3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Item { private $notifier; public function __construct(callable $notifier) { $this->notifier = $notifier; } public function setTtl($time) { call_user_func($this->notifier, $time); } } class Pool { private $ttls = []; public function getItem($id) { return new Item(function ($ttl) use ($id) { $this->ttls[$id] = $ttl; }); } public function getTtl($id) { return $this->ttls[$id]; } } $pool = new Pool; $item = $pool->getItem('foo'); $item->setTtl(60); echo $pool->getTtl('foo');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2TgJn
function name:  (null)
number of ops:  15
compiled vars:  !0 = $pool, !1 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   NEW                                                  $2      'Pool'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $2
   37     3        INIT_METHOD_CALL                                             !0, 'getItem'
          4        SEND_VAL_EX                                                  'foo'
          5        DO_FCALL                                          0  $5      
          6        ASSIGN                                                       !1, $5
   39     7        INIT_METHOD_CALL                                             !1, 'setTtl'
          8        SEND_VAL_EX                                                  60
          9        DO_FCALL                                          0          
   41    10        INIT_METHOD_CALL                                             !0, 'getTtl'
         11        SEND_VAL_EX                                                  'foo'
         12        DO_FCALL                                          0  $8      
         13        ECHO                                                         $8
         14      > RETURN                                                       1

Class Item:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2TgJn
function name:  __construct
number of ops:  4
compiled vars:  !0 = $notifier
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1        ASSIGN_OBJ                                                   'notifier'
          2        OP_DATA                                                      !0
   10     3      > RETURN                                                       null

End of function __construct

Function setttl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2TgJn
function name:  setTtl
number of ops:  6
compiled vars:  !0 = $time
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
   14     1        FETCH_OBJ_R                                          ~1      'notifier'
          2        INIT_USER_CALL                                    1          'call_user_func', ~1
          3        SEND_USER                                                    !0
          4        DO_FCALL                                          0          
   15     5      > RETURN                                                       null

End of function setttl

End of class Item.

Class Pool:
Function getitem:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2TgJn
function name:  getItem
number of ops:  8
compiled vars:  !0 = $id
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
   24     1        NEW                                                  $1      'Item'
          2        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          3        BIND_LEXICAL                                                 ~2, !0
   26     4        SEND_VAL_EX                                                  ~2
   24     5        DO_FCALL                                          0          
   26     6      > RETURN                                                       $1
   27     7*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2TgJn
function name:  {closure:Pool::getItem():24}
number of ops:  6
compiled vars:  !0 = $ttl, !1 = $id
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   25     2        FETCH_OBJ_W                                          $2      'ttls'
          3        ASSIGN_DIM                                                   $2, !1
          4        OP_DATA                                                      !0
   26     5      > RETURN                                                       null

End of Dynamic Function 0

End of function getitem

Function getttl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2TgJn
function name:  getTtl
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV                                                 !0      
   31     1        FETCH_OBJ_R                                          ~1      'ttls'
          2        FETCH_DIM_R                                          ~2      ~1, !0
          3      > RETURN                                                       ~2
   32     4*     > RETURN                                                       null

End of function getttl

End of class Pool.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.08 ms | 2162 KiB | 13 Q