3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Stuff { public static function countObjTypes( array $data, array $types ) { $return['Other'] = 0; foreach ( $types as $type ) $return[$type] = 0; foreach ( ( array ) $data as $obj ) { $set = false; array_walk( $types, function( $type ) use ( $obj, &$return, &$set ) { if ( is_a( $obj, $type ) ) { $return[$type]++; $set = true; } } ); if ( !$set ) $return['Other']++; } return $return; } public static function getArrayValueByPath($array, $path) { $path = (array) array_filter( $path ); if( !empty( $path ) ) { foreach ( $path as $key ) if( !isset( $array[$key] ) ) return NULL; $array = $array[$key]; return $array; } else { return false; } } } $data = array( 0 => 'abc', 1 => '123'); $iteration = 0; $path = array( $iteration ); var_dump( Stuff::getArrayValueByPath( $data, $path ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gqpWW
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $iteration, !2 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ASSIGN                                                   !0, <array>
   41     1        ASSIGN                                                   !1, 0
   42     2        INIT_ARRAY                                       ~5      !1
          3        ASSIGN                                                   !2, ~5
   43     4        INIT_FCALL                                               'var_dump'
          5        INIT_STATIC_METHOD_CALL                                  'Stuff', 'getArrayValueByPath'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FgqpWW%3A13%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/gqpWW
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $type, !1 = $obj, !2 = $return, !3 = $set
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   15     4        INIT_FCALL                                               'is_a'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8      > JMPZ                                                     $4, ->12
   16     9    >   FETCH_DIM_RW                                     $5      !2, !0
         10        PRE_INC                                                  $5
   17    11        ASSIGN                                                   !3, <true>
   19    12    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgqpWW%3A13%240

Class Stuff:
Function countobjtypes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 26
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 9
filename:       /in/gqpWW
function name:  countObjTypes
number of ops:  30
compiled vars:  !0 = $data, !1 = $types, !2 = $return, !3 = $type, !4 = $obj, !5 = $set
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ASSIGN_DIM                                               !2, 'Other'
          3        OP_DATA                                                  0
    8     4      > FE_RESET_R                                       $7      !1, ->9
          5    > > FE_FETCH_R                                               $7, !3, ->9
    9     6    >   ASSIGN_DIM                                               !2, !3
          7        OP_DATA                                                  0
    8     8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $7
   11    10        CAST                                          7  ~9      !0
         11      > FE_RESET_R                                       $10     ~9, ->27
         12    > > FE_FETCH_R                                               $10, !4, ->27
   12    13    >   ASSIGN                                                   !5, <false>
   13    14        INIT_FCALL                                               'array_walk'
         15        SEND_REF                                                 !1
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgqpWW%3A13%240'
         17        BIND_LEXICAL                                             ~12, !4
         18        BIND_LEXICAL                                             ~12, !2
         19        BIND_LEXICAL                                             ~12, !5
   19    20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
   21    22        BOOL_NOT                                         ~14     !5
         23      > JMPZ                                                     ~14, ->26
   22    24    >   FETCH_DIM_RW                                     $15     !2, 'Other'
         25        PRE_INC                                                  $15
   11    26    > > JMP                                                      ->12
         27    >   FE_FREE                                                  $10
   25    28      > RETURN                                                   !2
   26    29*     > RETURN                                                   null

End of function countobjtypes

Function getarrayvaluebypath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gqpWW
function name:  getArrayValueByPath
number of ops:  25
compiled vars:  !0 = $array, !1 = $path, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   29     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $3      
          5        CAST                                          7  ~4      $3
          6        ASSIGN                                                   !1, ~4
   31     7        ISSET_ISEMPTY_CV                                 ~6      !1
          8        BOOL_NOT                                         ~7      ~6
          9      > JMPZ                                                     ~7, ->23
   32    10    > > FE_RESET_R                                       $8      !1, ->18
         11    > > FE_FETCH_R                                               $8, !2, ->18
         12    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !0, !2
         13        BOOL_NOT                                         ~10     ~9
         14      > JMPZ                                                     ~10, ->17
         15    >   FE_FREE                                                  $8
         16      > RETURN                                                   null
         17    > > JMP                                                      ->11
         18    >   FE_FREE                                                  $8
         19        FETCH_DIM_R                                      ~11     !0, !2
         20        ASSIGN                                                   !0, ~11
   33    21      > RETURN                                                   !0
         22*       JMP                                                      ->24
   35    23    > > RETURN                                                   <false>
   37    24*     > RETURN                                                   null

End of function getarrayvaluebypath

End of class Stuff.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.18 ms | 1404 KiB | 21 Q