3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class CanNotSetProperties extends RuntimeException { public function __construct() { parent::__construct("You can not set properties on Immutable objects."); } } final class ConstructorIsVisible extends RuntimeException { public function __construct() { parent::__construct("Immutable objects can not expose the constructor."); } } final class CanNotBeCloned extends RuntimeException { public function __construct() { parent::__construct("Immutable objects can not be cloned."); } } trait Immutable { public function __set($property, $value) { throw new CanNotSetProperties; } private function __clone() { throw new CanNotBeCloned; } final private function __construct() { } } final class Test { use Immutable; public function __construct() { echo 'hello'; } public function __clone() { echo 'baba'; } } $test = new Test; $test2 = clone $test;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  (null)
number of ops:  7
compiled vars:  !0 = $test, !1 = $test2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   DECLARE_CLASS                                            'test'
   59     1        NEW                                              $2      'Test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   60     4        CLONE                                            ~5      !0
          5        ASSIGN                                                   !1, ~5
          6      > RETURN                                                   1

Class CanNotSetProperties:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        SEND_VAL_EX                                              'You+can+not+set+properties+on+Immutable+objects.'
          2        DO_FCALL                                      0          
    8     3      > RETURN                                                   null

End of function __construct

End of class CanNotSetProperties.

Class ConstructorIsVisible:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        SEND_VAL_EX                                              'Immutable+objects+can+not+expose+the+constructor.'
          2        DO_FCALL                                      0          
   16     3      > RETURN                                                   null

End of function __construct

End of class ConstructorIsVisible.

Class CanNotBeCloned:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        SEND_VAL_EX                                              'Immutable+objects+can+not+be+cloned.'
          2        DO_FCALL                                      0          
   24     3      > RETURN                                                   null

End of function __construct

End of class CanNotBeCloned.

Class Immutable:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/N11uf
function name:  __set
number of ops:  6
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     2        NEW                                              $2      'CanNotSetProperties'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $2
   32     5*     > RETURN                                                   null

End of function __set

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/N11uf
function name:  __clone
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $0      'CanNotBeCloned'
          1        DO_FCALL                                      0          
          2      > THROW                                         0          $0
   37     3*     > RETURN                                                   null

End of function __clone

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E > > RETURN                                                   null

End of function __construct

End of class Immutable.

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   ECHO                                                     'hello'
   51     1      > RETURN                                                   null

End of function __construct

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N11uf
function name:  __clone
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   ECHO                                                     'baba'
   56     1      > RETURN                                                   null

End of function __clone

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.51 ms | 1399 KiB | 13 Q