3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Slim Framework (https://slimframework.com) * * @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License) */ namespace Slim; use ArrayIterator; use ArrayAccess; use Countable; use IteratorAggregate; interface CollectionInterface extends ArrayAccess, Countable, IteratorAggregate { /** * Set collection item * * @param string $key The data key * @param mixed $value The data value */ public function set($key, $value); /** * Get collection item for key * * @param string $key The data key * @param mixed $default The default value to return if data key does not exist * * @return mixed The key's value, or the default value */ public function get($key, $default = null); /** * Add item to collection, replacing existing items with the same data key * * @param array $items Key-value array of data to append to this collection */ public function replace(array $items); /** * Get all items in collection * * @return array The collection's source data */ public function all(); /** * Does this collection have a given key? * * @param string $key The data key * * @return bool */ public function has($key); /** * Remove item from collection * * @param string $key The data key */ public function remove($key); /** * Remove all items from collection */ public function clear(); } /** * Collection * * This class provides a common interface used by many other * classes in a Slim application that manage "collections" * of data that must be inspected and/or manipulated */ class Collection implements CollectionInterface { /** * The source data * * @var array */ protected $data = []; /** * @param array $items Pre-populate collection with this key-value array */ public function __construct(array $items = []) { $this->replace($items); } /** * {@inheritdoc} */ public function set($key, $value) { $this->data[$key] = $value; } /** * {@inheritdoc} */ public function get($key, $default = null) { return $this->has($key) ? $this->data[$key] : $default; } /** * {@inheritdoc} */ public function replace(array $items) { foreach ($items as $key => $value) { $this->set($key, $value); } } /** * {@inheritdoc} */ public function all() { return $this->data; } /** * Get collection keys * * @return array The collection's source data keys */ public function keys() { return array_keys($this->data); } /** * {@inheritdoc} */ public function has($key) { return array_key_exists($key, $this->data); } /** * {@inheritdoc} */ public function remove($key) { unset($this->data[$key]); } /** * {@inheritdoc} */ public function clear() { $this->data = []; } /** * Does this collection have a given key? * * @param string $key The data key * * @return bool */ public function offsetExists($key): bool { return $this->has($key); } /** * Get collection item for key * * @param string $key The data key * * @return mixed The key's value, or the default value */ #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->get($key); } /** * Set collection item * * @param string $key The data key * @param mixed $value The data value */ #[\ReturnTypeWillChange] public function offsetSet($key, $value) { $this->set($key, $value); } /** * Remove item from collection * * @param string $key The data key */ #[\ReturnTypeWillChange] public function offsetUnset($key) { $this->remove($key); } /** * Get number of items in collection * * @return int */ public function count(): int { return count($this->data); } /** * Get collection iterator * * @return ArrayIterator|\Traversable */ public function getIterator(): \Traversable { return new ArrayIterator($this->data); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                                'slim%5Ccollectioninterface'
   78     1        DECLARE_CLASS                                                'slim%5Ccollection'
  230     2      > RETURN                                                       1

Class Slim\CollectionInterface:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  set
number of ops:  3
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2      > RETURN                                                       null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  get
number of ops:  3
compiled vars:  !0 = $key, !1 = $default
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
          2      > RETURN                                                       null

End of function get

Function replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  replace
number of ops:  2
compiled vars:  !0 = $items
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function replace

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

End of function all

Function has:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  has
number of ops:  2
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   56     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function has

Function remove:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  remove
number of ops:  2
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   63     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function remove

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

End of function clear

End of class Slim\CollectionInterface.

Class Slim\Collection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  __construct
number of ops:  5
compiled vars:  !0 = $items
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   90     0  E >   RECV_INIT                                            !0      <array>
   92     1        INIT_METHOD_CALL                                             'replace'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
   93     4      > RETURN                                                       null

End of function __construct

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  set
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   98     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  100     2        FETCH_OBJ_W                                          $2      'data'
          3        ASSIGN_DIM                                                   $2, !0
          4        OP_DATA                                                      !1
  101     5      > RETURN                                                       null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  get
number of ops:  13
compiled vars:  !0 = $key, !1 = $default
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  106     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
  108     2        INIT_METHOD_CALL                                             'has'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0  $2      
          5      > JMPZ                                                         $2, ->10
          6    >   FETCH_OBJ_R                                          ~3      'data'
          7        FETCH_DIM_R                                          ~4      ~3, !0
          8        QM_ASSIGN                                            ~5      ~4
          9      > JMP                                                          ->11
         10    >   QM_ASSIGN                                            ~5      !1
         11    > > RETURN                                                       ~5
  109    12*     > RETURN                                                       null

End of function get

Function replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/ZY1Vc
function name:  replace
number of ops:  11
compiled vars:  !0 = $items, !1 = $value, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  114     0  E >   RECV                                                 !0      
  116     1      > FE_RESET_R                                           $3      !0, ->9
          2    > > FE_FETCH_R                                           ~4      $3, !1, ->9
          3    >   ASSIGN                                                       !2, ~4
  117     4        INIT_METHOD_CALL                                             'set'
          5        SEND_VAR_EX                                                  !2
          6        SEND_VAR_EX                                                  !1
          7        DO_FCALL                                          0          
  116     8      > JMP                                                          ->2
          9    >   FE_FREE                                                      $3
  119    10      > RETURN                                                       null

End of function replace

Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  all
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  126     0  E >   FETCH_OBJ_R                                          ~0      'data'
          1      > RETURN                                                       ~0
  127     2*     > RETURN                                                       null

End of function all

Function keys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  keys
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  136     0  E >   INIT_NS_FCALL_BY_NAME                                        'Slim%5Carray_keys'
          1        CHECK_FUNC_ARG                                               
          2        FETCH_OBJ_FUNC_ARG                                   $0      'data'
          3        SEND_FUNC_ARG                                                $0
          4        DO_FCALL                                          0  $1      
          5      > RETURN                                                       $1
  137     6*     > RETURN                                                       null

End of function keys

Function has:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  has
number of ops:  9
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  142     0  E >   RECV                                                 !0      
  144     1        INIT_NS_FCALL_BY_NAME                                        'Slim%5Carray_key_exists'
          2        SEND_VAR_EX                                                  !0
          3        CHECK_FUNC_ARG                                               
          4        FETCH_OBJ_FUNC_ARG                                   $1      'data'
          5        SEND_FUNC_ARG                                                $1
          6        DO_FCALL                                          0  $2      
          7      > RETURN                                                       $2
  145     8*     > RETURN                                                       null

End of function has

Function remove:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  remove
number of ops:  4
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  150     0  E >   RECV                                                 !0      
  152     1        FETCH_OBJ_UNSET                                      $1      'data'
          2        UNSET_DIM                                                    $1, !0
  153     3      > RETURN                                                       null

End of function remove

Function clear:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  clear
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  160     0  E >   ASSIGN_OBJ                                                   'data'
          1        OP_DATA                                                      <array>
  161     2      > RETURN                                                       null

End of function clear

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  offsetExists
number of ops:  8
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  170     0  E >   RECV                                                 !0      
  172     1        INIT_METHOD_CALL                                             'has'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4        VERIFY_RETURN_TYPE                                           $1
          5      > RETURN                                                       $1
  173     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  offsetGet
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  183     0  E >   RECV                                                 !0      
  185     1        INIT_METHOD_CALL                                             'get'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4      > RETURN                                                       $1
  186     5*     > RETURN                                                       null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  offsetSet
number of ops:  7
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  195     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  197     2        INIT_METHOD_CALL                                             'set'
          3        SEND_VAR_EX                                                  !0
          4        SEND_VAR_EX                                                  !1
          5        DO_FCALL                                          0          
  198     6      > RETURN                                                       null

End of function offsetset

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  offsetUnset
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  206     0  E >   RECV                                                 !0      
  208     1        INIT_METHOD_CALL                                             'remove'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
  209     4      > RETURN                                                       null

End of function offsetunset

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  count
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  218     0  E >   INIT_NS_FCALL_BY_NAME                                        'Slim%5Ccount'
          1        CHECK_FUNC_ARG                                               
          2        FETCH_OBJ_FUNC_ARG                                   $0      'data'
          3        SEND_FUNC_ARG                                                $0
          4        DO_FCALL                                          0  $1      
          5        VERIFY_RETURN_TYPE                                           $1
          6      > RETURN                                                       $1
  219     7*       VERIFY_RETURN_TYPE                                           
          8*     > RETURN                                                       null

End of function count

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZY1Vc
function name:  getIterator
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  228     0  E >   NEW                                                  $0      'ArrayIterator'
          1        CHECK_FUNC_ARG                                               
          2        FETCH_OBJ_FUNC_ARG                                   $1      'data'
          3        SEND_FUNC_ARG                                                $1
          4        DO_FCALL                                          0          
          5        VERIFY_RETURN_TYPE                                           $0
          6      > RETURN                                                       $0
  229     7*       VERIFY_RETURN_TYPE                                           
          8*     > RETURN                                                       null

End of function getiterator

End of class Slim\Collection.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.7 ms | 1798 KiB | 16 Q