3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; public function __construct(int $a) { $this->a = $a; } public function __invoke(int $a) : Bar { return new Bar($a); } } class Bar { private $a; public function __construct(int $a) { $this->a = $a; } } $foo = new Foo(1); $bar = new $foo(2); $bar2 = new ($foo(2)); var_dump($foo); var_dump($bar); var_dump($bar2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wh8nD
function name:  (null)
number of ops:  26
compiled vars:  !0 = $foo, !1 = $bar, !2 = $bar2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $3      'Foo'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   34     4        FETCH_CLASS                                   0  $6      !0
          5        NEW                                              $7      $6
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   35     9        INIT_DYNAMIC_CALL                                        !0
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0  $10     
         12        FETCH_CLASS                                   0  $11     $10
         13        NEW                                              $12     $11
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !2, $12
   36    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
   37    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
   38    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wh8nD
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
   11     3      > RETURN                                                   null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wh8nD
function name:  __invoke
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        NEW                                              $1      'Bar'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   16     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function __invoke

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wh8nD
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
   28     3      > RETURN                                                   null

End of function __construct

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.61 ms | 1400 KiB | 15 Q