3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyBitmask { const POS_1 = 1; // const POS_2 = 2; // reserved/undefined // const POS_3 = 3; // reserved/undefined const POS_4 = 4; private $b = 0x0000; function setChecked($pos) { if (in_array($pos, (new ReflectionClass($this))->getConstants())) { $this->set($pos); } return $this; } function set($pos) { $this->b |= 1 << ($pos - 1); return $this; } } $b = new MyBitmask(); var_dump($b->setChecked(2)); var_dump($b->set(2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j4vuJ
function name:  (null)
number of ops:  16
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'MyBitmask'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'setChecked'
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   27     9        INIT_FCALL                                               'var_dump'
         10        INIT_METHOD_CALL                                         !0, 'set'
         11        SEND_VAL_EX                                              2
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class MyBitmask:
Function setchecked:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/j4vuJ
function name:  setChecked
number of ops:  18
compiled vars:  !0 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'in_array'
          2        SEND_VAR                                                 !0
          3        NEW                                              $1      'ReflectionClass'
          4        FETCH_THIS                                       $2      
          5        SEND_VAR_EX                                              $2
          6        DO_FCALL                                      0          
          7        INIT_METHOD_CALL                                         $1, 'getConstants'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11      > JMPZ                                                     $5, ->15
   12    12    >   INIT_METHOD_CALL                                         'set'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   15    15    >   FETCH_THIS                                       ~7      
         16      > RETURN                                                   ~7
   16    17*     > RETURN                                                   null

End of function setchecked

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j4vuJ
function name:  set
number of ops:  8
compiled vars:  !0 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        SUB                                              ~2      !0, 1
          2        SL                                               ~3      1, ~2
          3        ASSIGN_OBJ_OP                                 9          'b'
          4        OP_DATA                                                  ~3
   21     5        FETCH_THIS                                       ~4      
          6      > RETURN                                                   ~4
   22     7*     > RETURN                                                   null

End of function set

End of class MyBitmask.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.27 ms | 1400 KiB | 17 Q