diff --git a/composer.json b/composer.json index 7c4480773b..08af134c98 100644 --- a/composer.json +++ b/composer.json @@ -104,6 +104,7 @@ "phpmyadmin/coding-standard": "^3.0.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.4.8", + "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^8.5.16 || ^9.6", diff --git a/libraries/classes/Navigation/NavigationTree.php b/libraries/classes/Navigation/NavigationTree.php index df625a7ba7..636ccfd386 100644 --- a/libraries/classes/Navigation/NavigationTree.php +++ b/libraries/classes/Navigation/NavigationTree.php @@ -682,12 +682,12 @@ class NavigationTree foreach ($node->children as $child) { $prefixPos = false; foreach ($separators as $separator) { - $sepPos = mb_strpos((string) $child->name, $separator); + $sepPos = mb_strpos($child->name, $separator); if ( - $sepPos == false - || $sepPos == mb_strlen($child->name) - || $sepPos == 0 + $sepPos === false + || $sepPos === 0 || ($prefixPos !== false && $sepPos >= $prefixPos) + || $sepPos === mb_strlen($child->name) ) { continue; } diff --git a/libraries/classes/Utils/ForeignKey.php b/libraries/classes/Utils/ForeignKey.php index 165c02c3e7..e85b2af8ca 100644 --- a/libraries/classes/Utils/ForeignKey.php +++ b/libraries/classes/Utils/ForeignKey.php @@ -30,7 +30,7 @@ final class ForeignKey $dbi->fetchValue('SELECT @@ndb_version_string') ?: '' ); if (substr($ndbver, 0, 4) === 'ndb-') { - $ndbver = substr($ndbver, 4); + $ndbver = (string) substr($ndbver, 4); } return version_compare($ndbver, '7.3', '>='); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 77a705c932..a397e806f7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -8920,6 +8920,11 @@ parameters: count: 1 path: libraries/classes/UserPreferences.php + - + message: "#^Cannot access offset non\\-falsy\\-string on array\\{\\}\\|float\\|int\\|non\\-falsy\\-string\\.$#" + count: 1 + path: libraries/classes/Util.php + - message: "#^Cannot cast mixed to string\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 95b605ffdd..8ab678189e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -8565,8 +8565,7 @@ (int) $GLOBALS['cfg']['NavigationTreeDisplayDbFilterMinimum'] (int) $GLOBALS['cfg']['NavigationTreeDisplayItemFilterMinimum'] - - (string) $child->name + (string) $child->name (string) $key (string) $key @@ -15537,9 +15536,6 @@ - - setMethods - $serverRequest diff --git a/test/classes/Http/Factory/ServerRequestFactoryTest.php b/test/classes/Http/Factory/ServerRequestFactoryTest.php index 6c4880df93..c356c06347 100644 --- a/test/classes/Http/Factory/ServerRequestFactoryTest.php +++ b/test/classes/Http/Factory/ServerRequestFactoryTest.php @@ -130,7 +130,7 @@ class ServerRequestFactoryTest extends AbstractTestCase $_SERVER['HTTP_HOST'] = 'phpmyadmin.local'; $creator = $this->getMockBuilder(ServerRequestFactory::class) - ->setMethods(['getallheaders']) + ->onlyMethods(['getallheaders']) ->getMock(); $creator