@@ -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 );
@@ -402,6 +403,10 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
402
403
goto dynamic ;
403
404
} else {
404
405
wrong :
406
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
407
+ scope = scope -> lexical_scope ;
408
+ goto check_lexical_scope ;
409
+ }
405
410
/* Information was available, but we were denied access. Error out. */
406
411
if (!silent ) {
407
412
zend_bad_property_access (property_info , ce , member );
@@ -1818,6 +1823,8 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
1818
1823
/* Check access level */
1819
1824
if (fbc -> op_array .fn_flags & (ZEND_ACC_CHANGED |ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
1820
1825
scope = zend_get_executed_scope ();
1826
+ zend_class_entry * original_scope = scope ;
1827
+ check_lexical_scope :
1821
1828
1822
1829
if (fbc -> common .scope != scope ) {
1823
1830
if (fbc -> op_array .fn_flags & ZEND_ACC_CHANGED ) {
@@ -1835,7 +1842,11 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
1835
1842
if (zobj -> ce -> __call ) {
1836
1843
fbc = zend_get_user_call_function (zobj -> ce , method_name );
1837
1844
} else {
1838
- zend_bad_method_call (fbc , method_name , scope );
1845
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
1846
+ scope = scope -> lexical_scope ;
1847
+ goto check_lexical_scope ;
1848
+ }
1849
+ zend_bad_method_call (fbc , method_name , original_scope );
1839
1850
fbc = NULL ;
1840
1851
}
1841
1852
}
@@ -1894,12 +1905,20 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
1894
1905
fbc = Z_FUNC_P (func );
1895
1906
if (!(fbc -> op_array .fn_flags & ZEND_ACC_PUBLIC )) {
1896
1907
zend_class_entry * scope = zend_get_executed_scope ();
1908
+ zend_class_entry * original_scope = scope ;
1909
+
1910
+ check_lexical_scope :
1897
1911
if (UNEXPECTED (fbc -> common .scope != scope )) {
1898
1912
if (UNEXPECTED (fbc -> op_array .fn_flags & ZEND_ACC_PRIVATE )
1899
1913
|| UNEXPECTED (!zend_check_protected (zend_get_function_root_class (fbc ), scope ))) {
1900
1914
zend_function * fallback_fbc = get_static_method_fallback (ce , function_name );
1901
1915
if (!fallback_fbc ) {
1902
- zend_bad_method_call (fbc , function_name , scope );
1916
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
1917
+ scope = scope -> lexical_scope ;
1918
+ goto check_lexical_scope ;
1919
+ }
1920
+
1921
+ zend_bad_method_call (fbc , function_name , original_scope );
1903
1922
}
1904
1923
fbc = fallback_fbc ;
1905
1924
}
@@ -1976,10 +1995,15 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
1976
1995
1977
1996
if (!(property_info -> flags & ZEND_ACC_PUBLIC )) {
1978
1997
zend_class_entry * scope = get_fake_or_executed_scope ();
1998
+ check_lexical_scope :
1979
1999
if (property_info -> ce != scope ) {
1980
2000
if (UNEXPECTED (property_info -> flags & ZEND_ACC_PRIVATE )
1981
2001
|| UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
1982
2002
if (type != BP_VAR_IS ) {
2003
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
2004
+ scope = scope -> lexical_scope ;
2005
+ goto check_lexical_scope ;
2006
+ }
1983
2007
zend_bad_property_access (property_info , ce , property_name );
1984
2008
}
1985
2009
return NULL ;
@@ -2060,10 +2084,16 @@ ZEND_API zend_function *zend_std_get_constructor(zend_object *zobj) /* {{{ */
2060
2084
if (constructor ) {
2061
2085
if (UNEXPECTED (!(constructor -> op_array .fn_flags & ZEND_ACC_PUBLIC ))) {
2062
2086
zend_class_entry * scope = get_fake_or_executed_scope ();
2087
+ zend_class_entry * original_scope = scope ;
2088
+ check_lexical_scope :
2063
2089
if (UNEXPECTED (constructor -> common .scope != scope )) {
2064
2090
if (UNEXPECTED (constructor -> op_array .fn_flags & ZEND_ACC_PRIVATE )
2065
2091
|| UNEXPECTED (!zend_check_protected (zend_get_function_root_class (constructor ), scope ))) {
2066
- zend_bad_constructor_call (constructor , scope );
2092
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
2093
+ scope = scope -> lexical_scope ;
2094
+ goto check_lexical_scope ;
2095
+ }
2096
+ zend_bad_constructor_call (constructor , original_scope );
2067
2097
zend_object_store_ctor_failed (zobj );
2068
2098
constructor = NULL ;
2069
2099
}
0 commit comments