3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Test { private static $data = []; public static function Set($key, $value) { static::$data[$key] = $value; } public static function Get($key) { return static::$data[$key]; } } class TestTrait { use Test; public function __construct(){} public function setArrayValues(array $array) { foreach ($array as $key => $value) { Test::Set($key, $value); } } public function getArrayValueFromKey(array $array) { foreach ($array as $key => $value) { var_dump(Test::Get($key)); } } } $songs = [ 'Burial' => 'God is an Astronaut', 'Hazard' => 'Long Distance Calling', 'An Infinite Regression' => 'Animals as Leaders', ]; $testTrait = new TestTrait(); $testTrait->setArrayValues($songs); $testTrait->getArrayValueFromKey($songs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/86J6R
function name:  (null)
number of ops:  12
compiled vars:  !0 = $songs, !1 = $testTrait
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                            'testtrait'
   35     1        ASSIGN                                                   !0, <array>
   41     2        NEW                                              $3      'TestTrait'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   43     5        INIT_METHOD_CALL                                         !1, 'setArrayValues'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   45     8        INIT_METHOD_CALL                                         !1, 'getArrayValueFromKey'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Class Test:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/86J6R
function name:  Set
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        FETCH_STATIC_PROP_W          global              $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
    8     5      > RETURN                                                   null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/86J6R
function name:  Get
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        FETCH_STATIC_PROP_R          unknown             ~1      'data'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   11     4*     > RETURN                                                   null

End of function get

End of class Test.

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

End of function __construct

Function setarrayvalues:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/86J6R
function name:  setArrayValues
number of ops:  11
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1      > FE_RESET_R                                       $3      !0, ->9
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->9
          3    >   ASSIGN                                                   !2, ~4
   23     4        INIT_STATIC_METHOD_CALL                                  'Test', 'Set'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0          
   22     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $3
   25    10      > RETURN                                                   null

End of function setarrayvalues

Function getarrayvaluefromkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/86J6R
function name:  getArrayValueFromKey
number of ops:  13
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1      > FE_RESET_R                                       $3      !0, ->11
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->11
          3    >   ASSIGN                                                   !2, ~4
   30     4        INIT_FCALL                                               'var_dump'
          5        INIT_STATIC_METHOD_CALL                                  'Test', 'Get'
          6        SEND_VAR                                                 !2
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   29    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $3
   32    12      > RETURN                                                   null

End of function getarrayvaluefromkey

End of class TestTrait.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.37 ms | 1405 KiB | 15 Q