3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Immutable { private $somePropertyThatShouldntBeChanged; public static function create($value) { return new self($value); } private function __construct($value) { $this->somePropertyThatShouldntBeChanged = $value; } public function getValue() { return $this->somePropertyThatShouldntBeChanged; } } $foo = Immutable::create('immutable value'); echo $foo->getValue() . PHP_EOL; $foo->__construct('not immutable value'); echo $foo->getValue() . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oOuEk
function name:  (null)
number of ops:  16
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_STATIC_METHOD_CALL                                  'Immutable', 'create'
          1        SEND_VAL                                                 'immutable+value'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   24     4        INIT_METHOD_CALL                                         !0, 'getValue'
          5        DO_FCALL                                      0  $3      
          6        CONCAT                                           ~4      $3, '%0A'
          7        ECHO                                                     ~4
   26     8        INIT_METHOD_CALL                                         !0, '__construct'
          9        SEND_VAL_EX                                              'not+immutable+value'
         10        DO_FCALL                                      0          
   28    11        INIT_METHOD_CALL                                         !0, 'getValue'
         12        DO_FCALL                                      0  $6      
         13        CONCAT                                           ~7      $6, '%0A'
         14        ECHO                                                     ~7
         15      > RETURN                                                   1

Class Immutable:
Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oOuEk
function name:  create
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
    9     5*     > RETURN                                                   null

End of function create

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

End of function __construct

Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oOuEk
function name:  getValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                      ~0      'somePropertyThatShouldntBeChanged'
          1      > RETURN                                                   ~0
   19     2*     > RETURN                                                   null

End of function getvalue

End of class Immutable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.79 ms | 1390 KiB | 13 Q