@@ -713,13 +713,7 @@ private function isAllowedProperty(string $class, string $property, bool $writeA
713713 return false ;
714714 }
715715
716- // PHP 8.4: Asymmetric Visibility and Property Hooks
717- $ hasAsymmetricVisibilityCapability = method_exists ($ reflectionProperty , 'isPrivateSet ' )
718- && method_exists ($ reflectionProperty , 'isProtectedSet ' )
719- && method_exists ($ reflectionProperty , 'isVirtual ' )
720- && method_exists ($ reflectionProperty , 'hasHook ' );
721-
722- if ($ hasAsymmetricVisibilityCapability ) {
716+ if (\PHP_VERSION_ID >= 80400 ) {
723717 // If the property is virtual and has no setter, it's not writable.
724718 if ($ writeAccessRequired && $ reflectionProperty ->isVirtual () && !$ reflectionProperty ->hasHook (\PropertyHookType::Set)) {
725719 return false ;
@@ -969,19 +963,18 @@ private function getReadVisiblityForMethod(\ReflectionMethod $reflectionMethod):
969963
970964 private function getWriteVisiblityForProperty (\ReflectionProperty $ reflectionProperty ): string
971965 {
972- // PHP 8.4: Property hooks
973- if ( method_exists ( $ reflectionProperty , ' isVirtual ' ) && method_exists ( $ reflectionProperty , ' hasHook ' )) {
966+ if (\ PHP_VERSION_ID >= 80400 ) {
967+ // If the property is virtual and has no setter, it's private
974968 if ($ reflectionProperty ->isVirtual () && !$ reflectionProperty ->hasHook (\PropertyHookType::Set)) {
975969 return PropertyWriteInfo::VISIBILITY_PRIVATE ;
976970 }
977- }
978971
979- // PHP 8.4: Asymmetric visibility
980- if (method_exists ($ reflectionProperty , 'isPrivateSet ' ) && method_exists ($ reflectionProperty , 'isProtectedSet ' )) {
972+ // If the property has private setter, it's not writable
981973 if ($ reflectionProperty ->isPrivateSet ()) {
982974 return PropertyWriteInfo::VISIBILITY_PRIVATE ;
983975 }
984976
977+ // If the property has protected setter, it's protected
985978 if ($ reflectionProperty ->isProtectedSet ()) {
986979 return PropertyWriteInfo::VISIBILITY_PROTECTED ;
987980 }
0 commit comments