3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const TYPE_BUFFER = 1; const TYPE_PICKING = 2; const TYPE_CONTAINER = 4; const TYPE_SHIPMENT = 8; const TYPE_ALL = 15; private $type; public function __construct($type) { $this->type = $type; } public function allowAdd() { return ($this->type & self::TYPE_BUFFER + self::TYPE_PICKING) !== 0; } public function allowAddAll() { return ($this->type & self::TYPE_ALL) !== 0; } } var_dump((new Foo(Foo::TYPE_BUFFER))->allowAdd()); var_dump((new Foo(Foo::TYPE_PICKING))->allowAdd()); var_dump((new Foo(Foo::TYPE_CONTAINER))->allowAdd()); var_dump((new Foo(Foo::TYPE_SHIPMENT))->allowAdd()); echo PHP_EOL; var_dump((new Foo(Foo::TYPE_BUFFER))->allowAddAll()); var_dump((new Foo(Foo::TYPE_PICKING))->allowAddAll()); var_dump((new Foo(Foo::TYPE_CONTAINER))->allowAddAll()); var_dump((new Foo(Foo::TYPE_SHIPMENT))->allowAddAll()); var_dump((new Foo(16))->allowAddAll()); var_dump((new Foo(31))->allowAddAll()); var_dump((new Foo(0))->allowAddAll()); var_dump((new Foo(-16))->allowAddAll());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qF9dQ
function name:  (null)
number of ops:  98
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Foo'
          2        SEND_VAL_EX                                              1
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $0, 'allowAdd'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   30     8        INIT_FCALL                                               'var_dump'
          9        NEW                                              $4      'Foo'
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0          
         12        INIT_METHOD_CALL                                         $4, 'allowAdd'
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
   31    16        INIT_FCALL                                               'var_dump'
         17        NEW                                              $8      'Foo'
         18        SEND_VAL_EX                                              4
         19        DO_FCALL                                      0          
         20        INIT_METHOD_CALL                                         $8, 'allowAdd'
         21        DO_FCALL                                      0  $10     
         22        SEND_VAR                                                 $10
         23        DO_ICALL                                                 
   32    24        INIT_FCALL                                               'var_dump'
         25        NEW                                              $12     'Foo'
         26        SEND_VAL_EX                                              8
         27        DO_FCALL                                      0          
         28        INIT_METHOD_CALL                                         $12, 'allowAdd'
         29        DO_FCALL                                      0  $14     
         30        SEND_VAR                                                 $14
         31        DO_ICALL                                                 
   34    32        ECHO                                                     '%0A'
   36    33        INIT_FCALL                                               'var_dump'
         34        NEW                                              $16     'Foo'
         35        SEND_VAL_EX                                              1
         36        DO_FCALL                                      0          
         37        INIT_METHOD_CALL                                         $16, 'allowAddAll'
         38        DO_FCALL                                      0  $18     
         39        SEND_VAR                                                 $18
         40        DO_ICALL                                                 
   37    41        INIT_FCALL                                               'var_dump'
         42        NEW                                              $20     'Foo'
         43        SEND_VAL_EX                                              2
         44        DO_FCALL                                      0          
         45        INIT_METHOD_CALL                                         $20, 'allowAddAll'
         46        DO_FCALL                                      0  $22     
         47        SEND_VAR                                                 $22
         48        DO_ICALL                                                 
   38    49        INIT_FCALL                                               'var_dump'
         50        NEW                                              $24     'Foo'
         51        SEND_VAL_EX                                              4
         52        DO_FCALL                                      0          
         53        INIT_METHOD_CALL                                         $24, 'allowAddAll'
         54        DO_FCALL                                      0  $26     
         55        SEND_VAR                                                 $26
         56        DO_ICALL                                                 
   39    57        INIT_FCALL                                               'var_dump'
         58        NEW                                              $28     'Foo'
         59        SEND_VAL_EX                                              8
         60        DO_FCALL                                      0          
         61        INIT_METHOD_CALL                                         $28, 'allowAddAll'
         62        DO_FCALL                                      0  $30     
         63        SEND_VAR                                                 $30
         64        DO_ICALL                                                 
   40    65        INIT_FCALL                                               'var_dump'
         66        NEW                                              $32     'Foo'
         67        SEND_VAL_EX                                              16
         68        DO_FCALL                                      0          
         69        INIT_METHOD_CALL                                         $32, 'allowAddAll'
         70        DO_FCALL                                      0  $34     
         71        SEND_VAR                                                 $34
         72        DO_ICALL                                                 
   41    73        INIT_FCALL                                               'var_dump'
         74        NEW                                              $36     'Foo'
         75        SEND_VAL_EX                                              31
         76        DO_FCALL                                      0          
         77        INIT_METHOD_CALL                                         $36, 'allowAddAll'
         78        DO_FCALL                                      0  $38     
         79        SEND_VAR                                                 $38
         80        DO_ICALL                                                 
   42    81        INIT_FCALL                                               'var_dump'
         82        NEW                                              $40     'Foo'
         83        SEND_VAL_EX                                              0
         84        DO_FCALL                                      0          
         85        INIT_METHOD_CALL                                         $40, 'allowAddAll'
         86        DO_FCALL                                      0  $42     
         87        SEND_VAR                                                 $42
         88        DO_ICALL                                                 
   43    89        INIT_FCALL                                               'var_dump'
         90        NEW                                              $44     'Foo'
         91        SEND_VAL_EX                                              -16
         92        DO_FCALL                                      0          
         93        INIT_METHOD_CALL                                         $44, 'allowAddAll'
         94        DO_FCALL                                      0  $46     
         95        SEND_VAR                                                 $46
         96        DO_ICALL                                                 
         97      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qF9dQ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'type'
          2        OP_DATA                                                  !0
   16     3      > RETURN                                                   null

End of function __construct

Function allowadd:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qF9dQ
function name:  allowAdd
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_OBJ_R                                      ~0      'type'
          1        BW_AND                                           ~1      ~0, 3
          2        IS_NOT_IDENTICAL                                 ~2      ~1, 0
          3      > RETURN                                                   ~2
   21     4*     > RETURN                                                   null

End of function allowadd

Function allowaddall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qF9dQ
function name:  allowAddAll
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~0      'type'
          1        BW_AND                                           ~1      ~0, 15
          2        IS_NOT_IDENTICAL                                 ~2      ~1, 0
          3      > RETURN                                                   ~2
   26     4*     > RETURN                                                   null

End of function allowaddall

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.67 ms | 1396 KiB | 15 Q