3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Animal{ private $name; public function __construct($name){ $this->name = $name; } public function say($say_func=null){ $say_func = is_callable($say_func)? $say_func: function(){ var_dump('default',$this); }; $say_func(); } } $b = function(){ var_dump('custom',$this); }; $a = new Animal('bob'); $a->say(); $a->say($b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hhv1t
function name:  (null)
number of ops:  12
compiled vars:  !0 = $b, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fhhv1t%3A19%241'
          1        ASSIGN                                                   !0, ~2
   23     2        NEW                                              $4      'Animal'
          3        SEND_VAL_EX                                              'bob'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $4
   24     6        INIT_METHOD_CALL                                         !1, 'say'
          7        DO_FCALL                                      0          
   25     8        INIT_METHOD_CALL                                         !1, 'say'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fhhv1t%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hhv1t
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'default'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
   14     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fhhv1t%3A12%240

Function %00%7Bclosure%7D%2Fin%2Fhhv1t%3A19%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hhv1t
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'custom'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
   21     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fhhv1t%3A19%241

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

End of function __construct

Function say:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hhv1t
function name:  say
number of ops:  13
compiled vars:  !0 = $say_func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      null
   12     1        INIT_FCALL                                               'is_callable'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->7
          5    >   QM_ASSIGN                                        ~2      !0
          6      > JMP                                                      ->9
          7    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fhhv1t%3A12%240'
   14     8        QM_ASSIGN                                        ~2      ~3
   12     9    >   ASSIGN                                                   !0, ~2
   15    10        INIT_DYNAMIC_CALL                                        !0
         11        DO_FCALL                                      0          
   16    12      > RETURN                                                   null

End of function say

End of class Animal.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.73 ms | 1400 KiB | 17 Q