diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f419ecb..de0022bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), For a full diff see [`2.5.2...main`][2.5.2...main]. +### Added + +- Added support for `phpstan/phpstan:^2.0.0` ([#873]), by [@localheinz] + ## [`2.5.2`][2.5.2] For a full diff see [`2.5.1...2.5.2`][2.5.1...2.5.2]. @@ -567,6 +571,7 @@ For a full diff see [`362c7ea...0.1.0`][362c7ea...0.1.0]. [#862]: https://github.com/ergebnis/phpstan-rules/pull/862 [#863]: https://github.com/ergebnis/phpstan-rules/pull/863 [#872]: https://github.com/ergebnis/phpstan-rules/pull/872 +[#873]: https://github.com/ergebnis/phpstan-rules/pull/873 [#875]: https://github.com/ergebnis/phpstan-rules/pull/875 [#877]: https://github.com/ergebnis/phpstan-rules/pull/877 [#878]: https://github.com/ergebnis/phpstan-rules/pull/878 diff --git a/composer.json b/composer.json index 40192616..e020b473 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-mbstring": "*", - "phpstan/phpstan": "^1.10.21" + "phpstan/phpstan": "^2.0.0" }, "require-dev": { "doctrine/orm": "^2.20.0 || ^3.3.0", @@ -34,8 +34,8 @@ "nette/di": "^3.1.10", "nikic/php-parser": "^4.19.4", "phpstan/extension-installer": "^1.4.3", - "phpstan/phpstan-deprecation-rules": "^1.2.1", - "phpstan/phpstan-strict-rules": "^1.6.1", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpstan/phpstan-strict-rules": "^2.0.1", "phpunit/phpunit": "^9.6.21", "psr/container": "^2.0.2", "symfony/finder": "^5.4.45", diff --git a/composer.lock b/composer.lock index 38817c5c..5e5f77a4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,24 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "31f0e1fba4524e34ac08c37e71265e3c", + "content-hash": "a4c8640958f9c6d9280aac725322f4e1", "packages": [ { "name": "phpstan/phpstan", - "version": "1.12.12", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0" + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -62,7 +62,7 @@ "type": "github" } ], - "time": "2024-11-28T22:13:23+00:00" + "time": "2025-01-05T16:43:48+00:00" } ], "packages-dev": [ @@ -3376,26 +3376,26 @@ }, { "name": "phpstan/phpstan-deprecation-rules", - "version": "1.2.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82" + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/f94d246cc143ec5a23da868f8f7e1393b50eaa82", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -3417,34 +3417,33 @@ "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", "support": { "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.1" + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1" }, - "time": "2024-09-11T15:52:35+00:00" + "time": "2024-11-28T21:56:36+00:00" }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.6.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "daeec748b53de80a97498462513066834ec28f8b" + "reference": "ed6fea0ad4ad9c7e25f3ad2e7c4d420cf1e67fe3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/daeec748b53de80a97498462513066834ec28f8b", - "reference": "daeec748b53de80a97498462513066834ec28f8b", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/ed6fea0ad4ad9c7e25f3ad2e7c4d420cf1e67fe3", + "reference": "ed6fea0ad4ad9c7e25f3ad2e7c4d420cf1e67fe3", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12.4" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0.4" }, "require-dev": { - "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -3466,9 +3465,9 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.6.1" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/2.0.1" }, - "time": "2024-09-20T14:04:44+00:00" + "time": "2024-12-12T20:21:10+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ac0ddfff..c62dbe6c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,42 +1,56 @@ parameters: ignoreErrors: - - message: "#^Language construct isset\\(\\) should not be used\\.$#" + message: '#^Language construct isset\(\) should not be used\.$#' + identifier: ergebnis.noIsset count: 1 path: src/Classes/FinalRule.php - - message: "#^Language construct isset\\(\\) should not be used\\.$#" + message: '#^Language construct isset\(\) should not be used\.$#' + identifier: ergebnis.noIsset count: 1 path: src/Classes/NoExtendsRule.php - - message: "#^Language construct isset\\(\\) should not be used\\.$#" + message: '#^Language construct isset\(\) should not be used\.$#' + identifier: ergebnis.noIsset count: 1 path: src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php - - message: "#^Language construct isset\\(\\) should not be used\\.$#" + message: '#^Language construct isset\(\) should not be used\.$#' + identifier: ergebnis.noIsset count: 1 path: src/Functions/NoNullableReturnTypeDeclarationRule.php - - message: "#^Class PHPUnit\\\\Framework\\\\Attributes\\\\After not found\\.$#" + message: '#^Method Ergebnis\\PHPStan\\Rules\\Methods\\NoParameterWithContainerTypeDeclarationRule\:\:processNode\(\) should return list\ but returns list\.$#' + identifier: return.type + count: 1 + path: src/Methods/NoParameterWithContainerTypeDeclarationRule.php + + - + message: '#^Class PHPUnit\\Framework\\Attributes\\After not found\.$#' + identifier: class.notFound count: 1 path: src/Methods/PrivateInFinalClassRule.php - - message: "#^Class PHPUnit\\\\Framework\\\\Attributes\\\\Before not found\\.$#" + message: '#^Class PHPUnit\\Framework\\Attributes\\Before not found\.$#' + identifier: class.notFound count: 1 path: src/Methods/PrivateInFinalClassRule.php - - message: "#^Class PHPUnit\\\\Framework\\\\Attributes\\\\PostCondition not found\\.$#" + message: '#^Class PHPUnit\\Framework\\Attributes\\PostCondition not found\.$#' + identifier: class.notFound count: 1 path: src/Methods/PrivateInFinalClassRule.php - - message: "#^Class PHPUnit\\\\Framework\\\\Attributes\\\\PreCondition not found\\.$#" + message: '#^Class PHPUnit\\Framework\\Attributes\\PreCondition not found\.$#' + identifier: class.notFound count: 1 path: src/Methods/PrivateInFinalClassRule.php diff --git a/src/Analyzer.php b/src/Analyzer.php index 49981a2a..938cab76 100644 --- a/src/Analyzer.php +++ b/src/Analyzer.php @@ -49,9 +49,16 @@ public function isNullableTypeDeclaration($typeDeclaration): bool if ( $type instanceof Node\Name\FullyQualified - && 'null' === $type->toLowerString() + && $type->hasAttribute('originalName') ) { - return true; + $originalName = $type->getAttribute('originalName'); + + if ( + $originalName instanceof Node\Name + && 'null' === $originalName->toLowerString() + ) { + return true; + } } } }