Skip to content

Commit

Permalink
Merge pull request #873 from ergebnis/feature/phpstan
Browse files Browse the repository at this point in the history
Enhancement: Add support for `phpstan/phpstan:^2.0.0`
  • Loading branch information
localheinz authored Jan 8, 2025
2 parents 2754afb + ab9b03b commit 3046811
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
57 changes: 28 additions & 29 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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\<PHPStan\\Rules\\IdentifierRuleError\> 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

11 changes: 9 additions & 2 deletions src/Analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 3046811

Please # to comment.