3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { /** * A test function * * First parameter must be an object of type OtherClass */ public function test(OtherClass $otherclass) { echo $otherclass->var; } /** * Another test function * * First parameter must be an array */ public function test_array(array $input_array) { print_r($input_array); } /** * First parameter must be iterator */ public function test_interface(Traversable $iterator) { echo get_class($iterator); } /** * First parameter must be callable */ public function test_callable(callable $callback, $data) { call_user_func($callback, $data); } } // Another example class class OtherClass { public $var = 'Hello World'; } $myclass = new MyClass; $otherclass = new OtherClass; $myclass->test($otherclass); // Works: Prints the array $myclass->test_array(array('a', 'b', 'c')); // Works: Prints ArrayObject $myclass->test_interface(new ArrayObject(array())); // Works: Prints int(1) $myclass->test_callable('var_dump', 1); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HvvbM
function name:  (null)
number of ops:  23
compiled vars:  !0 = $myclass, !1 = $otherclass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   NEW                                              $2      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   45     3        NEW                                              $5      'OtherClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   48     6        INIT_METHOD_CALL                                         !0, 'test'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
   52     9        INIT_METHOD_CALL                                         !0, 'test_array'
         10        SEND_VAL_EX                                              <array>
         11        DO_FCALL                                      0          
   55    12        INIT_METHOD_CALL                                         !0, 'test_interface'
         13        NEW                                              $10     'ArrayObject'
         14        SEND_VAL_EX                                              <array>
         15        DO_FCALL                                      0          
         16        SEND_VAR_NO_REF_EX                                       $10
         17        DO_FCALL                                      0          
   58    18        INIT_METHOD_CALL                                         !0, 'test_callable'
         19        SEND_VAL_EX                                              'var_dump'
         20        SEND_VAL_EX                                              1
         21        DO_FCALL                                      0          
   59    22      > RETURN                                                   1

Class MyClass:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HvvbM
function name:  test
number of ops:  4
compiled vars:  !0 = $otherclass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        FETCH_OBJ_R                                      ~1      !0, 'var'
          2        ECHO                                                     ~1
   13     3      > RETURN                                                   null

End of function test

Function test_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HvvbM
function name:  test_array
number of ops:  5
compiled vars:  !0 = $input_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   23     4      > RETURN                                                   null

End of function test_array

Function test_interface:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HvvbM
function name:  test_interface
number of ops:  4
compiled vars:  !0 = $iterator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        GET_CLASS                                        ~1      !0
          2        ECHO                                                     ~1
   30     3      > RETURN                                                   null

End of function test_interface

Function test_callable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HvvbM
function name:  test_callable
number of ops:  6
compiled vars:  !0 = $callback, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        INIT_USER_CALL                                1          'call_user_func', !0
          3        SEND_USER                                                !1
          4        DO_FCALL                                      0          
   37     5      > RETURN                                                   null

End of function test_callable

End of class MyClass.

Class OtherClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.19 ms | 1400 KiB | 15 Q