3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GrandPa { protected $elements = array( 'a' => 1, 'b' => 2, ); public function mergeElements($childElements = null) { $elements = $this->elements; $parentClassName = get_parent_class($this); if($parentClassName){ $parentClass = new $parentClassName(); if($childElements){ $elements = array_merge($elements, $childElements); } return $parentClass->mergeElements($elements); } else { return array_merge($elements, $childElements); } } } class Father extends GrandPa { protected $elements = array( 'c' => 3, ); } class Me extends Father{ protected $elements = array( 'd' => 4, ); } $stime=microtime(true); for ($i=1;$i<=100000;$i++){ $me = new Me(); $me->mergeElements(); } $etime=microtime(true); echo $etime-$stime;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
Branch analysis from position: 6
filename:       /in/Fhrdv
function name:  (null)
number of ops:  21
compiled vars:  !0 = $stime, !1 = $i, !2 = $me, !3 = $etime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
   42     4        ASSIGN                                                   !1, 1
          5      > JMP                                                      ->12
   43     6    >   NEW                                              $7      'Me'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $7
   44     9        INIT_METHOD_CALL                                         !2, 'mergeElements'
         10        DO_FCALL                                      0          
   42    11        PRE_INC                                                  !1
         12    >   IS_SMALLER_OR_EQUAL                                      !1, 100000
         13      > JMPNZ                                                    ~12, ->6
   46    14    >   INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !3, $13
   47    18        SUB                                              ~15     !3, !0
         19        ECHO                                                     ~15
         20      > RETURN                                                   1

Class GrandPa:
Function mergeelements:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fhrdv
function name:  mergeElements
number of ops:  30
compiled vars:  !0 = $childElements, !1 = $elements, !2 = $parentClassName, !3 = $parentClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV_INIT                                        !0      null
   12     1        FETCH_OBJ_R                                      ~4      'elements'
          2        ASSIGN                                                   !1, ~4
   13     3        INIT_FCALL                                               'get_parent_class'
          4        FETCH_THIS                                       ~6      
          5        SEND_VAL                                                 ~6
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   15     8      > JMPZ                                                     !2, ->24
   16     9    >   FETCH_CLASS                                   0  $9      !2
         10        NEW                                              $10     $9
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $10
   17    13      > JMPZ                                                     !0, ->19
   18    14    >   INIT_FCALL                                               'array_merge'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !1, $13
   20    19    >   INIT_METHOD_CALL                                         !3, 'mergeElements'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $15     
         22      > RETURN                                                   $15
         23*       JMP                                                      ->29
   22    24    >   INIT_FCALL                                               'array_merge'
         25        SEND_VAR                                                 !1
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $16     
         28      > RETURN                                                   $16
   24    29*     > RETURN                                                   null

End of function mergeelements

End of class GrandPa.

Class Father:
Function mergeelements:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fhrdv
function name:  mergeElements
number of ops:  30
compiled vars:  !0 = $childElements, !1 = $elements, !2 = $parentClassName, !3 = $parentClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV_INIT                                        !0      null
   12     1        FETCH_OBJ_R                                      ~4      'elements'
          2        ASSIGN                                                   !1, ~4
   13     3        INIT_FCALL                                               'get_parent_class'
          4        FETCH_THIS                                       ~6      
          5        SEND_VAL                                                 ~6
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   15     8      > JMPZ                                                     !2, ->24
   16     9    >   FETCH_CLASS                                   0  $9      !2
         10        NEW                                              $10     $9
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $10
   17    13      > JMPZ                                                     !0, ->19
   18    14    >   INIT_FCALL                                               'array_merge'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !1, $13
   20    19    >   INIT_METHOD_CALL                                         !3, 'mergeElements'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $15     
         22      > RETURN                                                   $15
         23*       JMP                                                      ->29
   22    24    >   INIT_FCALL                                               'array_merge'
         25        SEND_VAR                                                 !1
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $16     
         28      > RETURN                                                   $16
   24    29*     > RETURN                                                   null

End of function mergeelements

End of class Father.

Class Me:
Function mergeelements:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fhrdv
function name:  mergeElements
number of ops:  30
compiled vars:  !0 = $childElements, !1 = $elements, !2 = $parentClassName, !3 = $parentClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV_INIT                                        !0      null
   12     1        FETCH_OBJ_R                                      ~4      'elements'
          2        ASSIGN                                                   !1, ~4
   13     3        INIT_FCALL                                               'get_parent_class'
          4        FETCH_THIS                                       ~6      
          5        SEND_VAL                                                 ~6
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   15     8      > JMPZ                                                     !2, ->24
   16     9    >   FETCH_CLASS                                   0  $9      !2
         10        NEW                                              $10     $9
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $10
   17    13      > JMPZ                                                     !0, ->19
   18    14    >   INIT_FCALL                                               'array_merge'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !1, $13
   20    19    >   INIT_METHOD_CALL                                         !3, 'mergeElements'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $15     
         22      > RETURN                                                   $15
         23*       JMP                                                      ->29
   22    24    >   INIT_FCALL                                               'array_merge'
         25        SEND_VAR                                                 !1
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $16     
         28      > RETURN                                                   $16
   24    29*     > RETURN                                                   null

End of function mergeelements

End of class Me.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.75 ms | 1408 KiB | 19 Q