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 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/cSFfb
function name:  (null)
number of ops:  25
compiled vars:  !0 = $items, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   BEGIN_SILENCE                                    ~2      
          1        INIT_FCALL                                               'ini_set'
          2        SEND_VAL                                                 'date.timezone'
          3        SEND_VAL                                                 'Europe%2FLondon'
          4        DO_ICALL                                                 
          5        END_SILENCE                                              ~2
    4     6        DECLARE_CLASS                                            'onlypendingdeletioniterator', 'filteriterator'
   21     7        ASSIGN                                                   !0, <array>
   31     8        NEW                                              $5      'OnlyPendingDeletionIterator'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !0, $5
   33    12        ECHO                                                     'Pending%3A+'
         13        COUNT                                            ~8      !0
         14        ECHO                                                     ~8
         15        ECHO                                                     '%0A'
   35    16      > FE_RESET_R                                       $9      !0, ->23
         17    > > FE_FETCH_R                                               $9, !1, ->23
   36    18    >   ECHO                                                     'id%3A+'
         19        FETCH_DIM_R                                      ~10     !1, 'id'
         20        ECHO                                                     ~10
         21        ECHO                                                     '%0A'
   35    22      > JMP                                                      ->17
         23    >   FE_FREE                                                  $9
   37    24      > RETURN                                                   1

Class OnlyPendingDeletionIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cSFfb
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/cSFfb
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/cSFfb
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:
158.09 ms | 1400 KiB | 19 Q