3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected static ?Foo $instance = null; public static function __callStatic($method, $args) { $instance = self::$instance ?? self::$instance = new static(); return $instance->__call($method, $args); } public function __call($method, $args) { if (method_exists($this, $method)) { return $instance->$method(...$args); } return $this; } protected function bar() { echo __METHOD__ . '<br />'; return $this; } protected function baz() { echo __METHOD__ . '<br />'; return $this; } } Foo::bar()->baz(); (new Foo())->bar()->baz();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/moH0s
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_STATIC_METHOD_CALL                                  'Foo', 'bar'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'baz'
          3        DO_FCALL                                      0          
   38     4        NEW                                              $2      'Foo'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $2, 'bar'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'baz'
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Class Foo:
Function __callstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/moH0s
function name:  __callStatic
number of ops:  16
compiled vars:  !0 = $method, !1 = $args, !2 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        FETCH_STATIC_PROP_IS                             ~3      'instance'
          3        COALESCE                                         ~4      ~3
          4        NEW                          static              $6      
          5        DO_FCALL                                      0          
          6        ASSIGN_STATIC_PROP                               ~5      'instance'
          7        OP_DATA                                                  $6
          8        QM_ASSIGN                                        ~4      ~5
          9        ASSIGN                                                   !2, ~4
   10    10        INIT_METHOD_CALL                                         !2, '__call'
         11        SEND_VAR_EX                                              !0
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $9      
         14      > RETURN                                                   $9
   11    15*     > RETURN                                                   null

End of function __callstatic

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/moH0s
function name:  __call
number of ops:  16
compiled vars:  !0 = $method, !1 = $args, !2 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'method_exists'
          3        FETCH_THIS                                       ~3      
          4        SEND_VAL                                                 ~3
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7      > JMPZ                                                     $4, ->13
   16     8    >   INIT_METHOD_CALL                                         !2, !0
          9        SEND_UNPACK                                              !1
         10        CHECK_UNDEF_ARGS                                         
         11        DO_FCALL                                      1  $5      
         12      > RETURN                                                   $5
   19    13    >   FETCH_THIS                                       ~6      
         14      > RETURN                                                   ~6
   20    15*     > RETURN                                                   null

End of function __call

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/moH0s
function name:  bar
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ECHO                                                     'Foo%3A%3Abar%3Cbr+%2F%3E'
   26     1        FETCH_THIS                                       ~0      
          2      > RETURN                                                   ~0
   27     3*     > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/moH0s
function name:  baz
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                     'Foo%3A%3Abaz%3Cbr+%2F%3E'
   33     1        FETCH_THIS                                       ~0      
          2      > RETURN                                                   ~0
   34     3*     > RETURN                                                   null

End of function baz

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.59 ms | 1002 KiB | 14 Q