@@ -316,12 +316,20 @@ static ZEND_COLD zend_never_inline void zend_readonly_property_unset_error(
316
316
ZSTR_VAL (ce -> name ), ZSTR_VAL (member ));
317
317
}
318
318
319
+ static zend_always_inline zend_class_entry * get_fake_or_executed_scope (void )
320
+ {
321
+ if (UNEXPECTED (EG (fake_scope ))) {
322
+ return EG (fake_scope );
323
+ } else {
324
+ return zend_get_executed_scope ();
325
+ }
326
+ }
327
+
319
328
static zend_always_inline uintptr_t zend_get_property_offset (zend_class_entry * ce , zend_string * member , int silent , void * * cache_slot , const zend_property_info * * info_ptr ) /* {{{ */
320
329
{
321
330
zval * zv ;
322
331
zend_property_info * property_info ;
323
332
uint32_t flags ;
324
- zend_class_entry * scope ;
325
333
uintptr_t offset ;
326
334
327
335
if (cache_slot && EXPECTED (ce == CACHED_PTR_EX (cache_slot ))) {
@@ -349,11 +357,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
349
357
flags = property_info -> flags ;
350
358
351
359
if (flags & (ZEND_ACC_CHANGED |ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
352
- if (UNEXPECTED (EG (fake_scope ))) {
353
- scope = EG (fake_scope );
354
- } else {
355
- scope = zend_get_executed_scope ();
356
- }
360
+ zend_class_entry * scope = get_fake_or_executed_scope ();
357
361
358
362
if (property_info -> ce != scope ) {
359
363
if (flags & ZEND_ACC_CHANGED ) {
@@ -436,7 +440,6 @@ ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce,
436
440
zval * zv ;
437
441
zend_property_info * property_info ;
438
442
uint32_t flags ;
439
- zend_class_entry * scope ;
440
443
441
444
if (UNEXPECTED (zend_hash_num_elements (& ce -> properties_info ) == 0 )
442
445
|| EXPECTED ((zv = zend_hash_find (& ce -> properties_info , member )) == NULL )) {
@@ -454,11 +457,7 @@ ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce,
454
457
flags = property_info -> flags ;
455
458
456
459
if (flags & (ZEND_ACC_CHANGED |ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
457
- if (UNEXPECTED (EG (fake_scope ))) {
458
- scope = EG (fake_scope );
459
- } else {
460
- scope = zend_get_executed_scope ();
461
- }
460
+ zend_class_entry * scope = get_fake_or_executed_scope ();
462
461
if (property_info -> ce != scope ) {
463
462
if (flags & ZEND_ACC_CHANGED ) {
464
463
zend_property_info * p = zend_get_parent_private_property (scope , ce , member );
@@ -917,12 +916,7 @@ static zend_always_inline bool property_uses_strict_types(void) {
917
916
static bool verify_readonly_initialization_access (
918
917
const zend_property_info * prop_info , const zend_class_entry * ce ,
919
918
zend_string * name , const char * operation ) {
920
- zend_class_entry * scope ;
921
- if (UNEXPECTED (EG (fake_scope ))) {
922
- scope = EG (fake_scope );
923
- } else {
924
- scope = zend_get_executed_scope ();
925
- }
919
+ zend_class_entry * scope = get_fake_or_executed_scope ();
926
920
if (prop_info -> ce == scope ) {
927
921
return true;
928
922
}
@@ -1839,7 +1833,6 @@ ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
1839
1833
ZEND_API zval * zend_std_get_static_property_with_info (zend_class_entry * ce , zend_string * property_name , int type , zend_property_info * * property_info_ptr ) /* {{{ */
1840
1834
{
1841
1835
zval * ret ;
1842
- zend_class_entry * scope ;
1843
1836
zend_property_info * property_info = zend_hash_find_ptr (& ce -> properties_info , property_name );
1844
1837
* property_info_ptr = property_info ;
1845
1838
@@ -1848,11 +1841,7 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
1848
1841
}
1849
1842
1850
1843
if (!(property_info -> flags & ZEND_ACC_PUBLIC )) {
1851
- if (UNEXPECTED (EG (fake_scope ))) {
1852
- scope = EG (fake_scope );
1853
- } else {
1854
- scope = zend_get_executed_scope ();
1855
- }
1844
+ zend_class_entry * scope = get_fake_or_executed_scope ();
1856
1845
if (property_info -> ce != scope ) {
1857
1846
if (UNEXPECTED (property_info -> flags & ZEND_ACC_PRIVATE )
1858
1847
|| UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
@@ -1933,15 +1922,10 @@ static ZEND_COLD zend_never_inline void zend_bad_constructor_call(zend_function
1933
1922
ZEND_API zend_function * zend_std_get_constructor (zend_object * zobj ) /* {{{ */
1934
1923
{
1935
1924
zend_function * constructor = zobj -> ce -> constructor ;
1936
- zend_class_entry * scope ;
1937
1925
1938
1926
if (constructor ) {
1939
1927
if (UNEXPECTED (!(constructor -> op_array .fn_flags & ZEND_ACC_PUBLIC ))) {
1940
- if (UNEXPECTED (EG (fake_scope ))) {
1941
- scope = EG (fake_scope );
1942
- } else {
1943
- scope = zend_get_executed_scope ();
1944
- }
1928
+ zend_class_entry * scope = get_fake_or_executed_scope ();
1945
1929
if (UNEXPECTED (constructor -> common .scope != scope )) {
1946
1930
if (UNEXPECTED (constructor -> op_array .fn_flags & ZEND_ACC_PRIVATE )
1947
1931
|| UNEXPECTED (!zend_check_protected (zend_get_function_root_class (constructor ), scope ))) {
0 commit comments