3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectNameGenerator { public function __invoke($object) { return $object->id; } } class b extends a { public function __construct() { parent::setCallableGenerator(new ObjectNameGenerator()); } } class a { private $callableGenerator = null; public function setCallableGenerator(callable $func) { $this->callableGenerator = $func; } public function build() { $object = new StdObj(); $object->id = 99; if($this->callableGenerator !== null) { return call_user_func($this->callableGenerator, $object); } else { return 'no callable function'; } } } $b = new b(); $b->build();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/79O8n
function name:  (null)
number of ops:  7
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'b', 'a'
   41     1        NEW                                              $1      'b'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   42     4        INIT_METHOD_CALL                                         !0, 'build'
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Class ObjectNameGenerator:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/79O8n
function name:  __invoke
number of ops:  4
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        FETCH_OBJ_R                                      ~1      !0, 'id'
          2      > RETURN                                                   ~1
    8     3*     > RETURN                                                   null

End of function __invoke

End of class ObjectNameGenerator.

Class b:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/79O8n
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'setCallableGenerator'
          1        NEW                                              $0      'ObjectNameGenerator'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $0
          4        DO_FCALL                                      0          
   16     5      > RETURN                                                   null

End of function __construct

End of class b.

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

End of function setcallablegenerator

Function build:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/79O8n
function name:  build
number of ops:  16
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $1      'StdObj'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   31     3        ASSIGN_OBJ                                               !0, 'id'
          4        OP_DATA                                                  99
   33     5        FETCH_OBJ_R                                      ~5      'callableGenerator'
          6        TYPE_CHECK                                  1020          ~5
          7      > JMPZ                                                     ~6, ->14
   34     8    >   FETCH_OBJ_R                                      ~7      'callableGenerator'
          9        INIT_USER_CALL                                1          'call_user_func', ~7
         10        SEND_USER                                                !0
         11        DO_FCALL                                      0  $8      
         12      > RETURN                                                   $8
         13*       JMP                                                      ->15
   36    14    > > RETURN                                                   'no+callable+function'
   38    15*     > RETURN                                                   null

End of function build

End of class a.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.82 ms | 1403 KiB | 14 Q