3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @link http://github.com/myclabs/php-enum * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file) */ namespace MyCLabs\Enum; /** * Base Enum class * * Create an enum by implementing this class and adding class constants. * * @author Matthieu Napoli <matthieu@mnapoli.fr> * @author Daniel Costa <danielcosta@gmail.com> * @author Mirosław Filip <mirfilip@gmail.com> * * @psalm-template T * @psalm-immutable * @psalm-consistent-constructor */ abstract class Enum implements \JsonSerializable { /** * Enum value * * @var mixed * @psalm-var T */ protected $value; /** * Enum key, the constant name * * @var string */ private $key; /** * Store existing constants in a static cache per object. * * * @var array * @psalm-var array<class-string, array<string, mixed>> */ protected static $cache = []; /** * Cache of instances of the Enum class * * @var array * @psalm-var array<class-string, array<string, static>> */ protected static $instances = []; /** * Creates a new value of some type * * @psalm-pure * @param mixed $value * * @psalm-param T $value * @throws \UnexpectedValueException if incompatible type is given. */ public function __construct($value) { if ($value instanceof static) { /** @psalm-var T */ $value = $value->getValue(); } /** @psalm-suppress ImplicitToStringCast assertValidValueReturningKey returns always a string but psalm has currently an issue here */ $this->key = static::assertValidValueReturningKey($value); /** @psalm-var T */ $this->value = $value; } /** * This method exists only for the compatibility reason when deserializing a previously serialized version * that didn't had the key property */ public function __wakeup() { /** @psalm-suppress DocblockTypeContradiction key can be null when deserializing an enum without the key */ if ($this->key === null) { /** * @psalm-suppress InaccessibleProperty key is not readonly as marked by psalm * @psalm-suppress PossiblyFalsePropertyAssignmentValue deserializing a case that was removed */ $this->key = static::search($this->value); } } /** * @param mixed $value * @return static * @psalm-return static<T> */ public static function from($value): self { $key = static::assertValidValueReturningKey($value); return self::__callStatic($key, []); } /** * @psalm-pure * @return mixed * @psalm-return T */ public function getValue() { return $this->value; } /** * Returns the enum key (i.e. the constant name). * * @psalm-pure * @return string */ public function getKey() { return $this->key; } /** * @psalm-pure * @psalm-suppress InvalidCast * @return string */ public function __toString() { return (string)$this->value; } /** * Determines if Enum should be considered equal with the variable passed as a parameter. * Returns false if an argument is an object of different class or not an object. * * This method is final, for more information read https://github.com/myclabs/php-enum/issues/4 * * @psalm-pure * @psalm-param mixed $variable * @return bool */ final public function equals($variable = null): bool { return $variable instanceof self && $this->getValue() === $variable->getValue() && static::class === \get_class($variable); } /** * Returns the names (keys) of all constants in the Enum class * * @psalm-pure * @psalm-return list<string> * @return array */ public static function keys() { return \array_keys(static::toArray()); } /** * Returns instances of the Enum class of all Enum constants * * @psalm-pure * @psalm-return array<string, static> * @return static[] Constant name in key, Enum instance in value */ public static function values() { $values = array(); /** @psalm-var T $value */ foreach (static::toArray() as $key => $value) { $values[$key] = new static($value); } return $values; } /** * Returns all possible values as an array * * @psalm-pure * @psalm-suppress ImpureStaticProperty * * @psalm-return array<string, mixed> * @return array Constant name in key, constant value in value */ public static function toArray() { $class = static::class; if (!isset(static::$cache[$class])) { /** @psalm-suppress ImpureMethodCall this reflection API usage has no side-effects here */ $reflection = new \ReflectionClass($class); /** @psalm-suppress ImpureMethodCall this reflection API usage has no side-effects here */ static::$cache[$class] = $reflection->getConstants(); } return static::$cache[$class]; } /** * Check if is valid enum value * * @param $value * @psalm-param mixed $value * @psalm-pure * @psalm-assert-if-true T $value * @return bool */ public static function isValid($value) { return \in_array($value, static::toArray(), true); } /** * Asserts valid enum value * * @psalm-pure * @psalm-assert T $value * @param mixed $value */ public static function assertValidValue($value): void { self::assertValidValueReturningKey($value); } /** * Asserts valid enum value * * @psalm-pure * @psalm-assert T $value * @param mixed $value * @return string */ private static function assertValidValueReturningKey($value): string { if (false === ($key = static::search($value))) { throw new \UnexpectedValueException("Value '$value' is not part of the enum " . static::class); } return $key; } /** * Check if is valid enum key * * @param $key * @psalm-param string $key * @psalm-pure * @return bool */ public static function isValidKey($key) { $array = static::toArray(); return isset($array[$key]) || \array_key_exists($key, $array); } /** * Return key for value * * @param mixed $value * * @psalm-param mixed $value * @psalm-pure * @return string|false */ public static function search($value) { return \array_search($value, static::toArray(), true); } /** * Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant * * @param string $name * @param array $arguments * * @return static * @throws \BadMethodCallException * * @psalm-pure */ public static function __callStatic($name, $arguments) { $class = static::class; if (!isset(self::$instances[$class][$name])) { $array = static::toArray(); if (!isset($array[$name]) && !\array_key_exists($name, $array)) { $message = "No static method or enum constant '$name' in class " . static::class; throw new \BadMethodCallException($message); } return self::$instances[$class][$name] = new static($array[$name]); } return clone self::$instances[$class][$name]; } /** * Specify data which should be serialized to JSON. This method returns data that can be serialized by json_encode() * natively. * * @return mixed * @link http://php.net/manual/en/jsonserializable.jsonserialize.php * @psalm-pure */ public function jsonSerialize() { return $this->getValue(); } } /** * Methods enum * * @method static STORE(): Method * @method static DEFLATE(): Method * @psalm-immutable */ class Method extends Enum { const STORE = 0x00; const DEFLATE = 0x08; } class Test { protected $method; public function __construct() { $this->method = Method::STORE(); } } $obj = new Test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  (null)
number of ops:  6
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   DECLARE_CLASS                                            'myclabs%5Cenum%5Cenum'
  330     1        DECLARE_CLASS                                            'myclabs%5Cenum%5Cmethod', 'myclabs%5Cenum%5Cenum'
  348     2        NEW                                              $1      'MyCLabs%5CEnum%5CTest'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
          5      > RETURN                                                   1

