3v4l.org

run code in 300+ PHP versions simultaneously
<?php class EventStatus { const SUCCESS = 'success'; const STOPPED = 'stopped'; const FAILED = 'failed'; private static $validStatuses = [ self::SUCCESS, self::STOPPED, self::FAILED ]; private $status = self::SUCCESS; public function __construct($aStatus = self::SUCCESS) { $this->validateStatus($aStatus); $this->status = (string) $aStatus; } public static function __callStatic($aStatus, $arguments = []) { return new static($aStatus); } public function isSuccess() { return ($this->status == self::SUCCESS); } public function isStopped() { return ($this->status == self::STOPPED); } public function isFailed() { return ($this->status == self::FAILED); } private function validateStatus($aStatus) { if (!in_array(str_to_lower($aStatus), static::$validStatuses)) { throw new DomainException("Invalid event status [$aStatus]"); } } } var_dump(EventStatus::Failed());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_STATIC_METHOD_CALL                                  'EventStatus', 'Failed'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   1

Class EventStatus:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  __construct
number of ops:  8
compiled vars:  !0 = $aStatus
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                        !0      <const ast>
   19     1        INIT_METHOD_CALL                                         'validateStatus'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   20     4        CAST                                          6  ~3      !0
          5        ASSIGN_OBJ                                               'status'
          6        OP_DATA                                                  ~3
   21     7      > RETURN                                                   null

End of function __construct

Function __callstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  __callStatic
number of ops:  7
compiled vars:  !0 = $aStatus, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   25     2        NEW                          static              $2      
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $2
   26     6*     > RETURN                                                   null

End of function __callstatic

Function issuccess:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  isSuccess
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'status'
          1        IS_EQUAL                                         ~1      ~0, 'success'
          2      > RETURN                                                   ~1
   31     3*     > RETURN                                                   null

End of function issuccess

Function isstopped:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  isStopped
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   FETCH_OBJ_R                                      ~0      'status'
          1        IS_EQUAL                                         ~1      ~0, 'stopped'
          2      > RETURN                                                   ~1
   36     3*     > RETURN                                                   null

End of function isstopped

Function isfailed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  isFailed
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_OBJ_R                                      ~0      'status'
          1        IS_EQUAL                                         ~1      ~0, 'failed'
          2      > RETURN                                                   ~1
   41     3*     > RETURN                                                   null

End of function isfailed

Function validatestatus:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/epQUt
function name:  validateStatus
number of ops:  19
compiled vars:  !0 = $aStatus
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   45     1        INIT_FCALL                                               'in_array'
          2        INIT_FCALL_BY_NAME                                       'str_to_lower'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        FETCH_STATIC_PROP_R          unknown             ~2      'validStatuses'
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                         $3      
          9        BOOL_NOT                                         ~4      $3
         10      > JMPZ                                                     ~4, ->18
   46    11    >   NEW                                              $5      'DomainException'
         12        ROPE_INIT                                     3  ~7      'Invalid+event+status+%5B'
         13        ROPE_ADD                                      1  ~7      ~7, !0
         14        ROPE_END                                      2  ~6      ~7, '%5D'
         15        SEND_VAL_EX                                              ~6
         16        DO_FCALL                                      0          
         17      > THROW                                         0          $5
   48    18    > > RETURN                                                   null

End of function validatestatus

End of class EventStatus.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.58 ms | 1400 KiB | 17 Q