3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Matcher { private $patterns; public $callbacks; public function __construct() { $this->patterns = new SplQueue(); $this->callbacks = []; } public function with(array $pattern, callable $callback) { $this->patterns->enqueue($pattern); $this->callbacks[$this->patterns->key()] = $callback; } } $a = new Matcher(); $cb = function() { }; $a->with(['foo', 'bar'], $cb); $a->with(['foo2', 'bar2'], $cb); $a->with(['foo3', 'bar3'], $cb); var_dump($a->callbacks);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G2nmb
function name:  (null)
number of ops:  22
compiled vars:  !0 = $a, !1 = $cb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $2      'Matcher'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   24     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FG2nmb%3A24%240'
          4        ASSIGN                                                   !1, ~5
   28     5        INIT_METHOD_CALL                                         !0, 'with'
          6        SEND_VAL_EX                                              <array>
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
   29     9        INIT_METHOD_CALL                                         !0, 'with'
         10        SEND_VAL_EX                                              <array>
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
   30    13        INIT_METHOD_CALL                                         !0, 'with'
         14        SEND_VAL_EX                                              <array>
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
   33    17        INIT_FCALL                                               'var_dump'
         18        FETCH_OBJ_R                                      ~10     !0, 'callbacks'
         19        SEND_VAL                                                 ~10
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FG2nmb%3A24%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G2nmb
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FG2nmb%3A24%240

Class Matcher:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G2nmb
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $1      'SplQueue'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'patterns'
          3        OP_DATA                                                  $1
   12     4        ASSIGN_OBJ                                               'callbacks'
          5        OP_DATA                                                  <array>
   13     6      > RETURN                                                   null

End of function __construct

Function with:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G2nmb
function name:  with
number of ops:  13
compiled vars:  !0 = $pattern, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        FETCH_OBJ_R                                      ~2      'patterns'
          3        INIT_METHOD_CALL                                         ~2, 'enqueue'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
   18     6        FETCH_OBJ_R                                      ~5      'patterns'
          7        INIT_METHOD_CALL                                         ~5, 'key'
          8        DO_FCALL                                      0  $6      
          9        FETCH_OBJ_W                                      $4      'callbacks'
         10        ASSIGN_DIM                                               $4, $6
         11        OP_DATA                                                  !1
   19    12      > RETURN                                                   null

End of function with

End of class Matcher.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.32 ms | 1405 KiB | 15 Q