Skip to content

Commit 319824a

Browse files
authored
Merge pull request #14692 from cakephp/phpstan
Update phpstan config.
2 parents 2ebb00a + 9d62bde commit 319824a

File tree

9 files changed

+20
-40
lines changed

9 files changed

+20
-40
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@
105105
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/",
106106
"test": "phpunit",
107107
"test-coverage": "phpunit --coverage-clover=clover.xml",
108-
"phpstan": "phpstan.phar analyse src/",
108+
"phpstan": "phpstan.phar analyse",
109109
"psalm": "psalm.phar --show-info=false",
110110
"stan": [
111111
"@phpstan",
112112
"@psalm"
113113
],
114-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.25 psalm/phar:~3.11.2 && mv composer.backup composer.json"
114+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 psalm/phar:~3.11.2 && mv composer.backup composer.json"
115115
},
116116
"config": {
117117
"sort-packages": true,

phpstan-baseline.neon

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ parameters:
2020
count: 1
2121
path: src/Auth/Storage/SessionStorage.php
2222

23-
-
24-
message: "#^Return type \\(\\$this\\(Cake\\\\Auth\\\\Storage\\\\SessionStorage\\)\\) of method Cake\\\\Auth\\\\Storage\\\\SessionStorage\\:\\:setConfig\\(\\) should be compatible with return type \\(\\$this\\(Cake\\\\Core\\\\InstanceConfigTrait\\)\\) of method Cake\\\\Core\\\\InstanceConfigTrait\\:\\:setConfig\\(\\)$#"
25-
count: 1
26-
path: src/Auth/Storage/SessionStorage.php
27-
28-
-
29-
message: "#^Return type \\(\\$this\\(Cake\\\\Auth\\\\Storage\\\\SessionStorage\\)\\) of method Cake\\\\Auth\\\\Storage\\\\SessionStorage\\:\\:configShallow\\(\\) should be compatible with return type \\(\\$this\\(Cake\\\\Core\\\\InstanceConfigTrait\\)\\) of method Cake\\\\Core\\\\InstanceConfigTrait\\:\\:configShallow\\(\\)$#"
30-
count: 1
31-
path: src/Auth/Storage/SessionStorage.php
32-
3323
-
3424
message: "#^Access to undefined constant Memcached\\:\\:OPT_CLIENT_MODE\\.$#"
3525
count: 1
@@ -266,14 +256,19 @@ parameters:
266256
path: src/Database/Log/LoggingStatement.php
267257

268258
-
269-
message: "#^Access to undefined constant PDO\\:\\:SQLSRV_ENCODING_BINARY\\.$#"
259+
message: "#^Result of && is always false\\.$#"
270260
count: 1
271-
path: src/Database/Statement/SqlserverStatement.php
261+
path: src/Datasource/QueryCacher.php
272262

273263
-
274-
message: "#^Result of && is always false\\.$#"
264+
message: "#^Property Cake\\\\ORM\\\\Query\\:\\:\\$_repository \\(Cake\\\\ORM\\\\Table\\) does not accept Cake\\\\Datasource\\\\RepositoryInterface\\.$#"
275265
count: 1
276-
path: src/Datasource/QueryCacher.php
266+
path: src/ORM/Query.php
267+
268+
-
269+
message: "#^Method Cake\\\\ORM\\\\Query\\:\\:find\\(\\) should return static\\(Cake\\\\ORM\\\\Query\\) but returns Cake\\\\ORM\\\\Query\\.$#"
270+
count: 1
271+
path: src/ORM/Query.php
277272

278273
-
279274
message: "#^Parameter \\#1 \\$rules of method Cake\\\\ORM\\\\Table\\:\\:buildRules\\(\\) expects Cake\\\\ORM\\\\RulesChecker, Cake\\\\Datasource\\\\RulesChecker given\\.$#"
@@ -435,21 +430,6 @@ parameters:
435430
count: 1
436431
path: src/ORM/Marshaller.php
437432

438-
-
439-
message: "#^Parameter \\#1 \\$table of method Cake\\\\ORM\\\\Query\\:\\:addDefaultTypes\\(\\) expects Cake\\\\ORM\\\\Table, Cake\\\\Datasource\\\\RepositoryInterface given\\.$#"
440-
count: 1
441-
path: src/ORM/Query.php
442-
443-
-
444-
message: "#^Parameter \\#1 \\$table of method Cake\\\\ORM\\\\Query\\:\\:_addAssociationsToTypeMap\\(\\) expects Cake\\\\ORM\\\\Table, Cake\\\\Datasource\\\\RepositoryInterface given\\.$#"
445-
count: 5
446-
path: src/ORM/Query.php
447-
448-
-
449-
message: "#^Method Cake\\\\ORM\\\\Query\\:\\:find\\(\\) should return static\\(Cake\\\\ORM\\\\Query\\) but returns Cake\\\\ORM\\\\Query\\.$#"
450-
count: 1
451-
path: src/ORM/Query.php
452-
453433
-
454434
message: "#^Parameter \\#2 \\$callback of function array_filter expects callable\\(mixed, mixed\\)\\: bool, 'strlen' given\\.$#"
455435
count: 1

phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ parameters:
66
checkMissingIterableValueType: false
77
checkGenericClassInNonGenericObjectType: false
88
treatPhpDocTypesAsCertain: false
9-
autoload_files:
9+
bootstrapFiles:
1010
- tests/bootstrap.php
11+
paths:
12+
- src
1113
earlyTerminatingMethodCalls:
1214
Cake\Console\Shell:
1315
- abort

src/Controller/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ public function redirect($url, int $status = 302): ?Response
637637
*
638638
* @param string $action The new action to be 'redirected' to.
639639
* Any other parameters passed to this method will be passed as parameters to the new action.
640-
* @param array ...$args Arguments passed to the action
640+
* @param mixed ...$args Arguments passed to the action
641641
* @return mixed Returns the return value of the called action
642642
*/
643643
public function setAction(string $action, ...$args)

src/Core/StaticConfigTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public static function drop(string $config): bool
155155
if (!isset(static::$_config[$config])) {
156156
return false;
157157
}
158-
/** @psalm-suppress UndefinedPropertyFetch */
159158
if (isset(static::$_registry)) {
160159
static::$_registry->unload($config);
161160
}

src/Database/Query.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,6 @@ public function page(int $num, ?int $limit = null)
13801380
*
13811381
* @param int|\Cake\Database\ExpressionInterface|null $num number of records to be returned
13821382
* @return $this
1383-
* @psalm-suppress MoreSpecificImplementedParamType
13841383
*/
13851384
public function limit($num)
13861385
{
@@ -1410,7 +1409,6 @@ public function limit($num)
14101409
*
14111410
* @param int|\Cake\Database\ExpressionInterface|null $num number of records to be skipped
14121411
* @return $this
1413-
* @psalm-suppress MoreSpecificImplementedParamType
14141412
*/
14151413
public function offset($num)
14161414
{

src/Http/ServerRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ public function __call(string $name, array $params)
613613
*
614614
* @param string|string[] $type The type of request you want to check. If an array
615615
* this method will return true if the request matches any type.
616-
* @param array ...$args List of arguments
616+
* @param string ...$args List of arguments
617617
* @return bool Whether or not the request is the type you are checking.
618618
*/
619619
public function is($type, ...$args): bool
@@ -1424,7 +1424,7 @@ public function getData(?string $name = null, $default = null)
14241424
* @param callable|null $callback A decoding callback that will convert the string data to another
14251425
* representation. Leave empty to access the raw input data. You can also
14261426
* supply additional parameters for the decoding callback using var args, see above.
1427-
* @param array ...$args The additional arguments
1427+
* @param mixed ...$args The additional arguments
14281428
* @return mixed The decoded/processed request data.
14291429
*/
14301430
public function input(?callable $callback = null, ...$args)

src/ORM/Query.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
* required.
4040
*
4141
* @see \Cake\Collection\CollectionInterface For a full description of the collection methods supported by this class
42+
* @property \Cake\ORM\Table $_repository Instance of a table object this query is bound to.
43+
* @method \Cake\ORM\Table getRepository() Returns the default table object that will be used by this query,
44+
* that is, the table that will appear in the from clause.
4245
* @method \Cake\Collection\CollectionInterface each(callable $c) Passes each of the query results to the callable
4346
* @method \Cake\Collection\CollectionInterface sortBy($callback, int $dir, int $type) Sorts the query with the callback
4447
* @method \Cake\Collection\CollectionInterface filter(callable $c = null) Keeps the results using passing the callable test
@@ -214,7 +217,6 @@ public function __construct(Connection $connection, Table $table)
214217
* to be added to the list.
215218
* @param bool $overwrite whether to reset fields with passed list or not
216219
* @return $this
217-
* @psalm-suppress MoreSpecificImplementedParamType
218220
*/
219221
public function select($fields = [], bool $overwrite = false)
220222
{

src/View/Form/EntityContext.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,6 @@ protected function _getTable($parts, $fallback = true): ?Table
659659
foreach ($normalized as $part) {
660660
if ($part === '_joinData') {
661661
if ($assoc !== null) {
662-
/** @psalm-suppress UndefinedMagicMethod */
663662
$table = $assoc->junction();
664663
$assoc = null;
665664
continue;

0 commit comments

Comments
 (0)