3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait Test { function init(){ $req = $this->getRequest(); $topics = $req['topics']; usort($topics, function($first, $next) { if(is_null($first['expiryDate'])) return 1; if(is_null($next['expiryDate'])) return -1; // otherwise ascending return $first['expiryDate'] <=> $next['expiryDate']; }); $req['topics'] = $topics; } } class Collection implements ArrayAccess { private $container = []; public function offsetSet($offset, $value):void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset):bool { return isset($this->container[$offset]); } public function offsetUnset($offset):void{ unset($this->container[$offset]); } public function offsetGet($offset):mixed { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } class SchedulerRepository { use Test; protected Collection $request; /** * @return Collection */ public function getRequest(): Collection { return $this->request; } public function bootstrap($data) { $this->request = $data; $this->init(); } } $data = new Collection; $data['topics'] = [ ['expiryDate' => 9], ['expiryDate' => 6], ['expiryDate' => 7], ]; $s = (new SchedulerRepository); $s->bootstrap($data); var_dump($s);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  (null)
number of ops:  17
compiled vars:  !0 = $data, !1 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   DECLARE_CLASS                                                'collection'
   41     1        DECLARE_CLASS                                                'schedulerrepository'
   63     2        NEW                                                  $2      'Collection'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   64     5        ASSIGN_DIM                                                   !0, 'topics'
   65     6        OP_DATA                                                      <array>
   69     7        NEW                                                  $6      'SchedulerRepository'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !1, $6
   70    10        INIT_METHOD_CALL                                             !1, 'bootstrap'
         11        SEND_VAR_EX                                                  !0
         12        DO_FCALL                                          0          
   71    13        INIT_FCALL                                                   'var_dump'
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                                     
         16      > RETURN                                                       1

Class Test:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  init
number of ops:  13
compiled vars:  !0 = $req, !1 = $topics
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   INIT_METHOD_CALL                                             'getRequest'
          1        DO_FCALL                                          0  $2      
          2        ASSIGN                                                       !0, $2
    6     3        FETCH_DIM_R                                          ~4      !0, 'topics'
          4        ASSIGN                                                       !1, ~4
    7     5        INIT_FCALL                                                   'usort'
          6        SEND_REF                                                     !1
          7        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
   12     8        SEND_VAL                                                     ~6
    7     9        DO_ICALL                                                     
   13    10        ASSIGN_DIM                                                   !0, 'topics'
         11        OP_DATA                                                      !1
   14    12      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  {closure:Test::init():7}
number of ops:  15
compiled vars:  !0 = $first, !1 = $next
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    8     2        FETCH_DIM_R                                          ~2      !0, 'expiryDate'
          3        TYPE_CHECK                                        2          ~2
          4      > JMPZ                                                         ~3, ->6
          5    > > RETURN                                                       1
    9     6    >   FETCH_DIM_R                                          ~4      !1, 'expiryDate'
          7        TYPE_CHECK                                        2          ~4
          8      > JMPZ                                                         ~5, ->10
          9    > > RETURN                                                       -1
   11    10    >   FETCH_DIM_R                                          ~6      !0, 'expiryDate'
         11        FETCH_DIM_R                                          ~7      !1, 'expiryDate'
         12        SPACESHIP                                            ~8      ~6, ~7
         13      > RETURN                                                       ~8
   12    14*     > RETURN                                                       null

End of Dynamic Function 0

End of function init

End of class Test.

Class Collection:
Function offsetset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
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: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  offsetSet
number of ops:  12
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   21     2        TYPE_CHECK                                        2          !0
          3      > JMPZ                                                         ~2, ->8
   22     4    >   FETCH_OBJ_W                                          $3      'container'
          5        ASSIGN_DIM                                                   $3
          6        OP_DATA                                                      !1
   21     7      > JMP                                                          ->11
   24     8    >   FETCH_OBJ_W                                          $5      'container'
          9        ASSIGN_DIM                                                   $5, !0
         10        OP_DATA                                                      !1
   26    11    > > RETURN                                                       null

End of function offsetset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  offsetExists
number of ops:  7
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   RECV                                                 !0      
   29     1        FETCH_OBJ_IS                                         ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      ~1, !0
          3        VERIFY_RETURN_TYPE                                           ~2
          4      > RETURN                                                       ~2
   30     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of function offsetexists

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   RECV                                                 !0      
   33     1        FETCH_OBJ_UNSET                                      $1      'container'
          2        UNSET_DIM                                                    $1, !0
   34     3      > RETURN                                                       null

End of function offsetunset

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  offsetGet
number of ops:  12
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
   37     1        FETCH_OBJ_IS                                         ~1      'container'
          2        ISSET_ISEMPTY_DIM_OBJ                             0          ~1, !0
          3      > JMPZ                                                         ~2, ->8
          4    >   FETCH_OBJ_R                                          ~3      'container'
          5        FETCH_DIM_R                                          ~4      ~3, !0
          6        QM_ASSIGN                                            ~5      ~4
          7      > JMP                                                          ->9
          8    >   QM_ASSIGN                                            ~5      null
          9    > > RETURN                                                       ~5
   38    10*       VERIFY_RETURN_TYPE                                           
         11*     > RETURN                                                       null

End of function offsetget

End of class Collection.

Class SchedulerRepository:
Function getrequest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  getRequest
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   52     0  E >   FETCH_OBJ_R                                          ~0      'request'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   53     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function getrequest

Function bootstrap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qLN2l
function name:  bootstrap
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   55     0  E >   RECV                                                 !0      
   57     1        ASSIGN_OBJ                                                   'request'
          2        OP_DATA                                                      !0
   59     3        INIT_METHOD_CALL                                             'init'
          4        DO_FCALL                                          0          
   60     5      > RETURN                                                       null

End of function bootstrap

End of class SchedulerRepository.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.59 ms | 1793 KiB | 15 Q