@@ -70,7 +70,6 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
70
70
}
71
71
72
72
$ propertyValues = & $ this ->readPropertiesUntil ($ objectOrArray , $ propertyPath , $ propertyPath ->getLength () - 1 );
73
- $ overwrite = true ;
74
73
75
74
// Add the root object to the list
76
75
array_unshift ($ propertyValues , array (
@@ -81,18 +80,19 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
81
80
for ($ i = count ($ propertyValues ) - 1 ; $ i >= 0 ; --$ i ) {
82
81
$ objectOrArray = & $ propertyValues [$ i ][self ::VALUE ];
83
82
84
- if ($ overwrite ) {
85
- $ property = $ propertyPath ->getElement ($ i );
83
+ $ property = $ propertyPath ->getElement ($ i );
86
84
87
- if ($ propertyPath ->isIndex ($ i )) {
88
- $ this ->writeIndex ($ objectOrArray , $ property , $ value );
89
- } else {
90
- $ this ->writeProperty ($ objectOrArray , $ property , $ value );
91
- }
85
+ if ($ propertyPath ->isIndex ($ i )) {
86
+ $ this ->writeIndex ($ objectOrArray , $ property , $ value );
87
+ } else {
88
+ $ this ->writeProperty ($ objectOrArray , $ property , $ value );
89
+ }
90
+
91
+ if ($ propertyValues [$ i ][self ::IS_REF ]) {
92
+ return ;
92
93
}
93
94
94
95
$ value = & $ objectOrArray ;
95
- $ overwrite = !$ propertyValues [$ i ][self ::IS_REF ];
96
96
}
97
97
}
98
98
@@ -127,7 +127,6 @@ public function isWritable($objectOrArray, $propertyPath)
127
127
128
128
try {
129
129
$ propertyValues = $ this ->readPropertiesUntil ($ objectOrArray , $ propertyPath , $ propertyPath ->getLength () - 1 );
130
- $ overwrite = true ;
131
130
132
131
// Add the root object to the list
133
132
array_unshift ($ propertyValues , array (
@@ -138,21 +137,21 @@ public function isWritable($objectOrArray, $propertyPath)
138
137
for ($ i = count ($ propertyValues ) - 1 ; $ i >= 0 ; --$ i ) {
139
138
$ objectOrArray = $ propertyValues [$ i ][self ::VALUE ];
140
139
141
- if ($ overwrite ) {
142
- $ property = $ propertyPath ->getElement ($ i );
140
+ $ property = $ propertyPath ->getElement ($ i );
143
141
144
- if ($ propertyPath ->isIndex ($ i )) {
145
- if (!$ objectOrArray instanceof \ArrayAccess && !is_array ($ objectOrArray )) {
146
- return false ;
147
- }
148
- } else {
149
- if (!$ this ->isPropertyWritable ($ objectOrArray , $ property )) {
150
- return false ;
151
- }
142
+ if ($ propertyPath ->isIndex ($ i )) {
143
+ if (!$ objectOrArray instanceof \ArrayAccess && !is_array ($ objectOrArray )) {
144
+ return false ;
145
+ }
146
+ } else {
147
+ if (!$ this ->isPropertyWritable ($ objectOrArray , $ property )) {
148
+ return false ;
152
149
}
153
150
}
154
151
155
- $ overwrite = !$ propertyValues [$ i ][self ::IS_REF ];
152
+ if ($ propertyValues [$ i ][self ::IS_REF ]) {
153
+ return true ;
154
+ }
156
155
}
157
156
158
157
return true ;
0 commit comments