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; public function __construct($foo) { $this->foo = $foo; } } $thing = new ImmutableThingy("bar"); var_dump($thing, $thing->foo); $thing->foo = 'baz'; var_dump($thing, $thing->foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yr19p
function name:  (null)
number of ops:  18
compiled vars:  !0 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_CLASS                                            'immutablethingy'
   24     1        NEW                                              $1      'ImmutableThingy'
          2        SEND_VAL_EX                                              'bar'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   26     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        FETCH_OBJ_R                                      ~4      !0, 'foo'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                                 
   28    10        ASSIGN_OBJ                                               !0, 'foo'
         11        OP_DATA                                                  'baz'
   30    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        FETCH_OBJ_R                                      ~7      !0, 'foo'
         15        SEND_VAL                                                 ~7
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class Immutable:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/Yr19p
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/Yr19p
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:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yr19p
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   21     3      > RETURN                                                   null

End of function __construct

End of class ImmutableThingy.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.49 ms | 1400 KiB | 15 Q