3v4l.org

run code in 300+ PHP versions simultaneously
<?php function callable_equals(callable $a, callable $b){ $f = function(callable $callable){ if(is_string($callable)){ $callable = strtolower($callable); $pieces = explode("::", $callable); if(count($pieces) == 2){ return [$pieces[0], $pieces[1]]; } return $callable; } if(is_string($callable[0])){ $callable[0] = strtolower($callable[0]); } $callable[1] = strtolower($callable[1]); return $callable; }; $a = $f($a); $b = $f($b); var_dump($a, $b); return $a === $b; } class Foo{static function bar(){}} var_dump(callable_equals( ['Foo', 'bar'], 'foo::bar' ));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZPcne
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'callable_equals'
   30     2        SEND_VAL                                                 <array>
   31     3        SEND_VAL                                                 'foo%3A%3Abar'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   32     7      > RETURN                                                   1

Function callable_equals:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZPcne
function name:  callable_equals
number of ops:  19
compiled vars:  !0 = $a, !1 = $b, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZPcne%3A4%240'
          3        ASSIGN                                                   !2, ~3
   20     4        INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !0, $5
   21     8        INIT_DYNAMIC_CALL                                        !2
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !1, $7
   23    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
   24    16        IS_IDENTICAL                                     ~10     !0, !1
         17      > RETURN                                                   ~10
   25    18*     > RETURN                                                   null

End of function callable_equals

Function %00%7Bclosure%7D%2Fin%2FZPcne%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/ZPcne
function name:  {closure}
number of ops:  38
compiled vars:  !0 = $callable, !1 = $pieces
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        TYPE_CHECK                                   64          !0
          2      > JMPZ                                                     ~2, ->21
    6     3    >   INIT_FCALL                                               'strtolower'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    7     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%3A%3A'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !1, $5
    8    12        COUNT                                            ~7      !1
         13        IS_EQUAL                                                 ~7, 2
         14      > JMPZ                                                     ~8, ->20
    9    15    >   FETCH_DIM_R                                      ~9      !1, 0
         16        INIT_ARRAY                                       ~10     ~9
         17        FETCH_DIM_R                                      ~11     !1, 1
         18        ADD_ARRAY_ELEMENT                                ~10     ~11
         19      > RETURN                                                   ~10
   11    20    > > RETURN                                                   !0
   13    21    >   FETCH_DIM_R                                      ~12     !0, 0
         22        TYPE_CHECK                                   64          ~12
         23      > JMPZ                                                     ~13, ->30
   14    24    >   INIT_FCALL                                               'strtolower'
         25        FETCH_DIM_R                                      ~15     !0, 0
         26        SEND_VAL                                                 ~15
         27        DO_ICALL                                         $16     
         28        ASSIGN_DIM                                               !0, 0
         29        OP_DATA                                                  $16
   16    30    >   INIT_FCALL                                               'strtolower'
         31        FETCH_DIM_R                                      ~18     !0, 1
         32        SEND_VAL                                                 ~18
         33        DO_ICALL                                         $19     
         34        ASSIGN_DIM                                               !0, 1
         35        OP_DATA                                                  $19
   17    36      > RETURN                                                   !0
   18    37*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZPcne%3A4%240

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

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.4 ms | 1403 KiB | 20 Q