@@ -48,7 +48,7 @@ public static function staticProxyConstructor($initializer)
48
48
static $ reflection ;
49
49
50
50
$ reflection = $ reflection ?? new \ReflectionClass (__CLASS__ );
51
- $ instance%w = $ reflection ->newInstanceWithoutConstructor ();
51
+ $ instance = $ reflection ->newInstanceWithoutConstructor ();
52
52
53
53
$ instance ->initializer %s = $ initializer ;
54
54
@@ -73,48 +73,114 @@ public function & __get($name)
73
73
return $ this ->valueHolder %s->$ name ;
74
74
}
75
75
76
+ $ realInstanceReflection = new \ReflectionClass (__CLASS__ );
77
+
78
+ if (! $ realInstanceReflection ->hasProperty ($ name )) {
79
+ $ targetObject = $ this ->valueHolder %s;
80
+
81
+ $ backtrace = debug_backtrace (false , 1 );
82
+ trigger_error (
83
+ sprintf (
84
+ 'Undefined property: %%s::$%%s in %%s on line %%s ' ,
85
+ $ realInstanceReflection ->getName (),
86
+ $ name ,
87
+ $ backtrace [0 ]['file ' ],
88
+ $ backtrace [0 ]['line ' ]
89
+ ),
90
+ \E_USER_NOTICE
91
+ );
92
+ return $ targetObject ->$ name ;
93
+ }
94
+
76
95
$ targetObject = $ this ->valueHolder %s;
96
+ $ accessor = function & () use ($ targetObject , $ name ) {
97
+ return $ targetObject ->$ name ;
98
+ };
99
+ $ backtrace = debug_backtrace (true , 2 );
100
+ $ scopeObject = isset ($ backtrace [1 ]['object ' ]) ? $ backtrace [1 ]['object ' ] : new \ProxyManager \Stub \EmptyClassStub ();
101
+ $ accessor = $ accessor ->bindTo ($ scopeObject , get_class ($ scopeObject ));
102
+ $ returnValue = & $ accessor ();
77
103
78
- $ backtrace = debug_backtrace (false %S);
79
- trigger_error (
80
- sprintf (
81
- 'Undefined property: %s::$%s in %s on line %s ' ,
82
- __CLASS__ ,
83
- $ name ,
84
- $ backtrace [0 ]['file ' ],
85
- $ backtrace [0 ]['line ' ]
86
- ),
87
- \E_USER_NOTICE
88
- );
89
- return $ targetObject ->$ name ;
104
+ return $ returnValue ;
90
105
}
91
106
92
107
public function __set ($ name , $ value )
93
108
{
94
109
$ this ->initializer %s && ($ this ->initializer %s->__invoke ($ valueHolder %s, $ this , '__set ' , array ('name ' => $ name , 'value ' => $ value ), $ this ->initializer %s) || 1 ) && $ this ->valueHolder %s = $ valueHolder %s;
95
110
111
+ $ realInstanceReflection = new \ReflectionClass (__CLASS__ );
112
+
113
+ if (! $ realInstanceReflection ->hasProperty ($ name )) {
114
+ $ targetObject = $ this ->valueHolder %s;
115
+
116
+ $ targetObject ->$ name = $ value ;
117
+
118
+ return $ targetObject ->$ name ;
119
+ }
120
+
96
121
$ targetObject = $ this ->valueHolder %s;
122
+ $ accessor = function & () use ($ targetObject , $ name , $ value ) {
123
+ $ targetObject ->$ name = $ value ;
124
+
125
+ return $ targetObject ->$ name ;
126
+ };
127
+ $ backtrace = debug_backtrace (true , 2 );
128
+ $ scopeObject = isset ($ backtrace [1 ]['object ' ]) ? $ backtrace [1 ]['object ' ] : new \ProxyManager \Stub \EmptyClassStub ();
129
+ $ accessor = $ accessor ->bindTo ($ scopeObject , get_class ($ scopeObject ));
130
+ $ returnValue = & $ accessor ();
97
131
98
- $ targetObject -> $ name = $ value ;%wreturn $ targetObject -> $ name ;
132
+ return $ returnValue ;
99
133
}
100
134
101
135
public function __isset ($ name )
102
136
{
103
137
$ this ->initializer %s && ($ this ->initializer %s->__invoke ($ valueHolder %s, $ this , '__isset ' , array ('name ' => $ name ), $ this ->initializer %s) || 1 ) && $ this ->valueHolder %s = $ valueHolder %s;
104
138
139
+ $ realInstanceReflection = new \ReflectionClass (__CLASS__ );
140
+
141
+ if (! $ realInstanceReflection ->hasProperty ($ name )) {
142
+ $ targetObject = $ this ->valueHolder %s;
143
+
144
+ return isset ($ targetObject ->$ name );
145
+ }
146
+
105
147
$ targetObject = $ this ->valueHolder %s;
148
+ $ accessor = function () use ($ targetObject , $ name ) {
149
+ return isset ($ targetObject ->$ name );
150
+ };
151
+ $ backtrace = debug_backtrace (true , 2 );
152
+ $ scopeObject = isset ($ backtrace [1 ]['object ' ]) ? $ backtrace [1 ]['object ' ] : new \ProxyManager \Stub \EmptyClassStub ();
153
+ $ accessor = $ accessor ->bindTo ($ scopeObject , get_class ($ scopeObject ));
154
+ $ returnValue = $ accessor ();
106
155
107
- return isset ( $ targetObject -> $ name ) ;
156
+ return $ returnValue ;
108
157
}
109
158
110
159
public function __unset ($ name )
111
160
{
112
161
$ this ->initializer %s && ($ this ->initializer %s->__invoke ($ valueHolder %s, $ this , '__unset ' , array ('name ' => $ name ), $ this ->initializer %s) || 1 ) && $ this ->valueHolder %s = $ valueHolder %s;
113
162
114
- $ targetObject = $ this ->valueHolder %s;
163
+ $ realInstanceReflection = new \ReflectionClass (__CLASS__ );
164
+
165
+ if (! $ realInstanceReflection ->hasProperty ($ name )) {
166
+ $ targetObject = $ this ->valueHolder %s;
115
167
116
- unset($ targetObject ->$ name );
117
- %a }
168
+ unset($ targetObject ->$ name );
169
+
170
+ return ;
171
+ }
172
+
173
+ $ targetObject = $ this ->valueHolder %s;
174
+ $ accessor = function () use ($ targetObject , $ name ) {
175
+ unset($ targetObject ->$ name );
176
+
177
+ return ;
178
+ };
179
+ $ backtrace = debug_backtrace (true , 2 );
180
+ $ scopeObject = isset ($ backtrace [1 ]['object ' ]) ? $ backtrace [1 ]['object ' ] : new \ProxyManager \Stub \EmptyClassStub ();
181
+ $ accessor = $ accessor ->bindTo ($ scopeObject , get_class ($ scopeObject ));
182
+ $ accessor ();
183
+ }
118
184
119
185
public function __clone ()
120
186
{
0 commit comments