3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function someMethod() { return "Foo::someMethod ".get_class($this); } } class Bar { public function someMethod() { return "Bar::someMethod ".get_class($this); } } $foo = new Foo(); $bar = new Bar(); $reflClass = new ReflectionClass('Foo'); $reflMethod = $reflClass->getMethod('someMethod'); $fooClosure = $reflMethod->getClosure($foo); $barClosure = $fooClosure->bindTo($bar); echo $fooClosure()."\n"; echo $barClosure()."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UYmaI
function name:  (null)
number of ops:  31
compiled vars:  !0 = $foo, !1 = $bar, !2 = $reflClass, !3 = $reflMethod, !4 = $fooClosure, !5 = $barClosure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $6      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   18     3        NEW                                              $9      'Bar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $9
   20     6        NEW                                              $12     'ReflectionClass'
          7        SEND_VAL_EX                                              'Foo'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $12
   21    10        INIT_METHOD_CALL                                         !2, 'getMethod'
         11        SEND_VAL_EX                                              'someMethod'
         12        DO_FCALL                                      0  $15     
         13        ASSIGN                                                   !3, $15
   22    14        INIT_METHOD_CALL                                         !3, 'getClosure'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $17     
         17        ASSIGN                                                   !4, $17
   23    18        INIT_METHOD_CALL                                         !4, 'bindTo'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0  $19     
         21        ASSIGN                                                   !5, $19
   25    22        INIT_DYNAMIC_CALL                                        !4
         23        DO_FCALL                                      0  $21     
         24        CONCAT                                           ~22     $21, '%0A'
         25        ECHO                                                     ~22
   26    26        INIT_DYNAMIC_CALL                                        !5
         27        DO_FCALL                                      0  $23     
         28        CONCAT                                           ~24     $23, '%0A'
         29        ECHO                                                     ~24
         30      > RETURN                                                   1

Class Foo:
Function somemethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UYmaI
function name:  someMethod
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'Foo%3A%3AsomeMethod+', ~1
          3      > RETURN                                                   ~2
    8     4*     > RETURN                                                   null

End of function somemethod

End of class Foo.

Class Bar:
Function somemethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UYmaI
function name:  someMethod
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'Bar%3A%3AsomeMethod+', ~1
          3      > RETURN                                                   ~2
   14     4*     > RETURN                                                   null

End of function somemethod

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.41 ms | 1399 KiB | 13 Q