3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Status { private static $codeMap = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 511 => 'Network Authentication Required', ]; /** @var self[] */ private static $instances = []; /** @var int */ private $code; /** @var string */ private $reason; /** * @param int $aCode * @throws InvalidArgumentException on invalid code */ private function __construct($aCode) { if (!array_key_exists((int) $aCode, static::$codeMap)) { throw new InvalidArgumentExeption("Invalid status code: [$aCode]"); } $this->code = (int) $aCode; $this->reason = static::$codeMap[$this->code]; } /** * @example $status = Status::_404(); * @return self */ public static function __callStatic($aMethod, array $arguments) { $aMethod = trim($aMethod, '_'); if (!array_key_exists($aMethod, static::$instances)) { static::$instances[$aMethod] = new static($aMethod); } return static::$instances[$aMethod]; } /** @return bool */ public function hasCode($aCode) { return $this->code === (int) $aCode; } /** @return string */ public function __toString() { return $this->code . ' ' . $this->reason; } } var_dump(Status::_418() === Status::_418());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Mf42
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'status'
  113     1        INIT_FCALL                                               'var_dump'
          2        INIT_STATIC_METHOD_CALL                                  'Status', '_418'
          3        DO_FCALL                                      0  $0      
          4        INIT_STATIC_METHOD_CALL                                  'Status', '_418'
          5        DO_FCALL                                      0  $1      
          6        IS_IDENTICAL                                     ~2      $0, $1
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class Status:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Mf42
function name:  __construct
number of ops:  22
compiled vars:  !0 = $aCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   78     0  E >   RECV                                             !0      
   80     1        CAST                                          4  ~1      !0
          2        FETCH_STATIC_PROP_R          unknown             ~2      'codeMap'
          3        ARRAY_KEY_EXISTS                                 ~3      ~1, ~2
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->13
   81     6    >   NEW                                              $5      'InvalidArgumentExeption'
          7        ROPE_INIT                                     3  ~7      'Invalid+status+code%3A+%5B'
          8        ROPE_ADD                                      1  ~7      ~7, !0
          9        ROPE_END                                      2  ~6      ~7, '%5D'
         10        SEND_VAL_EX                                              ~6
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $5
   83    13    >   CAST                                          4  ~11     !0
         14        ASSIGN_OBJ                                               'code'
         15        OP_DATA                                                  ~11
   84    16        FETCH_OBJ_R                                      ~14     'code'
         17        FETCH_STATIC_PROP_R          unknown             ~13     'codeMap'
         18        FETCH_DIM_R                                      ~15     ~13, ~14
         19        ASSIGN_OBJ                                               'reason'
         20        OP_DATA                                                  ~15
   85    21      > RETURN                                                   null

End of function __construct

Function __callstatic:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/5Mf42
function name:  __callStatic
number of ops:  21
compiled vars:  !0 = $aMethod, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   93     2        INIT_FCALL                                               'trim'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '_'
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   94     7        FETCH_STATIC_PROP_R          global lock         ~4      'instances'
          8        ARRAY_KEY_EXISTS                                 ~5      !0, ~4
          9        BOOL_NOT                                         ~6      ~5
         10      > JMPZ                                                     ~6, ->17
   95    11    >   NEW                          static              $9      
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
         14        FETCH_STATIC_PROP_W          unknown             $7      'instances'
         15        ASSIGN_DIM                                               $7, !0
         16        OP_DATA                                                  $9
   97    17    >   FETCH_STATIC_PROP_R          unknown             ~11     'instances'
         18        FETCH_DIM_R                                      ~12     ~11, !0
         19      > RETURN                                                   ~12
   98    20*     > RETURN                                                   null

End of function __callstatic

Function hascode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Mf42
function name:  hasCode
number of ops:  6
compiled vars:  !0 = $aCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  101     0  E >   RECV                                             !0      
  103     1        FETCH_OBJ_R                                      ~1      'code'
          2        CAST                                          4  ~2      !0
          3        IS_IDENTICAL                                     ~3      ~1, ~2
          4      > RETURN                                                   ~3
  104     5*     > RETURN                                                   null

End of function hascode

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Mf42
function name:  __toString
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  109     0  E >   FETCH_OBJ_R                                      ~0      'code'
          1        CONCAT                                           ~1      ~0, '+'
          2        FETCH_OBJ_R                                      ~2      'reason'
          3        CONCAT                                           ~3      ~1, ~2
          4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
  110     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function __tostring

End of class Status.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
311.05 ms | 1400 KiB | 18 Q