3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $a; public function __construct($a) { $this->a = $a; } } class B extends A { /** * Use php's magic method to enforce immutability */ public function __set($property, $value) { throw new RuntimeException(self::class . ' is immutable'); } } $a = new A(1); $b = new B(2); $a->b = $b; var_dump($a); try { $b->c = 3; } catch (RuntimeException $re) { var_dump($b); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RC1Sk
function name:  (null)
number of ops:  21
compiled vars:  !0 = $a, !1 = $b, !2 = $re
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $3      'A'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   25     4        NEW                                              $6      'B'
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   27     8        ASSIGN_OBJ                                               !0, 'b'
          9        OP_DATA                                                  !1
   28    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
   31    13        ASSIGN_OBJ                                               !1, 'c'
         14        OP_DATA                                                  3
         15      > JMP                                                      ->20
   32    16  E > > CATCH                                       last         'RuntimeException'
   33    17    >   INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
   34    20    > > RETURN                                                   1

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

End of function __construct

End of class A.

Class B:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/RC1Sk
function name:  __set
number of ops:  7
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        NEW                                              $2      'RuntimeException'
          3        SEND_VAL_EX                                              'B+is+immutable'
          4        DO_FCALL                                      0          
          5      > THROW                                         0          $2
   21     6*     > RETURN                                                   null

End of function __set

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

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.76 ms | 1072 KiB | 14 Q