@@ -713,13 +713,7 @@ private function isAllowedProperty(string $class, string $property, bool $writeA
713
713
return false ;
714
714
}
715
715
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 ) {
723
717
// If the property is virtual and has no setter, it's not writable.
724
718
if ($ writeAccessRequired && $ reflectionProperty ->isVirtual () && !$ reflectionProperty ->hasHook (\PropertyHookType::Set)) {
725
719
return false ;
@@ -969,15 +963,25 @@ private function getReadVisiblityForMethod(\ReflectionMethod $reflectionMethod):
969
963
970
964
private function getWriteVisiblityForProperty (\ReflectionProperty $ reflectionProperty ): string
971
965
{
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
974
968
if ($ reflectionProperty ->isVirtual () && !$ reflectionProperty ->hasHook (\PropertyHookType::Set)) {
975
969
return PropertyWriteInfo::VISIBILITY_PRIVATE ;
976
970
}
971
+
972
+ // If the property has private setter, it's not writable
973
+ if ($ reflectionProperty ->isPrivateSet ()) {
974
+ return PropertyWriteInfo::VISIBILITY_PRIVATE ;
975
+ }
976
+
977
+ // If the property has protected setter, it's protected
978
+ if ($ reflectionProperty ->isProtectedSet ()) {
979
+ return PropertyWriteInfo::VISIBILITY_PROTECTED ;
980
+ }
977
981
}
978
982
979
983
// PHP 8.4: Asymmetric visibility
980
- if (method_exists ( $ reflectionProperty , ' isPrivateSet ' ) && method_exists ( $ reflectionProperty , ' isProtectedSet ' ) ) {
984
+ if (\ PHP_VERSION_ID >= 80400 ) {
981
985
if ($ reflectionProperty ->isPrivateSet ()) {
982
986
return PropertyWriteInfo::VISIBILITY_PRIVATE ;
983
987
}
0 commit comments