3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Immutable { public function __set($name, $value) { throw new Exception("can't touch this, nah nah nuh nahhh"); } public function __get($name) { return $this->$name; } } class ImmutableThingy { use Immutable; protected $foo = 'bar'; } $thing = new ImmutableThingy; var_dump($thing, $thing->foo); $thing->poo = 'baz'; var_dump($thing, $thing->foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcPTQ
function name:  (null)
number of ops:  17
compiled vars:  !0 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_CLASS                                            'immutablethingy'
   19     1        NEW                                              $1      'ImmutableThingy'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   21     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        FETCH_OBJ_R                                      ~4      !0, 'foo'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                                 
   23     9        ASSIGN_OBJ                                               !0, 'poo'
         10        OP_DATA                                                  'baz'
   25    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        FETCH_OBJ_R                                      ~7      !0, 'foo'
         14        SEND_VAL                                                 ~7
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class Immutable:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/dcPTQ
function name:  __set
number of ops:  7
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        NEW                                              $2      'Exception'
          3        SEND_VAL_EX                                              'can%27t+touch+this%2C+nah+nah+nuh+nahhh'
          4        DO_FCALL                                      0          
          5      > THROW                                         0          $2
    6     6*     > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcPTQ
function name:  __get
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_OBJ_R                                      ~1      !0
          2      > RETURN                                                   ~1
   10     3*     > RETURN                                                   null

End of function __get

End of class Immutable.

Class ImmutableThingy: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
200.91 ms | 1396 KiB | 15 Q