Skip to content

Commit 80b8f87

Browse files
committed
GNSR - implement most GeneratorScope methods + almost final AssignHandler
1 parent 178939a commit 80b8f87

16 files changed

+4945
-208
lines changed

build/PHPStan/Build/ScopeGetTypeInGeneratorNamespaceRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function processNode(Node $node, Scope $scope): array
5353
}
5454
}
5555

56+
$inFunction = $scope->getFunction();
57+
if ($inFunction !== null && $inFunction->isDeprecated()->yes()) {
58+
return [];
59+
}
60+
5661
$methodReflection = $scope->getMethodReflection($calledOnType, $node->name->toString());
5762
if ($methodReflection === null) {
5863
return [];

phpstan-baseline.neon

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@ parameters:
1212
count: 1
1313
path: src/Analyser/AnalyserResultFinalizer.php
1414

15+
-
16+
rawMessage: 'Doing instanceof PHPStan\Type\Constant\ConstantStringType is error-prone and deprecated. Use Type::getConstantStrings() instead.'
17+
identifier: phpstanApi.instanceofType
18+
count: 1
19+
path: src/Analyser/Generator/ExprHandler/AssignHandler.php
20+
21+
-
22+
rawMessage: Casting to string something that's already string.
23+
identifier: cast.useless
24+
count: 2
25+
path: src/Analyser/Generator/GeneratorScope.php
26+
27+
-
28+
rawMessage: 'Doing instanceof PHPStan\Type\Constant\ConstantBooleanType is error-prone and deprecated. Use Type::isTrue() or Type::isFalse() instead.'
29+
identifier: phpstanApi.instanceofType
30+
count: 1
31+
path: src/Analyser/Generator/GeneratorScope.php
32+
33+
-
34+
rawMessage: 'Doing instanceof PHPStan\Type\Constant\ConstantStringType is error-prone and deprecated. Use Type::getConstantStrings() instead.'
35+
identifier: phpstanApi.instanceofType
36+
count: 3
37+
path: src/Analyser/Generator/GeneratorScope.php
38+
1539
-
1640
rawMessage: Cannot assign offset 'realCount' to array<mixed>|string.
1741
identifier: offsetAssign.dimType

src/Analyser/Generator/ExprAnalysisResult.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Analyser\Generator;
44

55
use PHPStan\Analyser\ImpurePoint;
6+
use PHPStan\Analyser\SpecifiedTypes;
67
use PHPStan\Type\Type;
78

89
final class ExprAnalysisResult
@@ -14,11 +15,14 @@ final class ExprAnalysisResult
1415
*/
1516
public function __construct(
1617
public readonly Type $type,
18+
public readonly Type $nativeType,
1719
public readonly GeneratorScope $scope,
1820
public readonly bool $hasYield,
1921
public readonly bool $isAlwaysTerminating,
2022
public readonly array $throwPoints,
2123
public readonly array $impurePoints,
24+
public readonly SpecifiedTypes $specifiedTruthyTypes,
25+
public readonly SpecifiedTypes $specifiedFalseyTypes,
2226
)
2327
{
2428
}

0 commit comments

Comments
 (0)