Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PHPStan rules and fix new reports #697

Merged
merged 2 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@
"symfony/http-kernel": "^5.3",
"symfony/process": "^5.3",
"symfony/yaml": "^5.3",
"symplify/astral": "^9.4.28",
"symplify/autowire-array-parameter": "^9.4.28",
"symplify/composer-json-manipulator": "^9.4.28",
"symplify/console-color-diff": "^9.4.28",
"symplify/package-builder": "^9.4.28",
"symplify/rule-doc-generator-contracts": "^9.4.28",
"symplify/simple-php-doc-parser": "^9.4.28",
"symplify/skipper": "^9.4.28",
"symplify/smart-file-system": "^9.4.28",
"symplify/symfony-php-config": "^9.4.28",
"symplify/astral": "^9.4.30",
"symplify/autowire-array-parameter": "^9.4.30",
"symplify/composer-json-manipulator": "^9.4.30",
"symplify/console-color-diff": "^9.4.30",
"symplify/package-builder": "^9.4.30",
"symplify/rule-doc-generator-contracts": "^9.4.30",
"symplify/simple-php-doc-parser": "^9.4.30",
"symplify/skipper": "^9.4.30",
"symplify/smart-file-system": "^9.4.30",
"symplify/symfony-php-config": "^9.4.30",
"tracy/tracy": "^2.8",
"webmozart/assert": "^1.10"
},
Expand All @@ -56,17 +56,17 @@
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-nette": "^0.12.19",
"phpunit/phpunit": "^9.5",
"rector/phpstan-rules": "^0.3.3",
"rector/phpstan-rules": "^0.3.5",
"rector/rector-generator": "^0.3",
"spatie/enum": "^3.9",
"symplify/coding-standard": "^9.4.28",
"symplify/easy-ci": "^9.4.28",
"symplify/easy-coding-standard": "^9.4.28",
"symplify/easy-testing": "^9.4.28",
"symplify/monorepo-builder": "^9.4.28",
"symplify/phpstan-extensions": "^9.4.28",
"symplify/phpstan-rules": "^9.4.28",
"symplify/rule-doc-generator": "^9.4.28",
"symplify/coding-standard": "^9.4.30",
"symplify/easy-ci": "^9.4.30",
"symplify/easy-coding-standard": "^9.4.30",
"symplify/easy-testing": "^9.4.30",
"symplify/monorepo-builder": "^9.4.30",
"symplify/phpstan-extensions": "^9.4.30",
"symplify/phpstan-rules": "^9.4.30",
"symplify/rule-doc-generator": "^9.4.30",
"timeweb/phpstan-enum": "^2.3"
},
"replace": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ private function processNodesWithMixinHandling(
array $nodes,
MutatingScope $mutatingScope,
callable $nodeCallback
): array
{
): array {
$contents = $smartFileInfo->getContents();

// avoid crash on class with @mixin @see https://github.com/rectorphp/rector-src/pull/688
Expand Down
15 changes: 15 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,18 @@ parameters:
-
message: '#Instead of array shape, use value object with specific types in constructor and getters#'
path: src/NodeFactory/ClassWithPublicPropertiesFactory.php #26

-
message: '#Instead of abstract class, use specific service with composition#'
paths:
- packages/BetterPhpDocParser/ValueObject/PhpDoc/DoctrineAnnotation/AbstractValuesAwareNode.php
- packages/PostRector/Rector/AbstractPostRector.php
- rules/Defluent/ValueObject/AbstractRootExpr.php
- rules/PhpSpecToPHPUnit/Rector/AbstractPhpSpecToPHPUnitRector.php
- src/Rector/AbstractRector.php

-
message: '#This call has duplicate argument#'
paths:
- rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php

10 changes: 6 additions & 4 deletions rules/DeadCode/ConditionEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

final class ConditionEvaluator
{
public function __construct(private PhpVersionProvider $phpVersionProvider)
{
public function __construct(
private PhpVersionProvider $phpVersionProvider
) {
}

/**
Expand All @@ -36,8 +37,9 @@ public function evaluate(ConditionInterface $condition)
return null;
}

private function evaluateVersionCompareCondition(VersionCompareCondition $versionCompareCondition): bool | int | null
{
private function evaluateVersionCompareCondition(
VersionCompareCondition $versionCompareCondition
): bool | int | null {
$compareSign = $versionCompareCondition->getCompareSign();
if ($compareSign !== null) {
if ($compareSign === '<' && $this->phpVersionProvider->provide() < $versionCompareCondition->getSecondVersion()) {
Expand Down
2 changes: 1 addition & 1 deletion utils/compiler/src/PhpScoper/StaticEasyPrefixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class StaticEasyPrefixer
// for usage in Helmich\TypoScriptParser\Parser\Traverser\Visitor
'Helmich\TypoScriptParser\Parser\AST\Statement',
// for usage in packages/Testing/PHPUnit/PlatformAgnosticAssertions.php
'PHPUnit\Framework\Constraint\IsEqual'
'PHPUnit\Framework\Constraint\IsEqual',
];

/**
Expand Down