@@ -95,7 +95,7 @@ public function getValue(object|array $objectOrArray, string|PropertyPathInterfa
95
95
self ::VALUE => $ objectOrArray ,
96
96
];
97
97
98
- if (\is_object ($ objectOrArray ) && false === strpbrk ((string ) $ propertyPath , '.[? ' )) {
98
+ if (\is_object ($ objectOrArray ) && false === strpbrk ((string ) $ propertyPath , '.[? ' ) || $ objectOrArray instanceof \stdClass && property_exists ( $ objectOrArray , $ propertyPath )) ) {
99
99
return $ this ->readProperty ($ zval , $ propertyPath , $ this ->ignoreInvalidProperty )[self ::VALUE ];
100
100
}
101
101
@@ -111,7 +111,7 @@ public function getValue(object|array $objectOrArray, string|PropertyPathInterfa
111
111
*/
112
112
public function setValue (object |array &$ objectOrArray , string |PropertyPathInterface $ propertyPath , mixed $ value )
113
113
{
114
- if (\is_object ($ objectOrArray ) && false === strpbrk ((string ) $ propertyPath , '.[ ' )) {
114
+ if (\is_object ($ objectOrArray ) && ( false === strpbrk ((string ) $ propertyPath , '.[ ' ) || $ objectOrArray instanceof \stdClass && property_exists ( $ objectOrArray , $ propertyPath ) )) {
115
115
$ zval = [
116
116
self ::VALUE => $ objectOrArray ,
117
117
];
@@ -214,7 +214,13 @@ public function isReadable(object|array $objectOrArray, string|PropertyPathInter
214
214
$ zval = [
215
215
self ::VALUE => $ objectOrArray ,
216
216
];
217
- $ this ->readPropertiesUntil ($ zval , $ propertyPath , $ propertyPath ->getLength (), $ this ->ignoreInvalidIndices );
217
+
218
+ // handle stdClass with properties with a dot in the name
219
+ if ($ objectOrArray instanceof \stdClass && str_contains ($ propertyPath , '. ' ) && property_exists ($ objectOrArray , $ propertyPath )) {
220
+ $ this ->readProperty ($ zval , $ propertyPath , $ this ->ignoreInvalidProperty );
221
+ } else {
222
+ $ this ->readPropertiesUntil ($ zval , $ propertyPath , $ propertyPath ->getLength (), $ this ->ignoreInvalidIndices );
223
+ }
218
224
219
225
return true ;
220
226
} catch (AccessException ) {
@@ -232,6 +238,14 @@ public function isWritable(object|array $objectOrArray, string|PropertyPathInter
232
238
$ zval = [
233
239
self ::VALUE => $ objectOrArray ,
234
240
];
241
+
242
+ // handle stdClass with properties with a dot in the name
243
+ if ($ objectOrArray instanceof \stdClass && str_contains ($ propertyPath , '. ' ) && property_exists ($ objectOrArray , $ propertyPath )) {
244
+ $ this ->readProperty ($ zval , $ propertyPath , $ this ->ignoreInvalidProperty );
245
+
246
+ return true ;
247
+ }
248
+
235
249
$ propertyValues = $ this ->readPropertiesUntil ($ zval , $ propertyPath , $ propertyPath ->getLength () - 1 );
236
250
237
251
for ($ i = \count ($ propertyValues ) - 1 ; 0 <= $ i ; --$ i ) {
0 commit comments