3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['type' => 'foo'], ]; function hasDependencyTypeLoop(array $dependencies, string $type): bool { foreach ($dependencies as ['type' => $currentType]) { if ($currentType === $type) { return true; } } return false; } function hasDependencyTypeArrayAny(array $dependencies, string $type): bool { return array_any($dependencies, fn() => $currentType === $type); } var_dump(hasDependencyTypeLoop($data, 'foo')); var_dump(hasDependencyTypeArrayAny($data, 'foo'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a7int
function name:  (null)
number of ops:  16
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'hasdependencytypeloop'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'foo'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   22     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'hasdependencytypearrayany'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 'foo'
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function hasdependencytypeloop:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/a7int
function name:  hasDependencyTypeLoop
number of ops:  16
compiled vars:  !0 = $dependencies, !1 = $type, !2 = $currentType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2      > FE_RESET_R                                       $3      !0, ->12
          3    > > FE_FETCH_R                                               $3, $4, ->12
          4    >   FETCH_LIST_R                                     $5      $4, 'type'
          5        ASSIGN                                                   !2, $5
          6        FREE                                                     $4
    9     7        IS_IDENTICAL                                             !2, !1
          8      > JMPZ                                                     ~7, ->11
   10     9    >   FE_FREE                                                  $3
         10      > RETURN                                                   <true>
    8    11    > > JMP                                                      ->3
         12    >   FE_FREE                                                  $3
   14    13      > RETURN                                                   <false>
   15    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function hasdependencytypeloop

Function hasdependencytypearrayany:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a7int
function name:  hasDependencyTypeArrayAny
number of ops:  13
compiled vars:  !0 = $dependencies, !1 = $type, !2 = $currentType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        INIT_FCALL_BY_NAME                                       'array_any'
          3        SEND_VAR_EX                                              !0
          4        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          5        BIND_LEXICAL                                             ~3, !2
          6        BIND_LEXICAL                                             ~3, !1
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0  $4      
          9        VERIFY_RETURN_TYPE                                       $4
         10      > RETURN                                                   $4
   19    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a7int
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $currentType, !1 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   BIND_STATIC                                              !0
          1        BIND_STATIC                                              !1
          2        IS_IDENTICAL                                     ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 0

End of function hasdependencytypearrayany

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.57 ms | 1021 KiB | 16 Q