3v4l.org

run code in 300+ PHP versions simultaneously
<?php function batchDelete(): \Generator { // $entityManager = $this->getEntityManager($class); $queryResults = range(0, 102); $i = 0; $removedObjects = []; foreach ($queryResults as $pos => $object) { // $entityManager->remove($object[0]); $removedObjects[] = $object; if (0 === (++$i % 20)) { yield from $removedObjects; $removedObjects = []; // $entityManager->flush(); // $entityManager->clear(); } } yield from $removedObjects; // $entityManager->flush(); // $entityManager->clear(); } function callerFunctionBatchDelete() { foreach (batchDelete() as $deletedObject) { // Fire any event you may need regarding `$deletedObject`. echo 'Some operation with object "'.$deletedObject."\".\n"; } } callerFunctionBatchDelete();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HjjWH
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'callerfunctionbatchdelete'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function batchdelete:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 21
filename:       /in/HjjWH
function name:  batchDelete
number of ops:  25
compiled vars:  !0 = $queryResults, !1 = $i, !2 = $removedObjects, !3 = $object, !4 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    6     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 102
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !0, $5
    7     6        ASSIGN                                                   !1, 0
    8     7        ASSIGN                                                   !2, <array>
    9     8      > FE_RESET_R                                       $9      !0, ->21
          9    > > FE_FETCH_R                                       ~10     $9, !3, ->21
         10    >   ASSIGN                                                   !4, ~10
   12    11        ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !3
   13    13        PRE_INC                                          ~13     !1
         14        MOD                                              ~14     ~13, 20
         15        IS_IDENTICAL                                             ~14, 0
         16      > JMPZ                                                     ~15, ->20
   14    17    >   YIELD_FROM                                       ~16     !2
         18        FREE                                                     ~16
   16    19        ASSIGN                                                   !2, <array>
    9    20    > > JMP                                                      ->9
         21    >   FE_FREE                                                  $9
   23    22        YIELD_FROM                                       ~18     !2
         23        FREE                                                     ~18
   27    24      > GENERATOR_RETURN                                         

End of function batchdelete

Function callerfunctionbatchdelete:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/HjjWH
function name:  callerFunctionBatchDelete
number of ops:  10
compiled vars:  !0 = $deletedObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'batchdelete'
          1        DO_FCALL                                      0  $1      
          2      > FE_RESET_R                                       $2      $1, ->8
          3    > > FE_FETCH_R                                               $2, !0, ->8
   33     4    >   CONCAT                                           ~3      'Some+operation+with+object+%22', !0
          5        CONCAT                                           ~4      ~3, '%22.%0A'
          6        ECHO                                                     ~4
   31     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $2
   35     9      > RETURN                                                   null

End of function callerfunctionbatchdelete

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.87 ms | 992 KiB | 16 Q