3v4l.org

run code in 300+ PHP versions simultaneously
<?php class salutations { public function hello() { return "Hello World!"; } } class methodFactory { public function __construct($instance) { $this->package = $instance; } public function getPackageMethod($method) { if (method_exists($this->package, $method)) { return $this->package->$method; } } } $salutationsInstance = new salutations(); $obj = new methodFactory($salutationsInstance); $hello = $obj->getPackageMethod('hello'); $hello();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NdjRF
function name:  (null)
number of ops:  14
compiled vars:  !0 = $salutationsInstance, !1 = $obj, !2 = $hello
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $3      'salutations'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   23     3        NEW                                              $6      'methodFactory'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   24     7        INIT_METHOD_CALL                                         !1, 'getPackageMethod'
          8        SEND_VAL_EX                                              'hello'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !2, $9
   25    11        INIT_DYNAMIC_CALL                                        !2
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

Class salutations:
Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NdjRF
function name:  hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   'Hello+World%21'
    6     1*     > RETURN                                                   null

End of function hello

End of class salutations.

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

End of function __construct

Function getpackagemethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NdjRF
function name:  getPackageMethod
number of ops:  11
compiled vars:  !0 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'method_exists'
          2        FETCH_OBJ_R                                      ~1      'package'
          3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > JMPZ                                                     $2, ->10
   16     7    >   FETCH_OBJ_R                                      ~3      'package'
          8        FETCH_OBJ_R                                      ~4      ~3, !0
          9      > RETURN                                                   ~4
   18    10    > > RETURN                                                   null

End of function getpackagemethod

End of class methodFactory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.66 ms | 1400 KiB | 15 Q