3v4l.org

run code in 300+ 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 = 20
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/OTqtL
function name:  __construct
number of ops:  22
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, ->20
          7    > > FE_FETCH_R                                               $6, !2, ->20
    7     8    >   INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 0
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $7      
         13        IS_IDENTICAL                                             $7, 'initMethod'
         14      > JMPZ                                                     ~8, ->19
    8    15    >   INIT_METHOD_CALL                                         !2
         16        SEND_UNPACK                                              !0
         17        CHECK_UNDEF_ARGS                                         
         18        DO_FCALL                                      1          
    6    19    > > JMP                                                      ->7
         20    >   FE_FREE                                                  $6
   11    21      > 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.0.0


preferences:
144.08 ms | 1400 KiB | 17 Q