3v4l.org

run code in 500+ PHP versions simultaneously
<?php abstract class Category { public $foo = [1, 2, 3]; public function getCategories($type) { return $this->foo; } } class ChildCategory extends Category { } // This works fine $categories = (new ChildCategory())->getCategories('xxx'); var_dump($categories); // Fatal error: Uncaught Error: Using $this when not in object context $categories = Category::getCategories('xxx'); var_dump($categories);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eMj68
function name:  (null)
number of ops:  17
compiled vars:  !0 = $categories
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   NEW                                                  $1      'ChildCategory'
          1        DO_FCALL                                          0          
          2        INIT_METHOD_CALL                                             $1, 'getCategories'
          3        SEND_VAL_EX                                                  'xxx'
          4        DO_FCALL                                          0  $3      
          5        ASSIGN                                                       !0, $3
   19     6        INIT_FCALL                                                   'var_dump'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                                     
   22     9        INIT_STATIC_METHOD_CALL                                      'Category', 'getCategories'
         10        SEND_VAL                                                     'xxx'
         11        DO_FCALL                                          0  $6      
         12        ASSIGN                                                       !0, $6
   23    13        INIT_FCALL                                                   'var_dump'
         14        SEND_VAR                                                     !0
         15        DO_ICALL                                                     
         16      > RETURN                                                       1

Class Category:
Function getcategories:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eMj68
function name:  getCategories
number of ops:  4
compiled vars:  !0 = $type
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1        FETCH_OBJ_R                                          ~1      'foo'
          2      > RETURN                                                       ~1
   10     3*     > RETURN                                                       null

End of function getcategories

End of class Category.

Class ChildCategory:
Function getcategories:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eMj68
function name:  getCategories
number of ops:  4
compiled vars:  !0 = $type
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1        FETCH_OBJ_R                                          ~1      'foo'
          2      > RETURN                                                       ~1
   10     3*     > RETURN                                                       null

End of function getcategories

End of class ChildCategory.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
148.52 ms | 1429 KiB | 14 Q