@@ -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 );
@@ -1861,6 +1866,8 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
1861
1866
/* Check access level */
1862
1867
if (fbc -> op_array .fn_flags & (ZEND_ACC_CHANGED |ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
1863
1868
scope = zend_get_executed_scope ();
1869
+ zend_class_entry * original_scope = scope ;
1870
+ check_lexical_scope :
1864
1871
1865
1872
if (fbc -> common .scope != scope ) {
1866
1873
if (fbc -> op_array .fn_flags & ZEND_ACC_CHANGED ) {
@@ -1878,7 +1885,11 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *
1878
1885
if (zobj -> ce -> __call ) {
1879
1886
fbc = zend_get_user_call_function (zobj -> ce , method_name );
1880
1887
} else {
1881
- zend_bad_method_call (fbc , method_name , scope );
1888
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
1889
+ scope = scope -> lexical_scope ;
1890
+ goto check_lexical_scope ;
1891
+ }
1892
+ zend_bad_method_call (fbc , method_name , original_scope );
1882
1893
fbc = NULL ;
1883
1894
}
1884
1895
}
@@ -1937,12 +1948,20 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
1937
1948
fbc = Z_FUNC_P (func );
1938
1949
if (!(fbc -> op_array .fn_flags & ZEND_ACC_PUBLIC )) {
1939
1950
zend_class_entry * scope = zend_get_executed_scope ();
1951
+ zend_class_entry * original_scope = scope ;
1952
+
1953
+ check_lexical_scope :
1940
1954
if (UNEXPECTED (fbc -> common .scope != scope )) {
1941
1955
if (UNEXPECTED (fbc -> op_array .fn_flags & ZEND_ACC_PRIVATE )
1942
1956
|| UNEXPECTED (!zend_check_protected (zend_get_function_root_class (fbc ), scope ))) {
1943
1957
zend_function * fallback_fbc = get_static_method_fallback (ce , function_name );
1944
1958
if (!fallback_fbc ) {
1945
- zend_bad_method_call (fbc , function_name , scope );
1959
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
1960
+ scope = scope -> lexical_scope ;
1961
+ goto check_lexical_scope ;
1962
+ }
1963
+
1964
+ zend_bad_method_call (fbc , function_name , original_scope );
1946
1965
}
1947
1966
fbc = fallback_fbc ;
1948
1967
}
@@ -2019,10 +2038,15 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
2019
2038
2020
2039
if (!(property_info -> flags & ZEND_ACC_PUBLIC )) {
2021
2040
zend_class_entry * scope = get_fake_or_executed_scope ();
2041
+ check_lexical_scope :
2022
2042
if (property_info -> ce != scope ) {
2023
2043
if (UNEXPECTED (property_info -> flags & ZEND_ACC_PRIVATE )
2024
2044
|| UNEXPECTED (!is_protected_compatible_scope (property_info -> ce , scope ))) {
2025
2045
if (type != BP_VAR_IS ) {
2046
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
2047
+ scope = scope -> lexical_scope ;
2048
+ goto check_lexical_scope ;
2049
+ }
2026
2050
zend_bad_property_access (property_info , ce , property_name );
2027
2051
}
2028
2052
return NULL ;
@@ -2103,10 +2127,16 @@ ZEND_API zend_function *zend_std_get_constructor(zend_object *zobj) /* {{{ */
2103
2127
if (constructor ) {
2104
2128
if (UNEXPECTED (!(constructor -> op_array .fn_flags & ZEND_ACC_PUBLIC ))) {
2105
2129
zend_class_entry * scope = get_fake_or_executed_scope ();
2130
+ zend_class_entry * original_scope = scope ;
2131
+ check_lexical_scope :
2106
2132
if (UNEXPECTED (constructor -> common .scope != scope )) {
2107
2133
if (UNEXPECTED (constructor -> op_array .fn_flags & ZEND_ACC_PRIVATE )
2108
2134
|| UNEXPECTED (!zend_check_protected (zend_get_function_root_class (constructor ), scope ))) {
2109
- zend_bad_constructor_call (constructor , scope );
2135
+ if (scope && scope -> lexical_scope && scope -> lexical_scope -> type != ZEND_NAMESPACE_CLASS ) {
2136
+ scope = scope -> lexical_scope ;
2137
+ goto check_lexical_scope ;
2138
+ }
2139
+ zend_bad_constructor_call (constructor , original_scope );
2110
2140
zend_object_store_ctor_failed (zobj );
2111
2141
constructor = NULL ;
2112
2142
}
0 commit comments