-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config option to exclude mixin classes
- Loading branch information
1 parent
b58d311
commit b5a6597
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,22 @@ | |
use PHPStan\Reflection\ClassReflection; | ||
use PHPStan\Reflection\PropertiesClassReflectionExtension; | ||
use PHPStan\Reflection\PropertyReflection; | ||
use PHPStan\Type\TypeUtils; | ||
|
||
class MixinPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension | ||
{ | ||
|
||
/** @var string[] */ | ||
private $mixinExcludeClasses; | ||
|
||
/** | ||
* @param string[] $mixinExcludeClasses | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ondrejmirtes
Member
|
||
*/ | ||
public function __construct(array $mixinExcludeClasses) | ||
{ | ||
$this->mixinExcludeClasses = $mixinExcludeClasses; | ||
} | ||
|
||
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool | ||
{ | ||
return $this->findProperty($classReflection, $propertyName) !== null; | ||
|
@@ -29,6 +41,10 @@ private function findProperty(ClassReflection $classReflection, string $property | |
{ | ||
$mixinTypes = $classReflection->getResolvedMixinTypes(); | ||
foreach ($mixinTypes as $type) { | ||
if (count(array_intersect(TypeUtils::getDirectClassNames($type), $this->mixinExcludeClasses)) > 0) { | ||
continue; | ||
} | ||
|
||
if (!$type->hasProperty($propertyName)->yes()) { | ||
continue; | ||
} | ||
|
could this be something like
class-string[]
?