3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('date.timezone', 'Europe/London'); class OnlyPendingDeletionIterator extends FilterIterator implements Countable { public function __construct(array $items) { parent::__construct(new ArrayIterator($items)); } public function accept() { $item = $this->current(); $fourthOfJan = strtotime('2014-01-04'); return $fourthOfJan > strtotime($item['date']); } public function count() { return iterator_count($this); } } $items = array( array('id' => 1, 'date' => '2014-01-01'), array('id' => 2, 'date' => '2014-01-02'), array('id' => 3, 'date' => '2014-01-03'), array('id' => 4, 'date' => '2014-01-04'), array('id' => 5, 'date' => '2014-01-05'), array('id' => 6, 'date' => '2014-01-06'), array('id' => 7, 'date' => '2014-01-07'), ); $items = new OnlyPendingDeletionIterator($items); echo 'Pending: ', count($items), PHP_EOL; foreach ($items as $item) { echo 'id: ', $item['id'], PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/t4Y28
function name:  (null)
number of ops:  23
compiled vars:  !0 = $items, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'date.timezone'
          2        SEND_VAL                                                 'Europe%2FLondon'
          3        DO_ICALL                                                 
    4     4        DECLARE_CLASS                                            'onlypendingdeletioniterator', 'filteriterator'
   21     5        ASSIGN                                                   !0, <array>
   31     6        NEW                                              $4      'OnlyPendingDeletionIterator'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !0, $4
   33    10        ECHO                                                     'Pending%3A+'
         11        COUNT                                            ~7      !0
         12        ECHO                                                     ~7
         13        ECHO                                                     '%0A'
   35    14      > FE_RESET_R                                       $8      !0, ->21
         15    > > FE_FETCH_R                                               $8, !1, ->21
   36    16    >   ECHO                                                     'id%3A+'
         17        FETCH_DIM_R                                      ~9      !1, 'id'
         18        ECHO                                                     ~9
         19        ECHO                                                     '%0A'
   35    20      > JMP                                                      ->15
         21    >   FE_FREE                                                  $8
   37    22      > RETURN                                                   1

Class OnlyPendingDeletionIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t4Y28
function name:  __construct
number of ops:  8
compiled vars:  !0 = $items
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_STATIC_METHOD_CALL                                  
          2        NEW                                              $1      'ArrayIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0          
    8     7      > RETURN                                                   null

End of function __construct

Function accept:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t4Y28
function name:  accept
number of ops:  14
compiled vars:  !0 = $item, !1 = $fourthOfJan
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_METHOD_CALL                                         'current'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   12     3        INIT_FCALL                                               'strtotime'
          4        SEND_VAL                                                 '2014-01-04'
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
   13     7        INIT_FCALL                                               'strtotime'
          8        FETCH_DIM_R                                      ~6      !0, 'date'
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                         $7      
         11        IS_SMALLER                                       ~8      $7, !1
         12      > RETURN                                                   ~8
   14    13*     > RETURN                                                   null

End of function accept

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t4Y28
function name:  count
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'iterator_count'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   18     5*     > RETURN                                                   null

End of function count

End of class OnlyPendingDeletionIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.78 ms | 1404 KiB | 19 Q