Skip to content

refactor: using property promotion on ResponseTraitTest #9397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions tests/system/API/ResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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';
}
};
Expand Down
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/assign.propertyType.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 18 additions & 18 deletions utils/phpstan-baseline/missingType.iterableValue.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions utils/phpstan-baseline/missingType.parameter.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 3 additions & 43 deletions utils/phpstan-baseline/missingType.property.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 135 errors
# total 127 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -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
Expand Down
Loading