3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(E_ALL); trait NumberSettingConstructor { public function __construct() { $this->number = 1234; } public function __set($name, $value) { printf("UNEXPECTED SETTING OF %s\n", $name); } } class ClassWithTypedProperty { public int $number; use NumberSettingConstructor; } class ClassWithInitializedTypedProperty { public int $number = 0; use NumberSettingConstructor; } class ClassWithTraditionalProperty { public $number; use NumberSettingConstructor; } printf("\n--- Typed Property ---\n"); print_r(new ClassWithTypedProperty()); printf("\n--- Typed Property (with Initialization) ---\n"); print_r(new ClassWithInitializedTypedProperty()); printf("\n--- Traditional Untyped Property ---\n"); print_r(new ClassWithTraditionalProperty());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0cT8r
function name:  (null)
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
   17     3        DECLARE_CLASS                                            'classwithtypedproperty'
   22     4        DECLARE_CLASS                                            'classwithinitializedtypedproperty'
   27     5        DECLARE_CLASS                                            'classwithtraditionalproperty'
   32     6        INIT_FCALL                                               'printf'
          7        SEND_VAL                                                 '%0A---+Typed+Property+---%0A'
          8        DO_ICALL                                                 
   33     9        INIT_FCALL                                               'print_r'
         10        NEW                                              $2      'ClassWithTypedProperty'
         11        DO_FCALL                                      0          
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   35    14        INIT_FCALL                                               'printf'
         15        SEND_VAL                                                 '%0A---+Typed+Property+%28with+Initialization%29+---%0A'
         16        DO_ICALL                                                 
   36    17        INIT_FCALL                                               'print_r'
         18        NEW                                              $6      'ClassWithInitializedTypedProperty'
         19        DO_FCALL                                      0          
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
   38    22        INIT_FCALL                                               'printf'
         23        SEND_VAL                                                 '%0A---+Traditional+Untyped+Property+---%0A'
         24        DO_ICALL                                                 
   39    25        INIT_FCALL                                               'print_r'
         26        NEW                                              $10     'ClassWithTraditionalProperty'
         27        DO_FCALL                                      0          
         28        SEND_VAR                                                 $10
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

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

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0cT8r
function name:  __set
number of ops:  7
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 'UNEXPECTED+SETTING+OF+%25s%0A'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   14     6      > RETURN                                                   null

End of function __set

End of class NumberSettingConstructor.

Class ClassWithTypedProperty: [no user functions]
Class ClassWithInitializedTypedProperty: [no user functions]
Class ClassWithTraditionalProperty: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
302.69 ms | 1017 KiB | 16 Q