diff --git a/composer.json b/composer.json index 67f80068..2301078d 100644 --- a/composer.json +++ b/composer.json @@ -8,11 +8,11 @@ "nikic/php-parser": "^4.16", "nette/utils": "^3.2.9 || ^4.0", "webmozart/assert": "^1.11", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^1.10.35", "symplify/rule-doc-generator-contracts": "^11.1.26" }, "require-dev": { - "symplify/phpstan-extensions": "^11.2", + "symplify/phpstan-extensions": "^11.4", "symplify/rule-doc-generator": "^12.0", "phpunit/phpunit": "^10.3", "symfony/framework-bundle": "6.1.*", @@ -21,10 +21,10 @@ "symplify/easy-ci": "^11.3", "phpstan/extension-installer": "^1.3", "php-parallel-lint/php-parallel-lint": "^1.3", - "illuminate/console": "^10.9", - "tomasvotruba/unused-public": "^0.1.10", - "tomasvotruba/type-coverage": "^0.2.0", - "tomasvotruba/class-leak": "0.1.1.72" + "illuminate/console": "^10.25", + "tomasvotruba/unused-public": "^0.3", + "tomasvotruba/type-coverage": "^0.2", + "tomasvotruba/class-leak": "^0.1" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index 7f605daa..1cd7c39c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,7 @@ +includes: + - config/services/services.neon + - config/naming-rules.neon + parameters: level: 8 @@ -49,3 +53,6 @@ parameters: # overly detailed - '#Class Symplify\\PHPStanRules\\(.*?) extends generic class PHPStan\\Testing\\RuleTestCase but does not specify its types\: TRule#' - '#Method Symplify\\PHPStanRules\\(.*?)\:\:getRule\(\) return type with generic interface PHPStan\\Rules\\Rule does not specify its types\: TNodeType#' + + # part of public contract + - '#Public constant "Symplify\\PHPStanRules\\(.*?)\:\:ERROR_MESSAGE" is never used#' diff --git a/src/Rules/CheckTypehintCallerTypeRule.php b/src/Rules/CheckTypehintCallerTypeRule.php index 5bc434ab..d428c8ff 100644 --- a/src/Rules/CheckTypehintCallerTypeRule.php +++ b/src/Rules/CheckTypehintCallerTypeRule.php @@ -4,11 +4,11 @@ namespace Symplify\PHPStanRules\Rules; -use PhpParser\Node\Expr\Variable; -use PhpParser\Node\Expr; use PhpParser\Node; use PhpParser\Node\Arg; +use PhpParser\Node\Expr; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\Variable; use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Param; use PhpParser\Node\Stmt\ClassMethod; @@ -21,7 +21,6 @@ use PHPStan\Type\IntersectionType; use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; -use PHPStan\Type\ThisType; use PHPStan\Type\Type; use PHPStan\Type\UnionType; use PHPStan\Type\VerbosityLevel; @@ -66,8 +65,8 @@ public function processNode(Node $node, Scope $scope): array return []; } - if (!$node->var instanceof Variable - || !is_string($node->var->name) + if (! $node->var instanceof Variable + || ! is_string($node->var->name) || $node->var->name !== 'this' ) { return []; diff --git a/src/Rules/ClassNameRespectsParentSuffixRule.php b/src/Rules/ClassNameRespectsParentSuffixRule.php index 5fcf1b68..9d5c2103 100644 --- a/src/Rules/ClassNameRespectsParentSuffixRule.php +++ b/src/Rules/ClassNameRespectsParentSuffixRule.php @@ -34,7 +34,7 @@ final class ClassNameRespectsParentSuffixRule implements Rule, DocumentedRuleInt public const ERROR_MESSAGE = 'Class should have suffix "%s" to respect parent type'; /** - * @var class-string[] + * @var string[] */ private const DEFAULT_PARENT_CLASSES = [ Command::class, diff --git a/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php b/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php index e6e59fc3..4768b1a5 100644 --- a/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php +++ b/src/Rules/Explicit/ExplicitClassPrefixSuffixRule.php @@ -23,16 +23,19 @@ final class ExplicitClassPrefixSuffixRule implements Rule, DocumentedRuleInterface { /** + * @api * @var string */ public const INTERFACE_ERROR_MESSAGE = 'Interface must be suffixed with "Interface" exclusively'; /** + * @api * @var string */ public const TRAIT_ERROR_MESSAGE = 'Trait must be suffixed by "Trait" exclusively'; /** + * @api * @var string */ public const ABSTRACT_ERROR_MESSAGE = 'Abstract class must be prefixed by "Abstract" exclusively';