@@ -381,6 +381,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
381
381
if (flags & (ZEND_ACC_CHANGED |ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
382
382
zend_class_entry * scope = get_fake_or_executed_scope ();
383
383
384
+ check_lexical_scope :
384
385
if (property_info -> ce != scope ) {
385
386
if (flags & ZEND_ACC_CHANGED ) {
386
387
zend_property_info * p = zend_get_parent_private_property (scope , ce , member );
@@ -401,11 +402,11 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
401
402
if (property_info -> ce != ce ) {
402
403
goto dynamic ;
403
404
} else {
404
- if (scope && scope -> lexical_scope && scope -> lexical_scope == ce ) {
405
- // Allow access to private properties from within the same outer class
406
- goto found ;
407
- }
408
405
wrong :
406
+ if (scope && scope -> lexical_scope ) {
407
+ scope = scope -> lexical_scope ;
408
+ goto check_lexical_scope ;
409
+ }
409
410
/* Information was available, but we were denied access. Error out. */
410
411
if (!silent ) {
411
412
zend_bad_property_access (property_info , ce , member );
@@ -1819,6 +1820,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
1819
1820
/* Check access level */
1820
1821
if (fbc -> op_array .fn_flags & (ZEND_ACC_CHANGED |ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
1821
1822
scope = zend_get_executed_scope ();
1823
+ zend_class_entry * original_scope = scope ;
1822
1824
check_lexical_scope :
1823
1825
1824
1826
if (fbc -> common .scope != scope ) {
@@ -1841,7 +1843,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
1841
1843
scope = scope -> lexical_scope ;
1842
1844
goto check_lexical_scope ;
1843
1845
}
1844
- zend_bad_method_call (fbc , method_name , scope );
1846
+ zend_bad_method_call (fbc , method_name , original_scope );
1845
1847
fbc = NULL ;
1846
1848
}
1847
1849
}
@@ -1900,6 +1902,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
1900
1902
fbc = Z_FUNC_P (func );
1901
1903
if (!(fbc -> op_array .fn_flags & ZEND_ACC_PUBLIC )) {
1902
1904
zend_class_entry * scope = zend_get_executed_scope ();
1905
+ zend_class_entry * original_scope = scope ;
1903
1906
check_lexical_scope :
1904
1907
if (UNEXPECTED (fbc -> common .scope != scope )) {
1905
1908
if (UNEXPECTED (fbc -> op_array .fn_flags & ZEND_ACC_PRIVATE )
@@ -1911,7 +1914,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
1911
1914
goto check_lexical_scope ;
1912
1915
}
1913
1916
1914
- zend_bad_method_call (fbc , function_name , scope );
1917
+ zend_bad_method_call (fbc , function_name , original_scope );
1915
1918
}
1916
1919
fbc = fallback_fbc ;
1917
1920
}
@@ -1988,10 +1991,15 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
1988
1991
1989
1992
if (!(property_info -> flags & ZEND_ACC_PUBLIC )) {
1990
1993
zend_class_entry * scope = get_fake_or_executed_scope ();
1994
+ check_lexical_scope :
1991
1995
if (property_info -> ce != scope ) {
1992
1996
if (UNEXPECTED (property_info -> flags & ZEND_ACC_PRIVATE )
1993
1997
|| UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
1994
1998
if (type != BP_VAR_IS ) {
1999
+ if (scope && scope -> lexical_scope ) {
2000
+ scope = scope -> lexical_scope ;
2001
+ goto check_lexical_scope ;
2002
+ }
1995
2003
zend_bad_property_access (property_info , ce , property_name );
1996
2004
}
1997
2005
return NULL ;
0 commit comments