3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { const STATE_BLOCKED = 0; const STATE_VALIDATED = 1; const STATE_NOT_VALIDATED = 2; public static $states = [ User::STATE_BLOCKED => 'Bloqueado', User::STATE_VALIDATED => 'Normal', User::STATE_NOT_VALIDATED => 'Pendiente de validaciĆ³n', ]; public function setState($state) { var_dump($state); var_dump(ctype_digit($state)); var_dump(array_key_exists($state, User::$states)); if (!ctype_digit(to_string($state)) or !array_key_exists($state, User::$states)) { echo "bad state '$state'"; } echo 'ok'; } public function setUnvalidated() { $this->setState(User::STATE_NOT_VALIDATED); } } $u = new User(); $u->setUnvalidated();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LRXHX
function name:  (null)
number of ops:  6
compiled vars:  !0 = $u
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $1      'User'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   35     3        INIT_METHOD_CALL                                         !0, 'setUnvalidated'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class User:
Function setstate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 27
filename:       /in/LRXHX
function name:  setState
number of ops:  34
compiled vars:  !0 = $state
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   19     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'ctype_digit'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
   20    10        INIT_FCALL                                               'var_dump'
         11        FETCH_STATIC_PROP_R          unknown             ~4      'states'
         12        ARRAY_KEY_EXISTS                                 ~5      !0, ~4
         13        SEND_VAL                                                 ~5
         14        DO_ICALL                                                 
   22    15        INIT_FCALL                                               'ctype_digit'
         16        INIT_FCALL_BY_NAME                                       'to_string'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $7      
         19        SEND_VAR                                                 $7
         20        DO_ICALL                                         $8      
         21        BOOL_NOT                                         ~9      $8
         22      > JMPNZ_EX                                         ~9      ~9, ->27
         23    >   FETCH_STATIC_PROP_R          unknown             ~10     'states'
         24        ARRAY_KEY_EXISTS                                 ~11     !0, ~10
         25        BOOL_NOT                                         ~12     ~11
         26        BOOL                                             ~9      ~12
         27    > > JMPZ                                                     ~9, ->32
   23    28    >   ROPE_INIT                                     3  ~14     'bad+state+%27'
         29        ROPE_ADD                                      1  ~14     ~14, !0
         30        ROPE_END                                      2  ~13     ~14, '%27'
         31        ECHO                                                     ~13
   25    32    >   ECHO                                                     'ok'
   26    33      > RETURN                                                   null

End of function setstate

Function setunvalidated:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LRXHX
function name:  setUnvalidated
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_METHOD_CALL                                         'setState'
          1        SEND_VAL_EX                                              2
          2        DO_FCALL                                      0          
   31     3      > RETURN                                                   null

End of function setunvalidated

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.92 ms | 1400 KiB | 17 Q