Skip to content

Commit

Permalink
There's no valid use-case to implement Scope or FunctionReflection
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 3, 2022
1 parent 5cf39bc commit 2796f8d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Rules/Api/ApiClassImplementsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleError;
Expand Down Expand Up @@ -69,6 +70,8 @@ private function checkName(Scope $scope, Node\Name $name): array
if (in_array($implementedClassReflection->getName(), [
Type::class,
ReflectionProvider::class,
Scope::class,
FunctionReflection::class,
], true)) {
return [$ruleError];
}
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Api/ApiClassImplementsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public function testRuleOutOfPhpStan(): void
322,
$tip,
],
[
'Implementing PHPStan\Analyser\Scope is not covered by backward compatibility promise. The interface might change in a minor PHPStan version.',
327,
$tip,
],
[
'Implementing PHPStan\Reflection\FunctionReflection is not covered by backward compatibility promise. The interface might change in a minor PHPStan version.',
332,
$tip,
],
]);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Api/data/class-implements-out-of-phpstan.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,13 @@ abstract class Dolor implements ReflectionProvider
{

}

abstract class MyScope implements Scope
{

}

abstract class MyFunctionReflection implements FunctionReflection
{

}

0 comments on commit 2796f8d

Please sign in to comment.