← All changes
|
vendor/symfony/property-info/Extractor/ReflectionExtractor.php
+34
-15
3.0.0
→
3.2.90
View file →
| @@ -7,21 +7,21 @@ | ||
| 7 | 7 | * |
| 8 | 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | 9 | * file that was distributed with this source code. |
| 10 | 10 | */ |
| 11 | -namespace WindPressPackages\Symfony\Component\PropertyInfo\Extractor; | |
| 11 | +namespace WindPressDeps\Symfony\Component\PropertyInfo\Extractor; | |
| 12 | 12 | |
| 13 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface; | |
| 14 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; | |
| 15 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyListExtractorInterface; | |
| 16 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyReadInfo; | |
| 17 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface; | |
| 18 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; | |
| 19 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyWriteInfo; | |
| 20 | -use WindPressPackages\Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface; | |
| 21 | -use WindPressPackages\Symfony\Component\PropertyInfo\Type; | |
| 22 | -use WindPressPackages\Symfony\Component\String\Inflector\EnglishInflector; | |
| 23 | -use WindPressPackages\Symfony\Component\String\Inflector\InflectorInterface; | |
| 13 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface; | |
| 14 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; | |
| 15 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyListExtractorInterface; | |
| 16 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyReadInfo; | |
| 17 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface; | |
| 18 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; | |
| 19 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyWriteInfo; | |
| 20 | +use WindPressDeps\Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface; | |
| 21 | +use WindPressDeps\Symfony\Component\PropertyInfo\Type; | |
| 22 | +use WindPressDeps\Symfony\Component\String\Inflector\EnglishInflector; | |
| 23 | +use WindPressDeps\Symfony\Component\String\Inflector\InflectorInterface; | |
| 24 | 24 | /** |
| 25 | 25 | * Extracts data using the reflection API. |
| 26 | 26 | * |
| 27 | 27 | * @author Kévin Dunglas <dunglas@gmail.com> |
| @@ -440,9 +440,9 @@ | ||
| 440 | 440 | private function extractFromReflectionType(\ReflectionType $reflectionType, \ReflectionClass $declaringClass): array |
| 441 | 441 | { |
| 442 | 442 | $types = []; |
| 443 | 443 | $nullable = $reflectionType->allowsNull(); |
| 444 | - foreach (($reflectionType instanceof \ReflectionUnionType || $reflectionType instanceof \ReflectionIntersectionType) ? $reflectionType->getTypes() : [$reflectionType] as $type) { | |
| 444 | + foreach ($reflectionType instanceof \ReflectionUnionType || $reflectionType instanceof \ReflectionIntersectionType ? $reflectionType->getTypes() : [$reflectionType] as $type) { | |
| 445 | 445 | if (!$type instanceof \ReflectionNamedType) { |
| 446 | 446 | // Nested composite types are not supported yet. |
| 447 | 447 | return []; |
| 448 | 448 | } |
| @@ -489,10 +489,18 @@ | ||
| 489 | 489 | private function isAllowedProperty(string $class, string $property, bool $writeAccessRequired = \false): bool |
| 490 | 490 | { |
| 491 | 491 | try { |
| 492 | 492 | $reflectionProperty = new \ReflectionProperty($class, $property); |
| 493 | - if (\PHP_VERSION_ID >= 80100 && $writeAccessRequired && $reflectionProperty->isReadOnly()) { | |
| 494 | - return \false; | |
| 493 | + if ($writeAccessRequired) { | |
| 494 | + if (\PHP_VERSION_ID >= 80100 && $reflectionProperty->isReadOnly()) { | |
| 495 | + return \false; | |
| 496 | + } | |
| 497 | + if (\PHP_VERSION_ID >= 80400 && ($reflectionProperty->isProtectedSet() || $reflectionProperty->isPrivateSet())) { | |
| 498 | + return \false; | |
| 499 | + } | |
| 500 | + if (\PHP_VERSION_ID >= 80400 && $reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) { | |
| 501 | + return \false; | |
| 502 | + } | |
| 495 | 503 | } |
| 496 | 504 | return (bool) ($reflectionProperty->getModifiers() & $this->propertyReflectionFlags); |
| 497 | 505 | } catch (\ReflectionException $e) { |
| 498 | 506 | // Return false if the property doesn't exist |
| @@ -685,8 +693,19 @@ | ||
| 685 | 693 | return PropertyReadInfo::VISIBILITY_PUBLIC; |
| 686 | 694 | } |
| 687 | 695 | private function getWriteVisiblityForProperty(\ReflectionProperty $reflectionProperty): string |
| 688 | 696 | { |
| 697 | + if (\PHP_VERSION_ID >= 80400) { | |
| 698 | + if ($reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) { | |
| 699 | + return PropertyWriteInfo::VISIBILITY_PRIVATE; | |
| 700 | + } | |
| 701 | + if ($reflectionProperty->isPrivateSet()) { | |
| 702 | + return PropertyWriteInfo::VISIBILITY_PRIVATE; | |
| 703 | + } | |
| 704 | + if ($reflectionProperty->isProtectedSet()) { | |
| 705 | + return PropertyWriteInfo::VISIBILITY_PROTECTED; | |
| 706 | + } | |
| 707 | + } | |
| 689 | 708 | if ($reflectionProperty->isPrivate()) { |
| 690 | 709 | return PropertyWriteInfo::VISIBILITY_PRIVATE; |
| 691 | 710 | } |
| 692 | 711 | if ($reflectionProperty->isProtected()) { |