Skip to content

Commit 2c8ab04

Browse files
committed
Remove more bleeding edge toggles about phpdoc-parser
1 parent 694467a commit 2c8ab04

File tree

10 files changed

+5
-82
lines changed

10 files changed

+5
-82
lines changed

conf/bleedingEdge.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ parameters:
1616
consistentConstructor: true
1717
checkUnresolvableParameterTypes: true
1818
readOnlyByPhpDoc: true
19-
enableIgnoreErrorsWithinPhpDocs: true
2019
runtimeReflectionRules: true
2120
notAnalysedTrait: true
2221
curlSetOptTypes: true
@@ -41,7 +40,6 @@ parameters:
4140
propertyVariance: true
4241
genericPrototypeMessage: true
4342
stricterFunctionMap: true
44-
invalidPhpDocTagLine: true
4543
detectDeadTypeInMultiCatch: true
4644
zeroFiles: true
4745
projectServicesNotInAnalysedPaths: true

conf/config.level2.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ services:
145145
class: PHPStan\Rules\Methods\IllegalConstructorStaticCallRule
146146
-
147147
class: PHPStan\Rules\PhpDoc\InvalidPhpDocTagValueRule
148-
arguments:
149-
invalidPhpDocTagLine: %featureToggles.invalidPhpDocTagLine%
150148
tags:
151149
- phpstan.rules.rule
152150
-

conf/config.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ parameters:
5151
consistentConstructor: false
5252
checkUnresolvableParameterTypes: false
5353
readOnlyByPhpDoc: false
54-
enableIgnoreErrorsWithinPhpDocs: false
5554
runtimeReflectionRules: false
5655
notAnalysedTrait: false
5756
curlSetOptTypes: false
@@ -77,7 +76,6 @@ parameters:
7776
propertyVariance: false
7877
genericPrototypeMessage: false
7978
stricterFunctionMap: false
80-
invalidPhpDocTagLine: false
8179
detectDeadTypeInMultiCatch: false
8280
zeroFiles: false
8381
projectServicesNotInAnalysedPaths: false
@@ -2018,7 +2016,6 @@ services:
20182016
class: PHPStan\Parser\RichParser
20192017
arguments:
20202018
parser: @currentPhpVersionPhpParser
2021-
enableIgnoreErrorsWithinPhpDocs: %featureToggles.enableIgnoreErrorsWithinPhpDocs%
20222019
autowired: no
20232020

20242021
currentPhpVersionSimpleParser:

conf/parametersSchema.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ parametersSchema:
4646
consistentConstructor: bool()
4747
checkUnresolvableParameterTypes: bool()
4848
readOnlyByPhpDoc: bool()
49-
enableIgnoreErrorsWithinPhpDocs: bool()
5049
runtimeReflectionRules: bool()
5150
notAnalysedTrait: bool()
5251
curlSetOptTypes: bool()
@@ -71,7 +70,6 @@ parametersSchema:
7170
propertyVariance: bool()
7271
genericPrototypeMessage: bool()
7372
stricterFunctionMap: bool()
74-
invalidPhpDocTagLine: bool()
7573
detectDeadTypeInMultiCatch: bool()
7674
zeroFiles: bool()
7775
projectServicesNotInAnalysedPaths: bool()

src/Parser/RichParser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function __construct(
4444
private NameResolver $nameResolver,
4545
private Container $container,
4646
private IgnoreLexer $ignoreLexer,
47-
private bool $enableIgnoreErrorsWithinPhpDocs = false,
4847
)
4948
{
5049
}
@@ -152,7 +151,7 @@ private function getLinesToIgnore(array $tokens): array
152151
$isNextLine = str_contains($text, '@phpstan-ignore-next-line');
153152
$isCurrentLine = str_contains($text, '@phpstan-ignore-line');
154153

