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

Function callable_equals:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OpbLb
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%2FOpbLb%3A4%240'
          3        ASSIGN                                                   !2, ~3
   16     4        INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !0, $5
   17     8        INIT_DYNAMIC_CALL                                        !2
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !1, $7
   19    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
   20    16        IS_IDENTICAL                                     ~10     !0, !1
         17      > RETURN                                                   ~10
   21    18*     > RETURN                                                   null

End of function callable_equals

Function %00%7Bclosure%7D%2Fin%2FOpbLb%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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OpbLb
function name:  {closure}
number of ops:  29
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                                           ~6      !1, $5
         12        COUNT                                            ~7      ~6
         13        IS_EQUAL                                                 ~7, 2
         14      > JMPZ                                                     ~8, ->20
    8    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
   10    20    > > RETURN                                                   !0
   12    21    >   INIT_FCALL                                               'strtolower'
         22        FETCH_DIM_R                                      ~13     !0, 1
         23        SEND_VAL                                                 ~13
         24        DO_ICALL                                         $14     
         25        ASSIGN_DIM                                               !0, 1
         26        OP_DATA                                                  $14
   13    27      > RETURN                                                   !0
   14    28*     > RETURN                                                   null

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

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

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.24 ms | 1403 KiB | 20 Q