Class MyCLabs\Enum\Enum:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/XbJJk
function name:  __construct
number of ops:  14
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV                                             !0      
   68     1        INSTANCEOF                                               !0
          2      > JMPZ                                                     ~1, ->6
   70     3    >   INIT_METHOD_CALL                                         !0, 'getValue'
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   74     6    >   INIT_STATIC_METHOD_CALL                                  'assertValidValueReturningKey'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $5      
          9        ASSIGN_OBJ                                               'key'
         10        OP_DATA                                                  $5
   77    11        ASSIGN_OBJ                                               'value'
         12        OP_DATA                                                  !0
   78    13      > RETURN                                                   null

End of function __construct

Function __wakeup:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/XbJJk
function name:  __wakeup
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   87     0  E >   FETCH_OBJ_R                                      ~0      'key'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->10
   92     3    >   INIT_STATIC_METHOD_CALL                                  'search'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $3      'value'
          6        SEND_FUNC_ARG                                            $3
          7        DO_FCALL                                      0  $4      
          8        ASSIGN_OBJ                                               'key'
          9        OP_DATA                                                  $4
   94    10    > > RETURN                                                   null

End of function __wakeup

Function from:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  from
number of ops:  13
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  101     0  E >   RECV                                             !0      
  103     1        INIT_STATIC_METHOD_CALL                                  'assertValidValueReturningKey'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
  105     5        INIT_STATIC_METHOD_CALL                                  '__callStatic'
          6        SEND_VAR_EX                                              !1
          7        SEND_VAL_EX                                              <array>
          8        DO_FCALL                                      0  $4      
          9        VERIFY_RETURN_TYPE                                       $4
         10      > RETURN                                                   $4
  106    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function from

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

End of function getvalue

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

End of function getkey

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  136     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1        CAST                                          6  ~1      ~0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
  137     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

