-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: respect ancestor property tags in model extensions (#1037)
- Loading branch information
Showing
5 changed files
with
88 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NunoMaduro\Larastan\Reflection; | ||
|
||
use PHPStan\Reflection\ClassReflection; | ||
|
||
final class ReflectionHelper | ||
{ | ||
/** | ||
* Does the given class or any of its ancestors have an `@property*` annotation with the given name? | ||
*/ | ||
public static function hasPropertyTag(ClassReflection $classReflection, string $propertyName): bool | ||
{ | ||
if (array_key_exists($propertyName, $classReflection->getPropertyTags())) { | ||
return true; | ||
} | ||
|
||
foreach ($classReflection->getAncestors() as $ancestor) { | ||
if (array_key_exists($propertyName, $ancestor->getPropertyTags())) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
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