3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public final function bar() { } public function baz() { } } class MethodsBuilder { // just a mock of the class generator public $methods; public function addMethodFromGenerator($method) { $this->methods[] = $method; } } class BuilderUtils { public static function addToGeneratorIfNotFinal(MethodsBuilder $builder, $method, ReflectionClass $originalClass) { if ($originalClass->hasMethod($method)) { $reflMethod = $originalClass->getMethod($method); if ($reflMethod->isFinal()) { return; } } $builder->addMethodFromGenerator($method); } } $methodsBuilder = new MethodsBuilder(); $reflection = new ReflectionClass('Foo'); BuilderUtils::addToGeneratorIfNotFinal($methodsBuilder, 'bar', $reflection); BuilderUtils::addToGeneratorIfNotFinal($methodsBuilder, 'baz', $reflection); var_dump($methodsBuilder);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uubdE
function name:  (null)
number of ops:  21
compiled vars:  !0 = $methodsBuilder, !1 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $2      'MethodsBuilder'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   39     3        NEW                                              $5      'ReflectionClass'
          4        SEND_VAL_EX                                              'Foo'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   42     7        INIT_STATIC_METHOD_CALL                                  'BuilderUtils', 'addToGeneratorIfNotFinal'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 'bar'
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0          
   43    12        INIT_STATIC_METHOD_CALL                                  'BuilderUtils', 'addToGeneratorIfNotFinal'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 'baz'
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0          
   45    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uubdE
function name:  bar
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uubdE
function name:  baz
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   null

End of function baz

End of class Foo.

Class MethodsBuilder:
Function addmethodfromgenerator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uubdE
function name:  addMethodFromGenerator
number of ops:  5
compiled vars:  !0 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        FETCH_OBJ_W                                      $1      'methods'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   16     4      > RETURN                                                   null

End of function addmethodfromgenerator

End of class MethodsBuilder.

Class BuilderUtils:
Function addtogeneratorifnotfinal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/uubdE
function name:  addToGeneratorIfNotFinal
number of ops:  19
compiled vars:  !0 = $builder, !1 = $method, !2 = $originalClass, !3 = $reflMethod
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   23     3        INIT_METHOD_CALL                                         !2, 'hasMethod'
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $4      
          6      > JMPZ                                                     $4, ->15
   24     7    >   INIT_METHOD_CALL                                         !2, 'getMethod'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $5      
         10        ASSIGN                                                   !3, $5
   26    11        INIT_METHOD_CALL                                         !3, 'isFinal'
         12        DO_FCALL                                      0  $7      
         13      > JMPZ                                                     $7, ->15
         14    > > RETURN                                                   null
   29    15    >   INIT_METHOD_CALL                                         !0, 'addMethodFromGenerator'
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   30    18      > RETURN                                                   null

End of function addtogeneratorifnotfinal

End of class BuilderUtils.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159 ms | 1392 KiB | 15 Q