3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $allowedNames = ['onlyThis', 'andThat']; public function __set($name, $value) { // only allow specific properties to be set pubically if (!in_array($name, $this->allowedNames)) { throw new Exception("No! Bad dog!"); } else { $this->$name = $value; } } } $foo = new Foo; $foo->onlyThis = true; $foo->andThat = false; var_dump($foo); // This won't work $foo->baz = 1;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ivnYo
function name:  (null)
number of ops:  13
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   16     3        ASSIGN_OBJ                                               !0, 'onlyThis'
          4        OP_DATA                                                  <true>
   17     5        ASSIGN_OBJ                                               !0, 'andThat'
          6        OP_DATA                                                  <false>
   18     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   21    10        ASSIGN_OBJ                                               !0, 'baz'
         11        OP_DATA                                                  1
   22    12      > RETURN                                                   1

Class Foo:
Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ivnYo
function name:  __set
number of ops:  17
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !0
          4        FETCH_OBJ_R                                      ~2      'allowedNames'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > JMPZ                                                     ~4, ->14
    8     9    >   NEW                                              $5      'Exception'
         10        SEND_VAL_EX                                              'No%21+Bad+dog%21'
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $5
         13*       JMP                                                      ->16
   10    14    >   ASSIGN_OBJ                                               !0
         15        OP_DATA                                                  !1
   12    16      > RETURN                                                   null

End of function __set

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.38 ms | 1396 KiB | 17 Q