3v4l.org

run code in 300+ PHP versions simultaneously
<?php class day{ public $date; public function __construct() { $this->date = time(); } /** * Should I write code today? * @param (array) $todos Current list of TODOs * @return boolean I should code if true. */ public function doCode($todos) { //return true; //Never stop coding $chore = next($todos); while($chore && $chore->priority < 3 ) $chore = next($todos); return $chore === false || $this->isWeekend($this->date); } /** * Is the date in teh weekend? * @param string $date String date to check * @return boolean True if date is in the weekend */ public function isWeekend($date) { return date('w', $date) % 6 == 0; } } /* End of file day.php */ /* Location: ./life/modules/day/day.php */ $agenda = array( (object)array('priority'=>1) ,(object)array('priority'=>4) ,(object)array('priority'=>1) ,(object)array('priority'=>5) ); $day = new day(); $i = 1; while($i< 10) { echo var_dump($day->isWeekend($day->date)) . "\n"; $day->date = strtotime('+1 day', $day->date); $i++; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 14
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 14
Branch analysis from position: 34
Branch analysis from position: 14
filename:       /in/ARIIA
function name:  (null)
number of ops:  35
compiled vars:  !0 = $agenda, !1 = $day, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   CAST                                          8  ~3      <array>
          1        INIT_ARRAY                                       ~4      ~3
   45     2        CAST                                          8  ~5      <array>
          3        ADD_ARRAY_ELEMENT                                ~4      ~5
   46     4        CAST                                          8  ~6      <array>
          5        ADD_ARRAY_ELEMENT                                ~4      ~6
   47     6        CAST                                          8  ~7      <array>
          7        ADD_ARRAY_ELEMENT                                ~4      ~7
   44     8        ASSIGN                                                   !0, ~4
   50     9        NEW                                              $9      'day'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $9
   52    12        ASSIGN                                                   !2, 1
   53    13      > JMP                                                      ->32
   55    14    >   INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !1, 'isWeekend'
         16        CHECK_FUNC_ARG                                           
         17        FETCH_OBJ_FUNC_ARG                               $13     !1, 'date'
         18        SEND_FUNC_ARG                                            $13
         19        DO_FCALL                                      0  $14     
         20        SEND_VAR                                                 $14
         21        DO_ICALL                                         $15     
         22        CONCAT                                           ~16     $15, '%0A'
         23        ECHO                                                     ~16
   56    24        INIT_FCALL                                               'strtotime'
         25        SEND_VAL                                                 '%2B1+day'
         26        FETCH_OBJ_R                                      ~18     !1, 'date'
         27        SEND_VAL                                                 ~18
         28        DO_ICALL                                         $19     
         29        ASSIGN_OBJ                                               !1, 'date'
         30        OP_DATA                                                  $19
   57    31        PRE_INC                                                  !2
   53    32    >   IS_SMALLER                                               !2, 10
         33      > JMPNZ                                                    ~21, ->14
   58    34    > > RETURN                                                   1

Class day:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ARIIA
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'time'
          1        DO_ICALL                                         $1      
          2        ASSIGN_OBJ                                               'date'
          3        OP_DATA                                                  $1
   11     4      > RETURN                                                   null

End of function __construct

Function docode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 6
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
Branch analysis from position: 14
Branch analysis from position: 14
filename:       /in/ARIIA
function name:  doCode
number of ops:  25
compiled vars:  !0 = $todos, !1 = $chore
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'next'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   23     5      > JMP                                                      ->10
   24     6    >   INIT_FCALL                                               'next'
          7        SEND_REF                                                 !0
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !1, $4
   23    10    > > JMPZ_EX                                          ~6      !1, ->14
         11    >   FETCH_OBJ_R                                      ~7      !1, 'priority'
         12        IS_SMALLER                                       ~8      ~7, 3
         13        BOOL                                             ~6      ~8
         14    > > JMPNZ                                                    ~6, ->6
   26    15    >   TYPE_CHECK                                    4  ~9      !1
         16      > JMPNZ_EX                                         ~9      ~9, ->23
         17    >   INIT_METHOD_CALL                                         'isWeekend'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_OBJ_FUNC_ARG                               $10     'date'
         20        SEND_FUNC_ARG                                            $10
         21        DO_FCALL                                      0  $11     
         22        BOOL                                             ~9      $11
         23    > > RETURN                                                   ~9
   27    24*     > RETURN                                                   null

End of function docode

Function isweekend:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ARIIA
function name:  isWeekend
number of ops:  9
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'w'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        MOD                                              ~2      $1, 6
          6        IS_EQUAL                                         ~3      ~2, 0
          7      > RETURN                                                   ~3
   37     8*     > RETURN                                                   null

End of function isweekend

End of class day.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.57 ms | 1404 KiB | 23 Q