3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeImmutableObject { private $someString; private $flagCreate = false; public function __construct(string $value) { if ($this->flagCreate === true) { throw new \BadMethodCallException('This immutable object has already been created.'); } $this->someString = $value; $this->flagCreate = true; } public function getValue(): string { return 'the value is:' . $this->someString . ' - '; } } class AnotherClassToBreakImmutableObject extends SomeImmutableObject { public function __construct(string $value) { $this->someString = $value; } public function getValue(): string { return 'the value is:' . $this->someString . ' - '; } public function change(): void { $this->someString .= ' and Baz'; } } $three = new AnotherClassToBreakImmutableObject('Foo'); echo $three->getValue(); //Foo echo $three->change(); echo $three->getValue(); //the value is: Foo and Baz -
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JmkoK
function name:  (null)
number of ops:  14
compiled vars:  !0 = $three
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $1      'AnotherClassToBreakImmutableObject'
          1        SEND_VAL_EX                                              'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   44     4        INIT_METHOD_CALL                                         !0, 'getValue'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   45     7        INIT_METHOD_CALL                                         !0, 'change'
          8        DO_FCALL                                      0  $5      
          9        ECHO                                                     $5
   46    10        INIT_METHOD_CALL                                         !0, 'getValue'
         11        DO_FCALL                                      0  $6      
         12        ECHO                                                     $6
         13      > RETURN                                                   1

Class SomeImmutableObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JmkoK
function name:  __construct
number of ops:  13
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
   10     1        FETCH_OBJ_R                                      ~1      'flagCreate'
          2        TYPE_CHECK                                    8          ~1
          3      > JMPZ                                                     ~2, ->8
   11     4    >   NEW                                              $3      'BadMethodCallException'
          5        SEND_VAL_EX                                              'This+immutable+object+has+already+been+created.'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
   14     8    >   ASSIGN_OBJ                                               'someString'
          9        OP_DATA                                                  !0
   15    10        ASSIGN_OBJ                                               'flagCreate'
         11        OP_DATA                                                  <true>
   16    12      > 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/JmkoK
function name:  getValue
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_OBJ_R                                      ~0      'someString'
          1        CONCAT                                           ~1      'the+value+is%3A', ~0
          2        CONCAT                                           ~2      ~1, '+-+'
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
   21     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function getvalue

End of class SomeImmutableObject.

Class AnotherClassToBreakImmutableObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JmkoK
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        ASSIGN_OBJ                                               'someString'
          2        OP_DATA                                                  !0
   30     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/JmkoK
function name:  getValue
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'someString'
          1        CONCAT                                           ~1      'the+value+is%3A', ~0
          2        CONCAT                                           ~2      ~1, '+-+'
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
   35     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function getvalue

Function change:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JmkoK
function name:  change
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   ASSIGN_OBJ_OP                                 8          'someString'
          1        OP_DATA                                                  '+and+Baz'
   40     2      > RETURN                                                   null

End of function change

End of class AnotherClassToBreakImmutableObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.77 ms | 1445 KiB | 13 Q