3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; private $baz; protected function getBar() { return __METHOD__; } private function getBaz() { return __METHOD__; } public function __call($methodName, $args) { if (!method_exists($this, $methodName)) { return 'some wise behavior'; } return 'Magic! '.$this->$methodName(...$args); } } $foo = new Foo(); var_dump(method_exists($foo, '__call')); var_dump(method_exists($foo, 'bar')); var_dump(method_exists($foo, 'baz')); var_dump($foo->__call('baz', [])); var_dump($foo->baz()); var_dump($foo->__call('nonexistent', []));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bqn9Z
function name:  (null)
number of ops:  44
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'method_exists'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 '__call'
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   30    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'method_exists'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 'bar'
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
   31    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'method_exists'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 'baz'
         21        DO_ICALL                                         $8      
         22        SEND_VAR                                                 $8
         23        DO_ICALL                                                 
   32    24        INIT_FCALL                                               'var_dump'
         25        INIT_METHOD_CALL                                         !0, '__call'
         26        SEND_VAL_EX                                              'baz'
         27        SEND_VAL_EX                                              <array>
         28        DO_FCALL                                      0  $10     
         29        SEND_VAR                                                 $10
         30        DO_ICALL                                                 
   33    31        INIT_FCALL                                               'var_dump'
         32        INIT_METHOD_CALL                                         !0, 'baz'
         33        DO_FCALL                                      0  $12     
         34        SEND_VAR                                                 $12
         35        DO_ICALL                                                 
   34    36        INIT_FCALL                                               'var_dump'
         37        INIT_METHOD_CALL                                         !0, '__call'
         38        SEND_VAL_EX                                              'nonexistent'
         39        SEND_VAL_EX                                              <array>
         40        DO_FCALL                                      0  $14     
         41        SEND_VAR                                                 $14
         42        DO_ICALL                                                 
         43      > RETURN                                                   1

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bqn9Z
function name:  getBar
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                   'Foo%3A%3AgetBar'
   11     1*     > RETURN                                                   null

End of function getbar

Function getbaz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bqn9Z
function name:  getBaz
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E > > RETURN                                                   'Foo%3A%3AgetBaz'
   16     1*     > RETURN                                                   null

End of function getbaz

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

End of function __call

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137 ms | 1006 KiB | 15 Q