3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Timer { private $_state; private $_date; public function __construct($state, \DateTime $date) { $this->_state = $state; $this->_date = clone $date; } public function getType() { return $this->_state; } public function getInterval() { return (new \DateTime('2015-01-01'))->diff(clone $this->_date); } public function isPositive() { return !(bool) $this->getInterval()->invert; } public function isNegative() { return (bool) $this->getInterval()->invert; } } $timer = new Timer('lalala', new \DateTime('2015-01-01')); var_dump( $timer->isPositive(), $timer->isNegative() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQjDi
function name:  (null)
number of ops:  17
compiled vars:  !0 = $timer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $1      'Timer'
          1        SEND_VAL_EX                                              'lalala'
          2        NEW                                              $2      'DateTime'
          3        SEND_VAL_EX                                              '2015-01-01'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $1
   36     8        INIT_FCALL                                               'var_dump'
   37     9        INIT_METHOD_CALL                                         !0, 'isPositive'
         10        DO_FCALL                                      0  $6      
         11        SEND_VAR                                                 $6
   38    12        INIT_METHOD_CALL                                         !0, 'isNegative'
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   39    16      > RETURN                                                   1

Class Timer:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQjDi
function name:  __construct
number of ops:  8
compiled vars:  !0 = $state, !1 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN_OBJ                                               '_state'
          3        OP_DATA                                                  !0
   10     4        CLONE                                            ~4      !1
          5        ASSIGN_OBJ                                               '_date'
          6        OP_DATA                                                  ~4
   11     7      > RETURN                                                   null

End of function __construct

Function gettype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQjDi
function name:  getType
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      '_state'
          1      > RETURN                                                   ~0
   16     2*     > RETURN                                                   null

End of function gettype

Function getinterval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQjDi
function name:  getInterval
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $0      'DateTime'
          1        SEND_VAL_EX                                              '2015-01-01'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'diff'
          4        FETCH_OBJ_R                                      ~2      '_date'
          5        CLONE                                            ~3      ~2
          6        SEND_VAL_EX                                              ~3
          7        DO_FCALL                                      0  $4      
          8      > RETURN                                                   $4
   21     9*     > RETURN                                                   null

End of function getinterval

Function ispositive:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQjDi
function name:  isPositive
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_METHOD_CALL                                         'getInterval'
          1        DO_FCALL                                      0  $0      
          2        FETCH_OBJ_R                                      ~1      $0, 'invert'
          3        BOOL                                             ~2      ~1
          4        BOOL_NOT                                         ~3      ~2
          5      > RETURN                                                   ~3
   26     6*     > RETURN                                                   null

End of function ispositive

Function isnegative:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQjDi
function name:  isNegative
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_METHOD_CALL                                         'getInterval'
          1        DO_FCALL                                      0  $0      
          2        FETCH_OBJ_R                                      ~1      $0, 'invert'
          3        BOOL                                             ~2      ~1
          4      > RETURN                                                   ~2
   31     5*     > RETURN                                                   null

End of function isnegative

End of class Timer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.82 ms | 1392 KiB | 15 Q