Function equals:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/XbJJk
function name:  equals
number of ops:  18
compiled vars:  !0 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  149     0  E >   RECV_INIT                                        !0      null
  151     1        INSTANCEOF                                       ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->9
  152     3    >   INIT_METHOD_CALL                                         'getValue'
          4        DO_FCALL                                      0  $2      
          5        INIT_METHOD_CALL                                         !0, 'getValue'
          6        DO_FCALL                                      0  $3      
          7        IS_IDENTICAL                                     ~4      $2, $3
          8        BOOL                                             ~1      ~4
          9    > > JMPZ_EX                                          ~1      ~1, ->14
  153    10    >   FETCH_CLASS_NAME                                 ~5      
         11        GET_CLASS                                        ~6      !0
         12        IS_IDENTICAL                                     ~7      ~5, ~6
         13        BOOL                                             ~1      ~7
         14    >   VERIFY_RETURN_TYPE                                       ~1
         15      > RETURN                                                   ~1
  154    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of function equals

Function keys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  keys
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  165     0  E >   INIT_FCALL                                               'array_keys'
          1        INIT_STATIC_METHOD_CALL                                  'toArray'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
  166     6*     > RETURN                                                   null

End of function keys

Function values:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/XbJJk
function name:  values
number of ops:  15
compiled vars:  !0 = $values, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  177     0  E >   ASSIGN                                                   !0, <array>
  180     1        INIT_STATIC_METHOD_CALL                                  'toArray'
          2        DO_FCALL                                      0  $4      
          3      > FE_RESET_R                                       $5      $4, ->12
          4    > > FE_FETCH_R                                       ~6      $5, !1, ->12
          5    >   ASSIGN                                                   !2, ~6
  181     6        NEW                          static              $9      
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN_DIM                                               !0, !2
         10        OP_DATA                                                  $9
  180    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $5
  184    13      > RETURN                                                   !0
  185    14*     > RETURN                                                   null

End of function values

Function toarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/XbJJk
function name:  toArray
number of ops:  19
compiled vars:  !0 = $class, !1 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  198     0  E >   FETCH_CLASS_NAME                                 ~2      
          1        ASSIGN                                                   !0, ~2
  200     2        FETCH_STATIC_PROP_IS                             ~4      'cache'
          3        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      ~4, !0
          4        BOOL_NOT                                         ~6      ~5
          5      > JMPZ                                                     ~6, ->15
  202     6    >   NEW                                              $7      'ReflectionClass'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $7
  204    10        INIT_METHOD_CALL                                         !1, 'getConstants'
         11        DO_FCALL                                      0  $12     
         12        FETCH_STATIC_PROP_W          unknown             $10     'cache'
         13        ASSIGN_DIM                                               $10, !0
         14        OP_DATA                                                  $12
  207    15    >   FETCH_STATIC_PROP_R          unknown             ~13     'cache'
         16        FETCH_DIM_R                                      ~14     ~13, !0
         17      > RETURN                                                   ~14
  208    18*     > RETURN                                                   null

End of function toarray

Function isvalid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  isValid
number of ops:  10
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  219     0  E >   RECV                                             !0      
  221     1        INIT_FCALL                                               'in_array'
          2        SEND_VAR                                                 !0
          3        INIT_STATIC_METHOD_CALL                                  'toArray'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
  222     9*     > RETURN                                                   null

End of function isvalid

Function assertvalidvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  assertValidValue
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  231     0  E >   RECV                                             !0      
  233     1        INIT_STATIC_METHOD_CALL                                  'assertValidValueReturningKey'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
  234     4      > RETURN                                                   null

End of function assertvalidvalue

Function assertvalidvaluereturningkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  assertValidValueReturningKey
number of ops:  20
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  244     0  E >   RECV                                             !0      
  246     1        INIT_STATIC_METHOD_CALL                                  'search'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                           ~3      !1, $2
          5        TYPE_CHECK                                    4          ~3
          6      > JMPZ                                                     ~4, ->16
  247     7    >   NEW                                              $5      'UnexpectedValueException'
          8        ROPE_INIT                                     3  ~7      'Value+%27'
          9        ROPE_ADD                                      1  ~7      ~7, !0
         10        ROPE_END                                      2  ~6      ~7, '%27+is+not+part+of+the+enum+'
         11        FETCH_CLASS_NAME                                 ~9      
         12        CONCAT                                           ~10     ~6, ~9
         13        SEND_VAL_EX                                              ~10
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $5
  250    16    >   VERIFY_RETURN_TYPE                                       !1
         17      > RETURN                                                   !1
  251    18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of function assertvalidvaluereturningkey

