diff --git a/composer.json b/composer.json index 97b4125b..2a8b8d9b 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "require-dev": { "phpunit/php-code-coverage": "^9.1.10", "friendsofphp/php-cs-fixer": "^3.51.0", - "phpstan/phpstan": "1.10.14", + "phpstan/phpstan": "1.11.3", "vimeo/psalm": "5.23.1" }, "scripts": { diff --git a/phpstan-baseline.php b/phpstan-baseline.php index f6d83f32..ae985b0d 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -226,11 +226,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Doctrine/Connection/Mssql.php', ); -$ignoreErrors[] = array( - 'message' => '#^Offset string does not exist on array\\, mixed\\>\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Doctrine/Connection/Mssql.php', -); $ignoreErrors[] = array( 'message' => '#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|null given\\.$#', 'count' => 1, @@ -486,11 +481,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Doctrine/Manager.php', ); -$ignoreErrors[] = array( - 'message' => '#^Cannot access offset \'dsn\'\\|\'fragment\'\\|\'host\'\\|\'pass\'\\|\'path\'\\|\'port\'\\|\'query\'\\|\'scheme\'\\|\'user\' on array\\<\'dsn\'\\|\'fragment\'\\|\'host\'\\|\'pass\'\\|\'path\'\\|\'port\'\\|\'query\'\\|\'scheme\'\\|\'user\', int\\<0, 65535\\>\\|string\\|null\\>\\|false\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Doctrine/Manager.php', -); $ignoreErrors[] = array( 'message' => '#^Parameter \\#1 \\$url of function parse_url expects string, string\\|null given\\.$#', 'count' => 1, @@ -506,16 +496,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Doctrine/Migration.php', ); -$ignoreErrors[] = array( - 'message' => '#^Parameter \\#1 \\$tableName of method Doctrine_Migration_Builder\\:\\:buildCreateForeignKey\\(\\) expects string, int\\|string given\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Doctrine/Migration/Builder.php', -); -$ignoreErrors[] = array( - 'message' => '#^Parameter \\#1 \\$tableName of method Doctrine_Migration_Builder\\:\\:buildDropForeignKey\\(\\) expects string, int\\|string given\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Doctrine/Migration/Builder.php', -); $ignoreErrors[] = array( 'message' => '#^Binary operation "\\." between array\\|string and string results in an error\\.$#', 'count' => 1, @@ -541,11 +521,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Doctrine/Node/NestedSet.php', ); -$ignoreErrors[] = array( - 'message' => '#^Cannot cast string\\|void to string\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Doctrine/Pager/Layout.php', -); $ignoreErrors[] = array( 'message' => '#^Method Doctrine_Parser\\:\\:doLoad\\(\\) should return string but returns string\\|false\\.$#', 'count' => 1, diff --git a/phpstan.neon b/phpstan.neon index 5fc6caa6..e4652370 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,14 +4,16 @@ includes: - ./phpstan-php8.php - ./phpstan-php82.php parameters: - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false inferPrivatePropertyTypeFromConstructor: true treatPhpDocTypesAsCertain: false level: 8 paths: - ./lib ignoreErrors: + - + identifier: missingType.generics + - + identifier: missingType.iterableValue ######### # Level 0 ######### @@ -237,8 +239,10 @@ parameters: # The Doctrine_Record::state method will return an int if it's not given any parameters ($state param == null), otherwise it returns nothing (void) # I checked that in all of the cases that phpstan complains about this method and returns from it, that they're being used properly (assigning # a value when no params are passed, not expecting a value when a param is passed) - - '#Parameter \#1 \$state of method Doctrine_Record::state\(\) expects int\|string\|null, int\|void given\.#' - - '#Parameter \#1 \$state of static method Doctrine_Lib::getRecordStateAsString\(\) expects int, int\|void given\.#' + - + message: '#Parameter \#1 \$state of static method Doctrine_Lib::getRecordStateAsString\(\) expects int, int\|null given\.#' + count: 1 + path: lib/Doctrine/Lib.php # Probably change the else condition of the ternary here to an empty string instead of null, Doctrine_Query:1043 - '#Parameter \#1 \$alias of method Doctrine_Query::_processPendingJoinConditions\(\) expects string, string\|null given\.#' # Same with this one, default for $alias should probably be an empty string, Doctrine_Table:1120 @@ -251,6 +255,17 @@ parameters: # function encounters an error, which would cause $query to be null. Not sure what do do in this error situation. - '#Parameter \#1 \$query of method Doctrine_Connection::execute\(\) expects string, string\|null given\.#' - '#Parameter \#1 \$query of method Doctrine_Connection::exec\(\) expects string, string\|null given\.#' + # These methods shouldn't return anything because it's a PHP magic method which is defined as a void return + # but we don't want to alter the behavior here in case anyone is actually using this method directly and expecting + # its return value + - + message: '#Method Doctrine_Event::__set\(\) with return type void returns \$this\(Doctrine_Event\) but should not return anything\.#' + count: 1 + path: lib/Doctrine/Event.php + - + message: '#Method Doctrine_Validator_Driver::__set\(\) with return type void returns \$this\(Doctrine_Validator_Driver\) but should not return anything\.#' + count: 1 + path: lib/Doctrine/Validator/Driver.php ################################################################################################################ # These are from the baseline generated by phpstan, but modified, so moved here so they don't change