155-
if ($this->enableIgnoreErrorsWithinPhpDocs && $type === T_DOC_COMMENT) {
154+
if ($type === T_DOC_COMMENT) {
156155
$lines += $this->getLinesToIgnoreForTokenByIgnoreComment($text, $line, '@phpstan-ignore-line');
157156
if ($isNextLine) {
158157
$pattern = sprintf('~%s~si', implode('|', [self::PHPDOC_TAG_REGEX, self::PHPDOC_DOCTRINE_TAG_REGEX]));

src/PhpDoc/StubValidator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ private function getRuleRegistry(Container $container): RuleRegistry
217217
new InvalidPhpDocTagValueRule(
218218
$container->getByType(Lexer::class),
219219
$container->getByType(PhpDocParser::class),
220-
$container->getParameter('featureToggles')['invalidPhpDocTagLine'],
221220
),
222221
new IncompatibleParamImmediatelyInvokedCallableRule($fileTypeMapper),
223222
new IncompatibleSelfOutTypeRule($unresolvableTypeHelper, $genericObjectTypeCheck),

src/Rules/PhpDoc/InvalidPhpDocTagValueRule.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\Rules\PhpDoc;
44

5-
use Nette\Utils\Strings;
65
use PhpParser\Node;
76
use PHPStan\Analyser\Scope;
87
use PHPStan\Node\VirtualNode;
@@ -26,7 +25,6 @@ final class InvalidPhpDocTagValueRule implements Rule
2625
public function __construct(
2726
private Lexer $phpDocLexer,
2827
private PhpDocParser $phpDocParser,
29-
private bool $invalidPhpDocTagLine,
3028
)
3129
{
3230
}
@@ -72,7 +70,7 @@ public function processNode(Node $node, Scope $scope): array
7270
'PHPDoc tag %s %s has invalid value: %s',
7371
$phpDocTag->name,
7472
$phpDocTag->value->alias,
75-
$this->trimExceptionMessage($phpDocTag->value->type->getException()->getMessage()),
73+
$phpDocTag->value->type->getException()->getMessage(),
7674
))
7775
->line(PhpDocLineHelper::detectLine($node, $phpDocTag))
7876
->identifier('phpDoc.parseError')->build();
@@ -86,7 +84,7 @@ public function processNode(Node $node, Scope $scope): array
8684
'PHPDoc tag %s has invalid value (%s): %s',
8785
$phpDocTag->name,
8886
$phpDocTag->value->value,
89-
$this->trimExceptionMessage($phpDocTag->value->exception->getMessage()),
87+
$phpDocTag->value->exception->getMessage(),
9088
))
9189
->line(PhpDocLineHelper::detectLine($node, $phpDocTag))
9290
->identifier('phpDoc.parseError')->build();
@@ -95,13 +93,4 @@ public function processNode(Node $node, Scope $scope): array
9593
return $errors;
9694
}
9795

98-
private function trimExceptionMessage(string $message): string
99-
{
100-
if ($this->invalidPhpDocTagLine) {
101-
return $message;
102-
}
103-
104-
return Strings::replace($message, '~( on line \d+)$~', '');
105-
}
106-
10796
}

tests/PHPStan/Analyser/AnalyserTest.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,6 @@ public function testIgnoreNextLineUnmatched(): void
555555
}
556556
}
557557

558-
public function testIgnoreNextLineLegacyBehaviour(): void
559-
{
560-
$result = $this->runAnalyser([], false, [__DIR__ . '/data/ignore-next-line-legacy.php'], true, false);
561-
562-
foreach ([10, 32, 36] as $i => $line) {
563-
$this->assertArrayHasKey($i, $result);
564-
$this->assertInstanceOf(Error::class, $result[$i]);
565-
$this->assertSame('Fail.', $result[$i]->getMessage());
566-
$this->assertSame($line, $result[$i]->getLine());
567-
}
568-
}
569-
570558
/**
571559
* @dataProvider dataTrueAndFalse
572560
*/
@@ -653,10 +641,9 @@ private function runAnalyser(
653641
bool $reportUnmatchedIgnoredErrors,
654642
$filePaths,
655643
bool $onlyFiles,
656-
bool $enableIgnoreErrorsWithinPhpDocs = true,
657644
): array
658645
{
659-
$analyser = $this->createAnalyser($enableIgnoreErrorsWithinPhpDocs);
646+
$analyser = $this->createAnalyser();
660647

661648
if (is_string($filePaths)) {
662649
$filePaths = [$filePaths];
@@ -701,7 +688,7 @@ private function runAnalyser(
701688
);
702689
}
703690

704-
private function createAnalyser(bool $enableIgnoreErrorsWithinPhpDocs): Analyser
691+
private function createAnalyser(): Analyser
705692
{
706693
$ruleRegistry = new DirectRuleRegistry([
707694
new AlwaysFailRule(),
@@ -755,7 +742,6 @@ private function createAnalyser(bool $enableIgnoreErrorsWithinPhpDocs): Analyser
755742
new NameResolver(),
756743
self::getContainer(),
757744
new IgnoreLexer(),
758-
$enableIgnoreErrorsWithinPhpDocs,
759745
),
760746
new DependencyResolver($fileHelper, $reflectionProvider, new ExportedNodeResolver($fileTypeMapper, new ExprPrinter(new Printer())), $fileTypeMapper),
761747
new RuleErrorTransformer(),

tests/PHPStan/Analyser/data/ignore-next-line-legacy.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

tests/PHPStan/Rules/PhpDoc/InvalidPhpDocTagValueRuleTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ protected function getRule(): Rule
1818
return new InvalidPhpDocTagValueRule(
1919
self::getContainer()->getByType(Lexer::class),
2020
self::getContainer()->getByType(PhpDocParser::class),
21-
true,
2221
);
2322
}
2423

0 commit comments

Comments
 (0)