From 0ecfb1eb565076bf31ecb652e542cf755a53daa7 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 10 Jan 2025 19:46:58 +0700 Subject: [PATCH 1/2] refactor: using property promotion on ResponseTraitTest --- tests/system/API/ResponseTraitTest.php | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index 25cccfbfca2a..dbdea6a6520d 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -116,14 +116,10 @@ protected function makeController(string $routePath = '', array $userHeaders = [ return new class ($this->request, $this->response, $this->formatter) { use ResponseTrait; - protected $request; - protected $response; protected $formatter; - public function __construct($request, $response, $formatter) + public function __construct(protected $request, protected $response, $formatter) { - $this->request = $request; - $this->response = $response; $this->formatter = $formatter; } @@ -177,15 +173,11 @@ public function testNoFormatterWithStringAsHtmlTrue(): void $controller = new class ($this->request, $this->response, $this->formatter) { use ResponseTrait; - protected $request; - protected $response; protected $formatter; protected bool $stringAsHtml = true; - public function __construct($request, $response, $formatter) + public function __construct(protected $request, protected $response, $formatter) { - $this->request = $request; - $this->response = $response; $this->formatter = $formatter; } }; @@ -299,15 +291,11 @@ public function testRespondSetsCorrectBodyAndStatusWithStringAsHtmlTrue(): void $controller = new class ($this->request, $this->response, $this->formatter) { use ResponseTrait; - protected $request; - protected $response; protected $formatter; protected bool $stringAsHtml = true; - public function __construct($request, $response, $formatter) + public function __construct(protected $request, protected $response, $formatter) { - $this->request = $request; - $this->response = $response; $this->formatter = $formatter; } }; @@ -639,14 +627,8 @@ public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML(): void $controller = new class ($request, $response) { use ResponseTrait; - protected $request; - protected $response; - - public function __construct($request, $response) + public function __construct(protected $request, protected $response) { - $this->request = $request; - $this->response = $response; - $this->format = 'txt'; } }; From e5f215c1dcc560ee9f838e9342f8926846825ccf Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 10 Jan 2025 19:49:41 +0700 Subject: [PATCH 2/2] refactor: regenerate baseline --- .../phpstan-baseline/assign.propertyType.neon | 2 +- .../missingType.iterableValue.neon | 36 +++++++-------- .../missingType.parameter.neon | 16 +++---- .../missingType.property.neon | 46 ++----------------- 4 files changed, 30 insertions(+), 70 deletions(-) diff --git a/utils/phpstan-baseline/assign.propertyType.neon b/utils/phpstan-baseline/assign.propertyType.neon index 2b5ea6f2ce06..6571e170e9f7 100644 --- a/utils/phpstan-baseline/assign.propertyType.neon +++ b/utils/phpstan-baseline/assign.propertyType.neon @@ -8,7 +8,7 @@ parameters: path: ../../system/Controller.php - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:\$format \(''html''\|''json''\|''xml''\|null\) does not accept ''txt''\.$#' + message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:\$format \(''html''\|''json''\|''xml''\|null\) does not accept ''txt''\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 044814f98ce4..d72e31df6792 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -6568,92 +6568,92 @@ parameters: path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:fail\(\) has parameter \$messages with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:fail\(\) has parameter \$messages with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:format\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:format\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:respond\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:respond\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:respondCreated\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:respondCreated\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:respondDeleted\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:respondDeleted\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:respondUpdated\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:respondUpdated\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:fail\(\) has parameter \$messages with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:fail\(\) has parameter \$messages with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:format\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:format\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:respond\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:respond\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:respondCreated\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:respondCreated\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:respondDeleted\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:respondDeleted\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:respondUpdated\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:respondUpdated\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:fail\(\) has parameter \$messages with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:fail\(\) has parameter \$messages with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:format\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:format\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:respond\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:respond\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:respondCreated\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:respondCreated\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:respondDeleted\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:respondDeleted\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:respondUpdated\(\) has parameter \$data with no value type specified in iterable type array\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:respondUpdated\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php diff --git a/utils/phpstan-baseline/missingType.parameter.neon b/utils/phpstan-baseline/missingType.parameter.neon index bde9193eae1a..faccbc8a91d8 100644 --- a/utils/phpstan-baseline/missingType.parameter.neon +++ b/utils/phpstan-baseline/missingType.parameter.neon @@ -128,42 +128,42 @@ parameters: path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:__construct\(\) has parameter \$formatter with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:__construct\(\) has parameter \$formatter with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:__construct\(\) has parameter \$request with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:__construct\(\) has parameter \$request with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:__construct\(\) has parameter \$response with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:__construct\(\) has parameter \$response with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:__construct\(\) has parameter \$formatter with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:__construct\(\) has parameter \$formatter with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:__construct\(\) has parameter \$request with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:__construct\(\) has parameter \$request with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:__construct\(\) has parameter \$response with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:__construct\(\) has parameter \$response with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:__construct\(\) has parameter \$request with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:__construct\(\) has parameter \$request with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:__construct\(\) has parameter \$response with no type specified\.$#' + message: '#^Method class@anonymous/tests/system/API/ResponseTraitTest\.php\:627\:\:__construct\(\) has parameter \$response with no type specified\.$#' count: 1 path: ../../tests/system/API/ResponseTraitTest.php diff --git a/utils/phpstan-baseline/missingType.property.neon b/utils/phpstan-baseline/missingType.property.neon index b1ec02957191..f9d34b635d94 100644 --- a/utils/phpstan-baseline/missingType.property.neon +++ b/utils/phpstan-baseline/missingType.property.neon @@ -1,4 +1,4 @@ -# total 135 errors +# total 127 errors parameters: ignoreErrors: @@ -148,55 +148,15 @@ parameters: path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:116\:\:\$request has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:116\:\:\$response has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:\$formatter has no type specified\.$#' + message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:173\:\:\$formatter has no type specified\.$#' count: 2 path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:\$request has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:177\:\:\$response has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:\$formatter has no type specified\.$#' + message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:291\:\:\$formatter has no type specified\.$#' count: 2 path: ../../tests/system/API/ResponseTraitTest.php - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:\$request has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:299\:\:\$response has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:\$request has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - - - message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:\$response has no type specified\.$#' - count: 1 - path: ../../tests/system/API/ResponseTraitTest.php - - message: '#^Property CodeIgniter\\Config\\Factory@anonymous/tests/system/Config/FactoriesTest\.php\:89\:\:\$widgets has no type specified\.$#' count: 1