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)){ if(count($pieces = explode("::", $callable)) == 2){ return [$pieces[0], $pieces[1]]; } } return $callable; }; $a = $f($a); $b = $f($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/62Gk7
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'callable_equals'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 'foo%3A%3Abar'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function callable_equals:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/62Gk7
function name:  callable_equals
number of ops:  15
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%2F62Gk7%3A4%240'
          3        ASSIGN                                                   !2, ~3
   13     4        INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !0, $5
   14     8        INIT_DYNAMIC_CALL                                        !2
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !1, $7
   16    12        IS_IDENTICAL                                     ~9      !0, !1
         13      > RETURN                                                   ~9
   17    14*     > RETURN                                                   null

End of function callable_equals

Function %00%7Bclosure%7D%2Fin%2F62Gk7%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/62Gk7
function name:  {closure}
number of ops:  18
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, ->16
    6     3    >   INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%3A%3A'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        ASSIGN                                           ~4      !1, $3
          8        COUNT                                            ~5      ~4
          9        IS_EQUAL                                                 ~5, 2
         10      > JMPZ                                                     ~6, ->16
    7    11    >   FETCH_DIM_R                                      ~7      !1, 0
         12        INIT_ARRAY                                       ~8      ~7
         13        FETCH_DIM_R                                      ~9      !1, 1
         14        ADD_ARRAY_ELEMENT                                ~8      ~9
         15      > RETURN                                                   ~8
   10    16    > > RETURN                                                   !0
   11    17*     > RETURN                                                   null

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

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

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.65 ms | 1407 KiB | 18 Q