3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class SuperAbstract { static function create() { return new static(); } } class Extended extends SuperAbstract { private $hello = ''; protected function __construct() { $this->hello = "world"; } public function hello() { return "hello " . $this->hello; } } // works $a = Extended::create(); echo $a->hello(); echo "\n\nNow we'll fail, trying to call 'new' directly:\n"; // can't touch this $b = new Extended();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LliKj
function name:  (null)
number of ops:  11
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_STATIC_METHOD_CALL                                  'Extended', 'create'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   25     3        INIT_METHOD_CALL                                         !0, 'hello'
          4        DO_FCALL                                      0  $4      
          5        ECHO                                                     $4
   28     6        ECHO                                                     '%0A%0ANow+we%27ll+fail%2C+trying+to+call+%27new%27+directly%3A%0A'
   30     7        NEW                                              $5      'Extended'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $5
         10      > RETURN                                                   1

Class SuperAbstract:
Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LliKj
function name:  create
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   NEW                          static              $0      
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
    7     3*     > RETURN                                                   null

End of function create

End of class SuperAbstract.

Class Extended:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LliKj
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN_OBJ                                               'hello'
          1        OP_DATA                                                  'world'
   16     2      > RETURN                                                   null

End of function __construct

Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LliKj
function name:  hello
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'hello'
          1        CONCAT                                           ~1      'hello+', ~0
          2      > RETURN                                                   ~1
   20     3*     > RETURN                                                   null

End of function hello

Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LliKj
function name:  create
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   NEW                          static              $0      
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
    7     3*     > RETURN                                                   null

End of function create

End of class Extended.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.53 ms | 1012 KiB | 13 Q