Function isvalidkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/XbJJk
function name:  isValidKey
number of ops:  10
compiled vars:  !0 = $key, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  261     0  E >   RECV                                             !0      
  263     1        INIT_STATIC_METHOD_CALL                                  'toArray'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
  265     4        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !1, !0
          5      > JMPNZ_EX                                         ~4      ~4, ->8
          6    >   ARRAY_KEY_EXISTS                                 ~5      !0, !1
          7        BOOL                                             ~4      ~5
          8    > > RETURN                                                   ~4
  266     9*     > RETURN                                                   null

End of function isvalidkey

Function search:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  search
number of ops:  10
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  277     0  E >   RECV                                             !0      
  279     1        INIT_FCALL                                               'array_search'
          2        SEND_VAR                                                 !0
          3        INIT_STATIC_METHOD_CALL                                  'toArray'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
  280     9*     > RETURN                                                   null

End of function search

Function __callstatic:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 39
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  __callStatic
number of ops:  45
compiled vars:  !0 = $name, !1 = $arguments, !2 = $class, !3 = $array, !4 = $message
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  293     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  295     2        FETCH_CLASS_NAME                                 ~5      
          3        ASSIGN                                                   !2, ~5
  296     4        FETCH_STATIC_PROP_IS                             ~7      'instances'
          5        FETCH_DIM_IS                                     ~8      ~7, !2
          6        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      ~8, !0
          7        BOOL_NOT                                         ~10     ~9
          8      > JMPZ                                                     ~10, ->39
  297     9    >   INIT_STATIC_METHOD_CALL                                  'toArray'
         10        DO_FCALL                                      0  $11     
         11        ASSIGN                                                   !3, $11
  298    12        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !3, !0
         13        BOOL_NOT                                         ~14     ~13
         14      > JMPZ_EX                                          ~14     ~14, ->18
         15    >   ARRAY_KEY_EXISTS                                 ~15     !0, !3
         16        BOOL_NOT                                         ~16     ~15
         17        BOOL                                             ~14     ~16
         18    > > JMPZ                                                     ~14, ->29
  299    19    >   ROPE_INIT                                     3  ~18     'No+static+method+or+enum+constant+%27'
         20        ROPE_ADD                                      1  ~18     ~18, !0
         21        ROPE_END                                      2  ~17     ~18, '%27+in+class+'
         22        FETCH_CLASS_NAME                                 ~20     
         23        CONCAT                                           ~21     ~17, ~20
         24        ASSIGN                                                   !4, ~21
  300    25        NEW                                              $23     'BadMethodCallException'
         26        SEND_VAR_EX                                              !4
         27        DO_FCALL                                      0          
         28      > THROW                                         0          $23
  302    29    >   NEW                          static              $28     
         30        CHECK_FUNC_ARG                                           
         31        FETCH_DIM_FUNC_ARG                               $29     !3, !0
         32        SEND_FUNC_ARG                                            $29
         33        DO_FCALL                                      0          
         34        FETCH_STATIC_PROP_W          unknown             $25     'instances'
         35        FETCH_DIM_W                                      $26     $25, !2
         36        ASSIGN_DIM                                       ~27     $26, !0
         37        OP_DATA                                                  $28
         38      > RETURN                                                   ~27
  304    39    >   FETCH_STATIC_PROP_R          unknown             ~31     'instances'
         40        FETCH_DIM_R                                      ~32     ~31, !2
         41        FETCH_DIM_R                                      ~33     ~32, !0
         42        CLONE                                            ~34     ~33
         43      > RETURN                                                   ~34
  305    44*     > RETURN                                                   null

End of function __callstatic

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  jsonSerialize
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  317     0  E >   INIT_METHOD_CALL                                         'getValue'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
  318     3*     > RETURN                                                   null

End of function jsonserialize

End of class MyCLabs\Enum\Enum.

Class MyCLabs\Enum\Method: [no user functions]
Class MyCLabs\Enum\Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbJJk
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  343     0  E >   INIT_STATIC_METHOD_CALL                                  'MyCLabs%5CEnum%5CMethod', 'STORE'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN_OBJ                                               'method'
          3        OP_DATA                                                  $1
  344     4      > RETURN                                                   null

End of function __construct

End of class MyCLabs\Enum\Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.88 ms | 1032 KiB | 16 Q