diff --git a/phpstan.neon b/phpstan.neon index bf132e8..f3d023b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,6 @@ parameters: level: 10 reportUnmatchedIgnoredErrors: false + treatPhpDocTypesAsCertain: false paths: - src diff --git a/src/Linter/Configuration/YamlConfigurationLoader.php b/src/Linter/Configuration/YamlConfigurationLoader.php index e1f3a52..71b43cf 100644 --- a/src/Linter/Configuration/YamlConfigurationLoader.php +++ b/src/Linter/Configuration/YamlConfigurationLoader.php @@ -47,8 +47,6 @@ public function __construct(FileLocatorInterface $locator, YamlParser $yamlParse * @param string|null $type The resource type * * @return array - * - * @psalm-suppress MethodSignatureMismatch */ public function load(mixed $resource, ?string $type = null): array { @@ -73,8 +71,6 @@ public function load(mixed $resource, ?string $type = null): array * @param string|null $type The resource type * * @return bool true if this class supports the given resource, false otherwise - * - * @psalm-suppress MethodSignatureMismatch */ public function supports(mixed $resource, ?string $type = null): bool { diff --git a/src/Linter/Linter.php b/src/Linter/Linter.php index 2255654..427ac4c 100644 --- a/src/Linter/Linter.php +++ b/src/Linter/Linter.php @@ -58,7 +58,7 @@ public function lintFile( } /** - * @psalm-param TokenInterface[] $tokens + * @param TokenInterface[] $tokens */ private function lintTokenStream( array $tokens, @@ -82,7 +82,7 @@ private function lintTokenStream( } /** - * @psalm-param Statement[] $statements + * @param Statement[] $statements */ private function lintSyntaxTree( array $statements, diff --git a/src/Linter/Sniff/DeadCodeSniff.php b/src/Linter/Sniff/DeadCodeSniff.php index e41f3ee..d8d74a4 100644 --- a/src/Linter/Sniff/DeadCodeSniff.php +++ b/src/Linter/Sniff/DeadCodeSniff.php @@ -24,10 +24,6 @@ public function __construct(array $parameters) /** * @param TokenInterface[] $tokens - * @param File $file - * @param LinterConfiguration $configuration - * - * @return void */ public function sniff(array $tokens, File $file, LinterConfiguration $configuration): void { diff --git a/src/Linter/Sniff/IndentationSniff.php b/src/Linter/Sniff/IndentationSniff.php index 0e1f018..e6dc6b8 100644 --- a/src/Linter/Sniff/IndentationSniff.php +++ b/src/Linter/Sniff/IndentationSniff.php @@ -11,6 +11,13 @@ use Helmich\TypoScriptParser\Tokenizer\LineGrouper; use Helmich\TypoScriptParser\Tokenizer\TokenInterface; +/** + * @phpstan-type IndentationSniffParams array{ + * useSpaces: ?bool, + * indentPerLevel: ?int, + * indentConditions: ?bool, + * } + */ class IndentationSniff implements TokenStreamSniffInterface { use TokenInspections; @@ -30,10 +37,8 @@ class IndentationSniff implements TokenStreamSniffInterface private bool $insideCondition = false; /** - * @param array $parameters * - * @psalm-param array{useSpaces: ?bool, indentPerLevel: ?int, indentConditions: ?bool} $parameters - * @psalm-suppress MoreSpecificImplementedParamType + * @param IndentationSniffParams $parameters */ public function __construct(array $parameters) { @@ -50,10 +55,6 @@ public function __construct(array $parameters) /** * @param TokenInterface[] $tokens - * @param File $file - * @param LinterConfiguration $configuration - * - * @return void */ public function sniff(array $tokens, File $file, LinterConfiguration $configuration): void { @@ -103,8 +104,6 @@ public function sniff(array $tokens, File $file, LinterConfiguration $configurat * Checks if a stream of tokens is an empty line. * * @param TokenInterface[] $tokensInLine - * - * @return bool */ private function isEmptyLine(array $tokensInLine): bool { diff --git a/src/Linter/Sniff/NestingConsistencySniff.php b/src/Linter/Sniff/NestingConsistencySniff.php index 987f2f2..b1c2b54 100644 --- a/src/Linter/Sniff/NestingConsistencySniff.php +++ b/src/Linter/Sniff/NestingConsistencySniff.php @@ -5,15 +5,23 @@ use Helmich\TypoScriptLint\Linter\Sniff\Visitor\NestingConsistencyVisitor; use Helmich\TypoScriptLint\Linter\Sniff\Visitor\SniffVisitor; +/** + * @phpstan-type NestingConsistencySniffParams array{ + * commonPathPrefixThreshold: ?int + * } + */ class NestingConsistencySniff extends AbstractSyntaxTreeSniff { private int $commonPathPrefixThreshold = 1; + /** + * @param NestingConsistencySniffParams $parameters + */ public function __construct(array $parameters) { parent::__construct($parameters); - if (array_key_exists('commonPathPrefixThreshold', $parameters) && is_int($parameters['commonPathPrefixThreshold'])) { + if (isset($parameters['commonPathPrefixThreshold']) && is_int($parameters['commonPathPrefixThreshold'])) { $this->commonPathPrefixThreshold = $parameters['commonPathPrefixThreshold']; } } diff --git a/src/Linter/Sniff/OperatorWhitespaceSniff.php b/src/Linter/Sniff/OperatorWhitespaceSniff.php index e04a0cd..1f247e3 100644 --- a/src/Linter/Sniff/OperatorWhitespaceSniff.php +++ b/src/Linter/Sniff/OperatorWhitespaceSniff.php @@ -14,7 +14,7 @@ class OperatorWhitespaceSniff implements TokenStreamSniffInterface use TokenInspections; /** - * @param array $parameters + * @param array{} $parameters * @phpstan-ignore constructor.unusedParameter (defined in interface) */ public function __construct(array $parameters) diff --git a/src/Linter/Sniff/RepeatingRValueSniff.php b/src/Linter/Sniff/RepeatingRValueSniff.php index 4c41f77..59e340e 100644 --- a/src/Linter/Sniff/RepeatingRValueSniff.php +++ b/src/Linter/Sniff/RepeatingRValueSniff.php @@ -7,6 +7,12 @@ use Helmich\TypoScriptLint\Linter\Report\Issue; use Helmich\TypoScriptParser\Tokenizer\TokenInterface; +/** + * @phpstan-type RepeatingRValueSniffParams array{ + * allowedRightValues: ?string[], + * valueLengthThreshold: ?int, + * } + */ class RepeatingRValueSniff implements TokenStreamSniffInterface { @@ -21,8 +27,7 @@ class RepeatingRValueSniff implements TokenStreamSniffInterface private int $valueLengthThreshold = 8; /** - * @psalm-param array{allowedRightValues: ?string[], valueLengthThreshold: ?int} $parameters - * @psalm-suppress MoreSpecificImplementedParamType + * @param RepeatingRValueSniffParams $parameters */ public function __construct(array $parameters) { @@ -37,10 +42,6 @@ public function __construct(array $parameters) /** * @param TokenInterface[] $tokens - * @param File $file - * @param LinterConfiguration $configuration - * - * @return void */ public function sniff(array $tokens, File $file, LinterConfiguration $configuration): void { diff --git a/src/Linter/Sniff/Visitor/DuplicateAssignmentVisitor.php b/src/Linter/Sniff/Visitor/DuplicateAssignmentVisitor.php index 5ee7be6..3af60b8 100644 --- a/src/Linter/Sniff/Visitor/DuplicateAssignmentVisitor.php +++ b/src/Linter/Sniff/Visitor/DuplicateAssignmentVisitor.php @@ -39,7 +39,6 @@ public function enterNode(Statement $statement): void if ($statement instanceof Assignment && false === $this->inCondition) { if (isset($this->assignments[$statement->object->absoluteName])) { - /** @var Statement $lastAssignment */ $lastAssignment = $this->assignments[$statement->object->absoluteName]; $this->issues[] = new Issue( $lastAssignment->sourceLine,