3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait OverloadConstructor { public function __construct(... $args) { $length = strlen('initMethod'); foreach (get_class_methods($this) as $method) { if (substr($method, 0, $length) === 'initMethod') { $this->{$method}(... $args); } } } } trait Init1 { protected function initMethodInit1(... $args) { echo 'initMethodInit1' . PHP_EOL; } } trait Init2 { protected function initMethodInit2(... $args) { echo 'initMethodInit2' . PHP_EOL; } } class InitTest { use OverloadConstructor, Init1; protected function initMethodInitTest(... $args) { echo 'initMethodInitTest' . PHP_EOL; } } class ChangeBehaviourOfInitTest extends InitTest { use Init2; protected function initMethodChangeBehaviourOfInitTest(... $args) { echo 'initMethodChangeBehaviourOfInitTest' . PHP_EOL; } } new InitTest(); new ChangeBehaviourOfInitTest();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OTqtL
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   DECLARE_CLASS                                                'inittest'
   35     1        DECLARE_CLASS                                                'changebehaviourofinittest', 'inittest'
   43     2        NEW                                                  $0      'InitTest'
          3        DO_FCALL                                          0          
          4        FREE                                                         $0
   44     5        NEW                                                  $2      'ChangeBehaviourOfInitTest'
          6        DO_FCALL                                          0          
          7        FREE                                                         $2
          8      > RETURN                                                       1

Class OverloadConstructor:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/OTqtL
function name:  __construct
number of ops:  19
compiled vars:  !0 = $args, !1 = $length, !2 = $method
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV_VARIADIC                                        !0      
    5     1        ASSIGN                                                       !1, 10
    6     2        INIT_FCALL                                                   'get_class_methods'
          3        FETCH_THIS                                           ~4      
          4        SEND_VAL                                                     ~4
          5        DO_ICALL                                             $5      
          6      > FE_RESET_R                                           $6      $5, ->17
          7    > > FE_FETCH_R                                                   $6, !2, ->17
    7     8    >   FRAMELESS_ICALL_3                substr              ~7      !2, 0
          9        OP_DATA                                                      !1
         10        IS_IDENTICAL                                                 ~7, 'initMethod'
         11      > JMPZ                                                         ~8, ->16
    8    12    >   INIT_METHOD_CALL                                             !2
         13        SEND_UNPACK                                                  !0
         14        CHECK_UNDEF_ARGS                                             
         15        DO_FCALL                                          1          
    6    16    > > JMP                                                          ->7
         17    >   FE_FREE                                                      $6
   11    18      > RETURN                                                       null

End of function __construct

End of class OverloadConstructor.

Class Init1:
Function initmethodinit1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OTqtL
function name:  initMethodInit1
number of ops:  3
compiled vars:  !0 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV_VARIADIC                                        !0      
   17     1        ECHO                                                         'initMethodInit1%0A'
   18     2      > RETURN                                                       null

End of function initmethodinit1

End of class Init1.

Class Init2:
Function initmethodinit2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OTqtL
function name:  initMethodInit2
number of ops:  3
compiled vars:  !0 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV_VARIADIC                                        !0      
   23     1        ECHO                                                         'initMethodInit2%0A'
   24     2      > RETURN                                                       null

End of function initmethodinit2

End of class Init2.

Class InitTest:
Function initmethodinittest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OTqtL
function name:  initMethodInitTest
number of ops:  3
compiled vars:  !0 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV_VARIADIC                                        !0      
   31     1        ECHO                                                         'initMethodInitTest%0A'
   32     2      > RETURN                                                       null

End of function initmethodinittest

End of class InitTest.

Class ChangeBehaviourOfInitTest:
Function initmethodchangebehaviourofinittest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OTqtL
function name:  initMethodChangeBehaviourOfInitTest
number of ops:  3
compiled vars:  !0 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   38     0  E >   RECV_VARIADIC                                        !0      
   39     1        ECHO                                                         'initMethodChangeBehaviourOfInitTest%0A'
   40     2      > RETURN                                                       null

End of function initmethodchangebehaviourofinittest

End of class ChangeBehaviourOfInitTest.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.93 ms | 2082 KiB | 14 Q