@@ -748,30 +748,13 @@ private function isPropertyWritable($object, $property)
748
748
return false ;
749
749
}
750
750
751
- $ reflClass = new \ReflectionClass ($ object );
752
-
753
- $ camelized = $ this ->camelize ($ property );
754
- $ setter = 'set ' .$ camelized ;
755
- $ getsetter = lcfirst ($ camelized ); // jQuery style, e.g. read: last(), write: last($item)
756
- $ classHasProperty = $ reflClass ->hasProperty ($ property );
757
-
758
- if ($ this ->isMethodAccessible ($ reflClass , $ setter , 1 )
759
- || $ this ->isMethodAccessible ($ reflClass , $ getsetter , 1 )
760
- || $ this ->isMethodAccessible ($ reflClass , '__set ' , 2 )
761
- || ($ classHasProperty && $ reflClass ->getProperty ($ property )->isPublic ())
762
- || (!$ classHasProperty && property_exists ($ object , $ property ))
763
- || ($ this ->magicCall && $ this ->isMethodAccessible ($ reflClass , '__call ' , 2 ))) {
764
- return true ;
765
- }
751
+ $ access = $ this ->getWriteAccessInfo (get_class ($ object ), $ property , array ());
766
752
767
- $ singulars = (array ) StringUtil::singularify ($ camelized );
768
-
769
- // Any of the two methods is required, but not yet known
770
- if (null !== $ this ->findAdderAndRemover ($ reflClass , $ singulars )) {
771
- return true ;
772
- }
773
-
774
- return false ;
753
+ return self ::ACCESS_TYPE_METHOD === $ access [self ::ACCESS_TYPE ]
754
+ || self ::ACCESS_TYPE_PROPERTY === $ access [self ::ACCESS_TYPE ]
755
+ || self ::ACCESS_TYPE_ADDER_AND_REMOVER === $ access [self ::ACCESS_TYPE ]
756
+ || (!$ access [self ::ACCESS_HAS_PROPERTY ] && property_exists ($ object , $ property ))
757
+ || self ::ACCESS_TYPE_MAGIC === $ access [self ::ACCESS_TYPE ];
775
758
}
776
759
777
760
/**
@@ -783,7 +766,7 @@ private function isPropertyWritable($object, $property)
783
766
*/
784
767
private function camelize ($ string )
785
768
{
786
- return strtr ( ucwords ( strtr ( $ string , array ( ' _ ' => ' ' ))), array ( ' ' => '' ));
769
+ return str_replace ( ' ' , '' , ucwords ( str_replace ( ' _ ' , ' ' , $ string ) ));
787
770
}
788
771
789
772
/**
0 commit comments