@@ -82,11 +82,16 @@ public function __construct(bool $magicCall = false, bool $throwExceptionOnInval
82
82
*/
83
83
public function getValue ($ objectOrArray , $ propertyPath )
84
84
{
85
- $ propertyPath = $ this ->getPropertyPath ($ propertyPath );
86
-
87
85
$ zval = [
88
86
self ::VALUE => $ objectOrArray ,
89
87
];
88
+
89
+ if (\is_object ($ objectOrArray ) && false === strpbrk ((string ) $ propertyPath , '.[ ' )) {
90
+ return $ this ->readProperty ($ zval , $ propertyPath )[self ::VALUE ];
91
+ }
92
+
93
+ $ propertyPath = $ this ->getPropertyPath ($ propertyPath );
94
+
90
95
$ propertyValues = $ this ->readPropertiesUntil ($ zval , $ propertyPath , $ propertyPath ->getLength (), $ this ->ignoreInvalidIndices );
91
96
92
97
return $ propertyValues [\count ($ propertyValues ) - 1 ][self ::VALUE ];
@@ -97,6 +102,22 @@ public function getValue($objectOrArray, $propertyPath)
97
102
*/
98
103
public function setValue (&$ objectOrArray , $ propertyPath , $ value )
99
104
{
105
+ if (\is_object ($ objectOrArray ) && false === strpbrk ((string ) $ propertyPath , '.[ ' )) {
106
+ $ zval = [
107
+ self ::VALUE => $ objectOrArray ,
108
+ ];
109
+
110
+ try {
111
+ $ this ->writeProperty ($ zval , $ propertyPath , $ value );
112
+
113
+ return ;
114
+ } catch (\TypeError $ e ) {
115
+ self ::throwInvalidArgumentException ($ e ->getMessage (), $ e ->getTrace (), 0 , $ propertyPath );
116
+ // It wasn't thrown in this class so rethrow it
117
+ throw $ e ;
118
+ }
119
+ }
120
+
100
121
$ propertyPath = $ this ->getPropertyPath ($ propertyPath );
101
122
102
123
$ zval = [
0 commit comments