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 $a) { echo $a->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; $foo = new OtherClass; $myclass->test($foo); // 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/TsvsA
function name:  (null)
number of ops:  26
compiled vars:  !0 = $myclass, !1 = $otherclass, !2 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   NEW                                              $3      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   45     3        NEW                                              $6      'OtherClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   46     6        NEW                                              $9      'OtherClass'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $9
   49     9        INIT_METHOD_CALL                                         !0, 'test'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0          
   53    12        INIT_METHOD_CALL                                         !0, 'test_array'
         13        SEND_VAL_EX                                              <array>
         14        DO_FCALL                                      0          
   56    15        INIT_METHOD_CALL                                         !0, 'test_interface'
         16        NEW                                              $14     'ArrayObject'
         17        SEND_VAL_EX                                              <array>
         18        DO_FCALL                                      0          
         19        SEND_VAR_NO_REF_EX                                       $14
         20        DO_FCALL                                      0          
   59    21        INIT_METHOD_CALL                                         !0, 'test_callable'
         22        SEND_VAL_EX                                              'var_dump'
         23        SEND_VAL_EX                                              1
         24        DO_FCALL                                      0          
   60    25      > RETURN                                                   1

Class MyClass:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TsvsA
function name:  test
number of ops:  4
compiled vars:  !0 = $a
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/TsvsA
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/TsvsA
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/TsvsA
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:
152.36 ms | 1400 KiB | 15 Q