@@ -1798,108 +1798,6 @@ ZEND_VM_C_LABEL(fetch_this):
17981798 ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION ();
17991799}
18001800
1801- ZEND_VM_HANDLER (210 , ZEND_FETCH_INNER_CLASS , CONST |TMPVAR |UNUSED , CONST , CACHE_SLOT )
1802- {
1803- USE_OPLINE
1804- SAVE_OPLINE ();
1805-
1806- zend_string * inner_class_name , * full_class_name ;
1807- zend_class_entry * outer_ce = NULL , * inner_ce = NULL , * scope = NULL ;
1808-
1809- scope = EX (func )-> op_array .scope ;
1810-
1811- if (OP1_TYPE == IS_CONST ) {
1812- zval * outer_class_zv = RT_CONSTANT (opline , opline -> op1 );
1813- outer_ce = zend_lookup_class (Z_STR_P (outer_class_zv ));
1814- if (!outer_ce ) {
1815- zend_error (E_ERROR , "Outer class '%s' not found for inner class %s:>%s" , Z_STRVAL_P (outer_class_zv ), Z_STRVAL_P (outer_class_zv ), Z_STRVAL_P (RT_CONSTANT (opline , opline -> op2 )));
1816- HANDLE_EXCEPTION ();
1817- }
1818- } else if (OP1_TYPE == IS_UNUSED ) {
1819- uint32_t fetch_type ;
1820- zend_class_entry * called_scope ;
1821-
1822- fetch_type = opline -> op1 .num & ZEND_FETCH_CLASS_MASK ;
1823- if (UNEXPECTED (scope == NULL )) {
1824- SAVE_OPLINE ();
1825- zend_throw_error (NULL , "Cannot use \"%s\" in the global scope" ,
1826- fetch_type == ZEND_FETCH_CLASS_SELF ? "self" :
1827- fetch_type == ZEND_FETCH_CLASS_PARENT ? "parent" : "static" );
1828- ZVAL_UNDEF (EX_VAR (opline -> result .var ));
1829- HANDLE_EXCEPTION ();
1830- }
1831- if (fetch_type == ZEND_FETCH_CLASS_SELF ) {
1832- outer_ce = scope ;
1833- } else if (fetch_type == ZEND_FETCH_CLASS_PARENT ) {
1834- if (UNEXPECTED (scope -> parent == NULL )) {
1835- SAVE_OPLINE ();
1836- zend_throw_error (NULL ,
1837- "Cannot use \"parent\" when current class scope has no parent" );
1838- ZVAL_UNDEF (EX_VAR (opline -> result .var ));
1839- HANDLE_EXCEPTION ();
1840- }
1841- outer_ce = scope -> parent ;
1842- } else if (fetch_type == ZEND_FETCH_CLASS_STATIC ) {
1843- if (Z_TYPE (EX (This )) == IS_OBJECT ) {
1844- called_scope = Z_OBJCE (EX (This ));
1845- } else {
1846- called_scope = Z_CE (EX (This ));
1847- }
1848- outer_ce = called_scope ;
1849- } else {
1850- zend_throw_error (NULL , "Unknown scope resolution" );
1851- HANDLE_EXCEPTION ();
1852- }
1853- } else {
1854- outer_ce = Z_CE_P (EX_VAR (opline -> op1 .var ));
1855- }
1856-
1857- inner_class_name = Z_STR_P (RT_CONSTANT (opline , opline -> op2 ));
1858-
1859- if (UNEXPECTED (ZSTR_LEN (outer_ce -> name ) + ZSTR_LEN (inner_class_name ) + 2 > ZSTR_MAX_LEN )) {
1860- zend_error (E_ERROR , "Class name is too long" );
1861- HANDLE_EXCEPTION ();
1862- }
1863-
1864- full_class_name = zend_string_concat3 (
1865- ZSTR_VAL (outer_ce -> name ), ZSTR_LEN (outer_ce -> name ),
1866- ":>" , 2 ,
1867- ZSTR_VAL (inner_class_name ), ZSTR_LEN (inner_class_name )
1868- );
1869-
1870- inner_ce = zend_lookup_class (full_class_name );
1871- if (!inner_ce ) {
1872- zend_error (E_ERROR , "Inner class '%s' not found in outer class %s" , ZSTR_VAL (full_class_name ), ZSTR_VAL (outer_ce -> name ));
1873- HANDLE_EXCEPTION ();
1874- }
1875-
1876- if (inner_ce -> required_scope ) {
1877- if (inner_ce -> required_scope_absolute ) {
1878- // for private classes, we check if the scope we are currently in has access
1879- if (scope != NULL && (inner_ce -> required_scope == scope || scope -> lexical_scope == inner_ce -> required_scope )) {
1880- // we are in the correct scope
1881- } else {
1882- zend_error (E_ERROR , "Cannot access private inner class '%s'" , ZSTR_VAL (full_class_name ));
1883- HANDLE_EXCEPTION ();
1884- }
1885- } else {
1886- // for protected classes, we check if the scope is an instance of the required scope
1887- if (scope != NULL && (instanceof_function (scope , inner_ce -> required_scope ) || instanceof_function (scope -> lexical_scope , inner_ce -> required_scope ))) {
1888- // we are in the correct scope
1889- } else {
1890- zend_error (E_ERROR , "Cannot access protected inner class '%s'" , ZSTR_VAL (full_class_name ));
1891- HANDLE_EXCEPTION ();
1892- }
1893- }
1894- }
1895-
1896- Z_CE_P (EX_VAR (opline -> result .var )) = inner_ce ;
1897-
1898- zend_string_release (full_class_name );
1899-
1900- ZEND_VM_NEXT_OPCODE ();
1901- }
1902-
19031801ZEND_VM_HANDLER (80 , ZEND_FETCH_R , CONST |TMPVAR |CV , UNUSED , VAR_FETCH )
19041802{
19051803 ZEND_VM_DISPATCH_TO_HELPER (zend_fetch_var_address_helper , type , BP_VAR_R );
@@ -8293,7 +8191,6 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
82938191
82948192 case ZEND_FETCH_CLASS :
82958193 case ZEND_DECLARE_ANON_CLASS :
8296- case ZEND_FETCH_INNER_CLASS :
82978194 break ; /* return value is zend_class_entry pointer */
82988195
82998196 default :
0 commit comments