Skip to content

Commit 30f247d

Browse files
Add phpstan deprecation rule
1 parent 9dfe0ba commit 30f247d

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"friendsofphp/php-cs-fixer": "^3.13.0",
2828
"infection/infection": "^0.26.16 || ^0.32.0",
2929
"phpstan/phpstan": "^2.0",
30+
"phpstan/phpstan-deprecation-rules": "^2.0",
3031
"phpstan/phpstan-phpunit": "^2.0",
3132
"phpstan/phpstan-strict-rules": "^2.0",
3233
"phpstan/phpstan-symfony": "^2.0",

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ includes:
44
- vendor/phpstan/phpstan-symfony/extension.neon
55
- vendor/phpstan/phpstan-symfony/rules.neon
66
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
7+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
78
- vendor/phpstan/phpstan-strict-rules/rules.neon
89
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
910

src/Environment/Parser/ComponentTokenParser.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ private function parseArguments(): void
5757

5858
private function parseExpression(): void
5959
{
60-
// @phpstan-ignore-next-line
61-
if (method_exists($this->parser, 'parseExpression')) {
62-
// Since Twig 3.21
60+
// @phpstan-ignore-next-line function.alreadyNarrowedType
61+
if (method_exists($this->parser, 'parseExpression')) { // Since Twig 3.21
6362
$this->parser->parseExpression();
6463
} else {
64+
// @codeCoverageIgnoreStart
65+
// @phpstan-ignore-next-line method.deprecated, method.deprecatedClass
6566
$this->parser->getExpressionParser()->parseExpression();
67+
// @codeCoverageIgnoreEnd
6668
}
6769
}
6870
}

src/Token/Tokenizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,9 @@ private function getOperatorRegex(Environment $env): string
799799
}
800800
} else {
801801
// @codeCoverageIgnoreStart
802-
// @phpstan-ignore-next-line
802+
// @phpstan-ignore-next-line method.notFound, argument.type
803803
$unaryOperators = array_keys($env->getUnaryOperators());
804-
// @phpstan-ignore-next-line
804+
// @phpstan-ignore-next-line method.notFound, argument.type
805805
$binaryOperators = array_keys($env->getBinaryOperators());
806806
$expressionParsers = [...$unaryOperators, ...$binaryOperators];
807807
// @codeCoverageIgnoreEnd

tests/Environment/Fixtures/CustomTokenParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class CustomTokenParser extends AbstractTokenParser
1313
public function parse(Token $token): Node
1414
{
1515
if (!$this->parser->getStream()->test(Token::BLOCK_END_TYPE)) {
16+
// @phpstan-ignore-next-line method.deprecated, method.deprecatedClass
1617
$this->parser->getExpressionParser()->parseMultitargetExpression();
1718
}
1819
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);

tests/Token/Tokenizer/Fixtures/CustomTwigExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getOperators(): array
4646
['+sum' => [
4747
'precedence' => 0,
4848
'class' => AddBinary::class,
49-
'associativity' => ExpressionParser::OPERATOR_RIGHT,
49+
'associativity' => ExpressionParser::OPERATOR_RIGHT, // @phpstan-ignore classConstant.deprecatedClass
5050
]],
5151
];
5252
}

0 commit comments

Comments
 (0)