3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace { function callable_equals(callable ...$callables){ $normalizeCallable = 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; }; foreach($callables as $i => $callable) $callables[$i] = $normalizeCallable($callable); var_dump($a, $b); return $a === $b; } class Foo{static function bar(){}} } namespace A\b\C\d { class Foo{static function bar(){}} } namespace { var_dump(callable_equals( ['Foo', 'bar'], 'foo::BAR' )); var_dump(callable_equals( ['A\\b\\C\\d\\Foo', 'bAr'], 'a\\B\\c\\D\\FoO::bar' )); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n6Nct
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'callable_equals'
   40     2        SEND_VAL                                                 <array>
   41     3        SEND_VAL                                                 'foo%3A%3ABAR'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   44     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'callable_equals'
   45     9        SEND_VAL                                                 <array>
   46    10        SEND_VAL                                                 'a%5CB%5Cc%5CD%5CFoO%3A%3Abar'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   48    14      > RETURN                                                   1

Function callable_equals:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/n6Nct
function name:  callable_equals
number of ops:  20
compiled vars:  !0 = $callables, !1 = $normalizeCallable, !2 = $callable, !3 = $i, !4 = $a, !5 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_VARIADIC                                    !0      
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fn6Nct%3A6%240'
          2        ASSIGN                                                   !1, ~6
   22     3      > FE_RESET_R                                       $8      !0, ->12
          4    > > FE_FETCH_R                                       ~9      $8, !2, ->12
          5    >   ASSIGN                                                   !3, ~9
   23     6        INIT_DYNAMIC_CALL                                        !1
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $12     
          9        ASSIGN_DIM                                               !0, !3
         10        OP_DATA                                                  $12
   22    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $8
   25    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !4
         15        SEND_VAR                                                 !5
         16        DO_ICALL                                                 
   26    17        IS_IDENTICAL                                     ~14     !4, !5
         18      > RETURN                                                   ~14
   27    19*     > RETURN                                                   null

End of function callable_equals

Function %00%7Bclosure%7D%2Fin%2Fn6Nct%3A6%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/n6Nct
function name:  {closure}
number of ops:  38
compiled vars:  !0 = $callable, !1 = $pieces
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        TYPE_CHECK                                   64          !0
          2      > JMPZ                                                     ~2, ->21
    8     3    >   INIT_FCALL                                               'strtolower'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    9     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%3A%3A'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !1, $5
   10    12        COUNT                                            ~7      !1
         13        IS_EQUAL                                                 ~7, 2
         14      > JMPZ                                                     ~8, ->20
   11    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
   13    20    > > RETURN                                                   !0
   15    21    >   FETCH_DIM_R                                      ~12     !0, 0
         22        TYPE_CHECK                                   64          ~12
         23      > JMPZ                                                     ~13, ->30
   16    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
   18    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
   19    36      > RETURN                                                   !0
   20    37*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fn6Nct%3A6%240

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

End of function bar

End of class Foo.

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

End of function bar

End of class A\b\C\d\Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
254.68 ms | 1407 KiB | 22 Q