diff --git a/UPGRADING b/UPGRADING index e3c3eed5976..3b02ec4bf3f 100644 --- a/UPGRADING +++ b/UPGRADING @@ -48,6 +48,16 @@ PHP 8.2 UPGRADE NOTES ======================================== - Core: + . Creation of dynamic properties is deprecated, unless the class opts in by + using the #[AllowDynamicProperties] attribute. stdClass allows dynamic + properties. Usage of __get()/__set() is not affected by this change. A + dynamic properties deprecation warning can be addressed by: + - Declaring the property (preferred). + - Adding the #[AllowDynamicProperties] attribute to the class (which also + applies to all child classes). + - Using a WeakMap if you wish to associate additional data with an object + you do not own. + . Callables that are not accepted by the $callable() syntax (but are accepted by call_user_func) are deprecated. In particular: diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 71aefe04a82..be82c5aba91 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -1101,7 +1101,9 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o /* Don't try to propagate assignments to (potentially) typed properties. We would * need to deal with errors and type conversions first. */ - if (!var_info->ce || (var_info->ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS)) { + // TODO: Distinguish dynamic and declared property assignments here? + if (!var_info->ce || (var_info->ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS) || + !(var_info->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { SET_RESULT_BOT(result); SET_RESULT_BOT(op1); return; diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 9d06fee7f7f..92958baf22b 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -4842,15 +4842,17 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op return 1; } - if (op_array->scope != ce && ce->default_properties_count) { - zend_property_info *prop_info = - zend_hash_find_ptr(&ce->properties_info, prop_name); - if (prop_info && (!(prop_info->flags & ZEND_ACC_PUBLIC) - || ZEND_TYPE_IS_SET(prop_info->type))) { + zend_property_info *prop_info = + zend_hash_find_ptr(&ce->properties_info, prop_name); + if (prop_info) { + if (ZEND_TYPE_IS_SET(prop_info->type)) { return 1; } + return !(prop_info->flags & ZEND_ACC_PUBLIC) + && prop_info->ce != op_array->scope; + } else { + return !(ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES); } - return 0; } return 1; case ZEND_ROPE_INIT: diff --git a/Zend/tests/allow_dynamic_properties_on_interface.phpt b/Zend/tests/allow_dynamic_properties_on_interface.phpt new file mode 100644 index 00000000000..1d9bb4b89c2 --- /dev/null +++ b/Zend/tests/allow_dynamic_properties_on_interface.phpt @@ -0,0 +1,11 @@ +--TEST-- +#[AllowDynamicProperties] cannot be applied to interface +--FILE-- + +--EXPECTF-- +Fatal error: Cannot apply #[AllowDynamicProperties] to interface in %s on line %d diff --git a/Zend/tests/allow_dynamic_properties_on_trait.phpt b/Zend/tests/allow_dynamic_properties_on_trait.phpt new file mode 100644 index 00000000000..4bceee03807 --- /dev/null +++ b/Zend/tests/allow_dynamic_properties_on_trait.phpt @@ -0,0 +1,11 @@ +--TEST-- +#[AllowDynamicProperties] cannot be applied to trait +--FILE-- + +--EXPECTF-- +Fatal error: Cannot apply #[AllowDynamicProperties] to trait in %s on line %d diff --git a/Zend/tests/anon/003.phpt b/Zend/tests/anon/003.phpt index e4c3f7cc03b..c6a7390fac7 100644 --- a/Zend/tests/anon/003.phpt +++ b/Zend/tests/anon/003.phpt @@ -4,7 +4,7 @@ reusing anonymous classes i = $i; } diff --git a/Zend/tests/assign_to_obj_001.phpt b/Zend/tests/assign_to_obj_001.phpt index a4eb7c0141b..5b0c11b7446 100644 --- a/Zend/tests/assign_to_obj_001.phpt +++ b/Zend/tests/assign_to_obj_001.phpt @@ -8,6 +8,7 @@ function &a($i) { } class A { + public $a; public function test() { $this->a = a(1); unset($this->a); diff --git a/Zend/tests/bug27268.phpt b/Zend/tests/bug27268.phpt index a86e8d0297a..47301068d84 100644 --- a/Zend/tests/bug27268.phpt +++ b/Zend/tests/bug27268.phpt @@ -2,6 +2,7 @@ Bug #27268 (Bad references accentuated by clone) --FILE-- A = $A; - } + public function __construct(public $A) {} public function __destruct() { diff --git a/Zend/tests/bug49893.phpt b/Zend/tests/bug49893.phpt index adab4421ddc..0832b0b0ef4 100644 --- a/Zend/tests/bug49893.phpt +++ b/Zend/tests/bug49893.phpt @@ -12,6 +12,7 @@ class A { } } class B { + public $a; function __construct() { $this->a = new A(); throw new Exception("1"); diff --git a/Zend/tests/bug51822.phpt b/Zend/tests/bug51822.phpt index 0a3813b2f14..6bfacf8d5e7 100644 --- a/Zend/tests/bug51822.phpt +++ b/Zend/tests/bug51822.phpt @@ -12,6 +12,7 @@ class DestructableObject class DestructorCreator { + public $test; public function __destruct() { $this->test = new DestructableObject; diff --git a/Zend/tests/bug54268.phpt b/Zend/tests/bug54268.phpt index e4ce5c0e3a7..3567aaa6ee5 100644 --- a/Zend/tests/bug54268.phpt +++ b/Zend/tests/bug54268.phpt @@ -20,6 +20,7 @@ class DestructableObject } class DestructorCreator { + public $test; public function __destruct() { $this->test = new DestructableObject; diff --git a/Zend/tests/bug55305.phpt b/Zend/tests/bug55305.phpt index 7f0749a3152..90d4c5b5bc0 100644 --- a/Zend/tests/bug55305.phpt +++ b/Zend/tests/bug55305.phpt @@ -2,6 +2,7 @@ Bug #55305 (ref lost: 1st ref instantiated in class def, 2nd ref made w/o instantiating) --FILE-- x; } } +#[AllowDynamicProperties] class Z extends Y { function __construct() { return ++$this->x; diff --git a/Zend/tests/bug60833.phpt b/Zend/tests/bug60833.phpt index 19cd2a4e53a..e1b8a0a2a3a 100644 --- a/Zend/tests/bug60833.phpt +++ b/Zend/tests/bug60833.phpt @@ -5,8 +5,8 @@ Bug #60833 (self, parent, static behave inconsistently case-sensitive) class A { static $x = "A"; function testit() { - $this->v1 = new sELF; - $this->v2 = new SELF; + var_dump(new sELF); + var_dump(new SELF); } } @@ -14,26 +14,21 @@ class B extends A { static $x = "B"; function testit() { PARENT::testit(); - $this->v3 = new sELF; - $this->v4 = new PARENT; - $this->v4 = STATIC::$x; + var_dump(new sELF); + var_dump(new PARENT); + var_dump(STATIC::$x); } } $t = new B(); $t->testit(); -var_dump($t); ?> ---EXPECTF-- -object(B)#%d (4) { - ["v1"]=> - object(A)#%d (0) { - } - ["v2"]=> - object(A)#%d (0) { - } - ["v3"]=> - object(B)#%d (0) { - } - ["v4"]=> - string(1) "B" +--EXPECT-- +object(A)#2 (0) { } +object(A)#2 (0) { +} +object(B)#2 (0) { +} +object(A)#2 (0) { +} +string(1) "B" diff --git a/Zend/tests/bug63462.phpt b/Zend/tests/bug63462.phpt index 03182224ef5..70e66e305c1 100644 --- a/Zend/tests/bug63462.phpt +++ b/Zend/tests/bug63462.phpt @@ -4,6 +4,7 @@ Test script to verify that magic methods should be called only once when accessi Marco Pivetta --FILE-- message = NULL; diff --git a/Zend/tests/bug64960.phpt b/Zend/tests/bug64960.phpt index 360b5bf7228..6ed010c859a 100644 --- a/Zend/tests/bug64960.phpt +++ b/Zend/tests/bug64960.phpt @@ -31,6 +31,10 @@ $a['waa']; --EXPECTF-- Notice: ob_end_flush(): Failed to delete and flush buffer. No buffer to delete or flush in %sbug64960.php on line 3 +Deprecated: Creation of dynamic property Exception::$_trace is deprecated in %s on line %d + +Deprecated: Creation of dynamic property Exception::$_trace is deprecated in %s on line %d + Fatal error: Uncaught Exception in %sbug64960.php:19 Stack trace: #0 [internal function]: {closure}(8, 'ob_end_clean():...', '%s', 9) diff --git a/Zend/tests/bug65911.phpt b/Zend/tests/bug65911.phpt index cea7cdc1ded..47d4eebc984 100644 --- a/Zend/tests/bug65911.phpt +++ b/Zend/tests/bug65911.phpt @@ -6,6 +6,7 @@ class A {} class B { + public $foo; public function go() { $this->foo = 'bar'; diff --git a/Zend/tests/bug66609.phpt b/Zend/tests/bug66609.phpt index f8c0d9ce67e..0807d1465e7 100644 --- a/Zend/tests/bug66609.phpt +++ b/Zend/tests/bug66609.phpt @@ -10,6 +10,7 @@ class Bar { return $foo->foo; } } +#[AllowDynamicProperties] class Foo { public function __get($x) { global $bar; diff --git a/Zend/tests/bug69446.phpt b/Zend/tests/bug69446.phpt index a82ecb44720..6bc3c700689 100644 --- a/Zend/tests/bug69446.phpt +++ b/Zend/tests/bug69446.phpt @@ -5,6 +5,7 @@ zend.enable_gc = 1 --FILE-- value; }; -var_dump($f->call(new class {})->current()); +var_dump($f->call(new class { + public $value; +})->current()); ?> --EXPECT-- diff --git a/Zend/tests/bug70805.phpt b/Zend/tests/bug70805.phpt index 86653df0e74..65ecd90d0b1 100644 --- a/Zend/tests/bug70805.phpt +++ b/Zend/tests/bug70805.phpt @@ -3,9 +3,11 @@ Bug #70805 (Segmentation faults whilst running Drupal 8 test suite) --FILE-- stub->invoke($invocation); } @@ -77,10 +78,10 @@ $foo->bar($a, $b, $c); --EXPECTF-- Fatal error: Uncaught Error: Class "DoesNotExists" not found in %s:%d Stack trace: -#0 %sbug72101.php(8): {closure}(2, 'MethodCallbackB...', '%s', 8) -#1 %sbug72101.php(27): PHPUnit_Framework_MockObject_Stub_ReturnCallback->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) -#2 %sbug72101.php(19): PHPUnit_Framework_MockObject_Matcher->invoked(Object(PHPUnit_Framework_MockObject_Invocation_Static)) -#3 %sbug72101.php(52): PHPUnit_Framework_MockObject_InvocationMocker->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) -#4 %sbug72101.php(72): Mock_MethodCallbackByReference_7b180d26->bar(0, 0, 0) +#0 %sbug72101.php(%d): {closure}(2, 'MethodCallbackB...', '%s', 8) +#1 %sbug72101.php(%d): PHPUnit_Framework_MockObject_Stub_ReturnCallback->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) +#2 %sbug72101.php(%d): PHPUnit_Framework_MockObject_Matcher->invoked(Object(PHPUnit_Framework_MockObject_Invocation_Static)) +#3 %sbug72101.php(%d): PHPUnit_Framework_MockObject_InvocationMocker->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) +#4 %sbug72101.php(%d): Mock_MethodCallbackByReference_7b180d26->bar(0, 0, 0) #5 {main} - thrown in %sbug72101.php on line 61 + thrown in %sbug72101.php on line %d diff --git a/Zend/tests/bug78010.phpt b/Zend/tests/bug78010.phpt index a9ebc37ef17..82334e78a25 100644 --- a/Zend/tests/bug78010.phpt +++ b/Zend/tests/bug78010.phpt @@ -5,6 +5,7 @@ memory_limit=2G --FILE-- bytes= self::$files[$path]; diff --git a/Zend/tests/bug78379.phpt b/Zend/tests/bug78379.phpt index 0f8d216bd31..850e44d7a5e 100644 --- a/Zend/tests/bug78379.phpt +++ b/Zend/tests/bug78379.phpt @@ -3,10 +3,12 @@ Bug #78379 (Cast to object confuses GC, causes crash) --FILE-- p = (object)["x" => [1]]; } } +#[AllowDynamicProperties] class E { } $e = new E; diff --git a/Zend/tests/bug78379_2.phpt b/Zend/tests/bug78379_2.phpt index b1e7e3527f4..473f430ad8f 100644 --- a/Zend/tests/bug78379_2.phpt +++ b/Zend/tests/bug78379_2.phpt @@ -2,6 +2,7 @@ Bug #78379.2 (Cast to object confuses GC, causes crash) --FILE-- x = [$this]; } diff --git a/Zend/tests/closure_020.phpt b/Zend/tests/closure_020.phpt index 7d98dd2dc6d..55a2a01b257 100644 --- a/Zend/tests/closure_020.phpt +++ b/Zend/tests/closure_020.phpt @@ -5,6 +5,7 @@ Closure 020: Trying to access private property outside class class foo { private $test = 3; + public $a; public function x() { $a = &$this; diff --git a/Zend/tests/closure_026.phpt b/Zend/tests/closure_026.phpt index 0dba62fcb9a..c586a7d71ef 100644 --- a/Zend/tests/closure_026.phpt +++ b/Zend/tests/closure_026.phpt @@ -4,6 +4,7 @@ Closure 026: Assigning a closure object to an array in $this prop = 1; // Deprecated +$obj->prop = 1; // Ok +$obj->prop2 += 1; // Deprecated +$obj->prop2 += 1; // Ok +$obj->prop3++; // Deprecated +$obj->prop3++; // Ok +$obj->prop4[] = 1; // Deprecated +$obj->prop4[] = 1; // Ok +isset($obj->prop5); // Ok +unset($obj->prop6); // Ok + +// stdClass should not throw deprecation. +$obj = new stdClass; +$obj->prop = 1; + +// Classes with #[AllowDynamicProperties] should not throw deprecation. +#[AllowDynamicProperties] +class Test2 {} +class Test3 extends Test2 {} + +$obj = new Test2; +$obj->prop = 1; + +$obj = new Test3; +$obj->prop = 1; + +?> +--EXPECTF-- +Deprecated: Creation of dynamic property Test::$prop is deprecated in %s on line %d + +Deprecated: Creation of dynamic property Test::$prop2 is deprecated in %s on line %d + +Warning: Undefined property: Test::$prop2 in %s on line %d + +Deprecated: Creation of dynamic property Test::$prop3 is deprecated in %s on line %d + +Warning: Undefined property: Test::$prop3 in %s on line %d + +Deprecated: Creation of dynamic property Test::$prop4 is deprecated in %s on line %d diff --git a/Zend/tests/exception_stream_wrapper.phpt b/Zend/tests/exception_stream_wrapper.phpt index 7a70645cc14..4de8274fe0c 100644 --- a/Zend/tests/exception_stream_wrapper.phpt +++ b/Zend/tests/exception_stream_wrapper.phpt @@ -4,6 +4,7 @@ Exception in stream wrapper + __call x= $x; + $x->x = $x; @$x .= "x"; $n = gc_collect_cycles(); echo ".=\t$n\n"; diff --git a/Zend/tests/gc_042.phpt b/Zend/tests/gc_042.phpt index c8dfc0ef861..b56309f1d63 100644 --- a/Zend/tests/gc_042.phpt +++ b/Zend/tests/gc_042.phpt @@ -3,6 +3,7 @@ Object properties HT may need to be removed from nested data --FILE-- gen1 = (function () { yield 1; diff --git a/Zend/tests/get_mangled_object_vars.phpt b/Zend/tests/get_mangled_object_vars.phpt index f9ad008a33c..d8a885e1a6a 100644 --- a/Zend/tests/get_mangled_object_vars.phpt +++ b/Zend/tests/get_mangled_object_vars.phpt @@ -3,6 +3,7 @@ get_mangled_object_vars() function --FILE-- {"6"} = 6; var_export(get_mangled_object_vars($obj)); echo "\n"; +#[AllowDynamicProperties] class AO extends ArrayObject { private $priv = 1; } diff --git a/Zend/tests/nowdoc.inc b/Zend/tests/nowdoc.inc index c903740e246..d2aa5c4aef1 100644 --- a/Zend/tests/nowdoc.inc +++ b/Zend/tests/nowdoc.inc @@ -4,7 +4,7 @@ $a = 1; $b = 2; $c = array( 'c' => 3, ); -class d { public function __construct() { $this->d = 4; } }; +class d { public $d = 4; }; $d = new d; ?> diff --git a/Zend/tests/temporary_cleaning_013.phpt b/Zend/tests/temporary_cleaning_013.phpt index ce121d03e88..e5f4b73bb14 100644 --- a/Zend/tests/temporary_cleaning_013.phpt +++ b/Zend/tests/temporary_cleaning_013.phpt @@ -77,6 +77,7 @@ try { try { var_dump((function() { return new class { + public $foo; function __construct() { $this->foo = new stdClass; } function __destruct() { throw new Exception; } }; })()->foo++); @@ -92,6 +93,7 @@ try { try { var_dump((function() { return new class { + public $bar; function __construct() { $this->bar = new stdClass; } function &__get($x) { return $this->bar; } function __destruct() { throw new Exception; } @@ -115,6 +117,7 @@ try { try { var_dump(++(function() { return new class { + public $bar; function __construct() { $this->bar = new stdClass; } function &__get($x) { return $this->bar; } function __destruct() { throw new Exception; } @@ -143,6 +146,7 @@ try { try { var_dump((new class { + public $foo; function __construct() { $this->foo = new stdClass; } function __destruct() { throw new Exception; } })->foo); @@ -168,6 +172,7 @@ try { try { var_dump(isset((new class { + public $foo; function __construct() { $this->foo = new stdClass; } function __destruct() { throw new Exception; } })->foo->bar)); @@ -278,14 +283,22 @@ caught Exception 2 caught Exception 3 caught Exception 4 caught Exception 5 + +Deprecated: Creation of dynamic property class@anonymous::$foo is deprecated in %s on line %d caught Exception 6 caught Exception 7 caught Exception 8 caught Exception 9 caught Exception 10 + +Deprecated: Creation of dynamic property class@anonymous::$foo is deprecated in %s on line %d caught Exception 11 + +Deprecated: Creation of dynamic property class@anonymous::$foo is deprecated in %s on line %d caught Exception 12 caught Exception 13 + +Deprecated: Creation of dynamic property class@anonymous::$foo is deprecated in %s on line %d caught Exception 14 Notice: Indirect modification of overloaded element of ArrayAccess@anonymous has no effect in %s on line %d diff --git a/Zend/tests/throwing_overloaded_compound_assign_op.phpt b/Zend/tests/throwing_overloaded_compound_assign_op.phpt index e6e79baf5dd..39c38627076 100644 --- a/Zend/tests/throwing_overloaded_compound_assign_op.phpt +++ b/Zend/tests/throwing_overloaded_compound_assign_op.phpt @@ -3,6 +3,7 @@ Exception in compound assign op should prevent call to overloaded object handler --FILE-- $k = 42; diff --git a/Zend/tests/type_declarations/typed_properties_086.phpt b/Zend/tests/type_declarations/typed_properties_086.phpt index 7c160dd9d05..5a6b19ad5c8 100644 --- a/Zend/tests/type_declarations/typed_properties_086.phpt +++ b/Zend/tests/type_declarations/typed_properties_086.phpt @@ -3,6 +3,7 @@ Test typed properties with integer keys --FILE-- ce_flags & ZEND_ACC_TRAIT) { + zend_error_noreturn(E_ERROR, "Cannot apply #[AllowDynamicProperties] to trait"); + } + if (scope->ce_flags & ZEND_ACC_INTERFACE) { + zend_error_noreturn(E_ERROR, "Cannot apply #[AllowDynamicProperties] to interface"); + } + scope->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; +} + ZEND_METHOD(Attribute, __construct) { zend_long flags = ZEND_ATTRIBUTE_TARGET_ALL; @@ -73,6 +86,11 @@ ZEND_METHOD(ReturnTypeWillChange, __construct) ZEND_PARSE_PARAMETERS_NONE(); } +ZEND_METHOD(AllowDynamicProperties, __construct) +{ + ZEND_PARSE_PARAMETERS_NONE(); +} + static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset) { if (attributes) { @@ -288,6 +306,10 @@ void zend_register_attribute_ce(void) zend_ce_return_type_will_change_attribute = register_class_ReturnTypeWillChange(); zend_internal_attribute_register(zend_ce_return_type_will_change_attribute, ZEND_ATTRIBUTE_TARGET_METHOD); + + zend_ce_allow_dynamic_properties = register_class_AllowDynamicProperties(); + attr = zend_internal_attribute_register(zend_ce_allow_dynamic_properties, ZEND_ATTRIBUTE_TARGET_CLASS); + attr->validator = validate_allow_dynamic_properties; } void zend_attributes_shutdown(void) diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index fa21896447f..a55dc562450 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -40,6 +40,7 @@ BEGIN_EXTERN_C() extern ZEND_API zend_class_entry *zend_ce_attribute; +extern ZEND_API zend_class_entry *zend_ce_allow_dynamic_properties; typedef struct { zend_string *name; diff --git a/Zend/zend_attributes.stub.php b/Zend/zend_attributes.stub.php index 70b0c49aeb9..0469016704b 100644 --- a/Zend/zend_attributes.stub.php +++ b/Zend/zend_attributes.stub.php @@ -13,3 +13,8 @@ final class ReturnTypeWillChange { public function __construct() {} } + +final class AllowDynamicProperties +{ + public function __construct() {} +} diff --git a/Zend/zend_attributes_arginfo.h b/Zend/zend_attributes_arginfo.h index 5f62eb8fd05..657ab924c74 100644 --- a/Zend/zend_attributes_arginfo.h +++ b/Zend/zend_attributes_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3fd949e1b9f49666bed3081ed1e8e711acd9f49c */ + * Stub hash: 024e849a9dfa8789f13dd1d2ac222a48e4b017f1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Attribute___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "Attribute::TARGET_ALL") @@ -8,9 +8,12 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReturnTypeWillChange___construct, 0, 0, 0) ZEND_END_ARG_INFO() +#define arginfo_class_AllowDynamicProperties___construct arginfo_class_ReturnTypeWillChange___construct + ZEND_METHOD(Attribute, __construct); ZEND_METHOD(ReturnTypeWillChange, __construct); +ZEND_METHOD(AllowDynamicProperties, __construct); static const zend_function_entry class_Attribute_methods[] = { @@ -24,6 +27,12 @@ static const zend_function_entry class_ReturnTypeWillChange_methods[] = { ZEND_FE_END }; + +static const zend_function_entry class_AllowDynamicProperties_methods[] = { + ZEND_ME(AllowDynamicProperties, __construct, arginfo_class_AllowDynamicProperties___construct, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + static zend_class_entry *register_class_Attribute(void) { zend_class_entry ce, *class_entry; @@ -51,3 +60,14 @@ static zend_class_entry *register_class_ReturnTypeWillChange(void) return class_entry; } + +static zend_class_entry *register_class_AllowDynamicProperties(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "AllowDynamicProperties", class_AllowDynamicProperties_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL; + + return class_entry; +} diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 89475235d81..529ade072aa 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -19,6 +19,7 @@ #include "zend.h" #include "zend_API.h" +#include "zend_attributes.h" #include "zend_gc.h" #include "zend_builtin_functions.h" #include "zend_constants.h" @@ -33,10 +34,12 @@ /* }}} */ ZEND_MINIT_FUNCTION(core) { /* {{{ */ - zend_standard_class_def = register_class_stdClass(); - zend_register_default_classes(); + zend_standard_class_def = register_class_stdClass(); + zend_add_class_attribute(zend_standard_class_def, zend_ce_allow_dynamic_properties->name, 0); + zend_standard_class_def->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES; + return SUCCESS; } /* }}} */ diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 531a072cf7b..65d675d77f3 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -240,7 +240,7 @@ typedef struct _zend_oparray_context { /* or IS_CONSTANT_VISITED_MARK | | | */ #define ZEND_CLASS_CONST_IS_CASE (1 << 6) /* | | | X */ /* | | | */ -/* Class Flags (unused: 15,16,21,30,31) | | | */ +/* Class Flags (unused: 16,21,30,31) | | | */ /* =========== | | | */ /* | | | */ /* Special class types | | | */ @@ -269,6 +269,10 @@ typedef struct _zend_oparray_context { /* User class has methods with static variables | | | */ #define ZEND_HAS_STATIC_IN_METHODS (1 << 14) /* X | | | */ /* | | | */ +/* Objects of this class may have dynamic properties | | | */ +/* without triggering a deprecation warning | | | */ +#define ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES (1 << 15) /* X | | | */ +/* | | | */ /* Parent class is resolved (CE). | | | */ #define ZEND_ACC_RESOLVED_PARENT (1 << 17) /* X | | | */ /* | | | */ diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 55d67a59144..eab874d71e6 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1588,7 +1588,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; } } - ce->ce_flags |= parent_ce->ce_flags & (ZEND_HAS_STATIC_IN_METHODS | ZEND_ACC_HAS_TYPE_HINTS | ZEND_ACC_USE_GUARDS | ZEND_ACC_NOT_SERIALIZABLE); + ce->ce_flags |= parent_ce->ce_flags & (ZEND_HAS_STATIC_IN_METHODS | ZEND_ACC_HAS_TYPE_HINTS | ZEND_ACC_USE_GUARDS | ZEND_ACC_NOT_SERIALIZABLE | ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES); } /* }}} */ diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 4f4efb2e3aa..dab57807796 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -277,6 +277,12 @@ static ZEND_COLD zend_never_inline void zend_forbidden_dynamic_property( ZSTR_VAL(ce->name), ZSTR_VAL(member)); } +static ZEND_COLD zend_never_inline void zend_deprecated_dynamic_property( + zend_class_entry *ce, zend_string *member) { + zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated", + ZSTR_VAL(ce->name), ZSTR_VAL(member)); +} + static ZEND_COLD zend_never_inline void zend_readonly_property_modification_scope_error( zend_class_entry *ce, zend_string *member, zend_class_entry *scope, const char *operation) { zend_throw_error(NULL, "Cannot %s readonly property %s::$%s from %s%s", @@ -874,6 +880,9 @@ write_std_property: variable_ptr = &EG(error_zval); goto exit; } + if (UNEXPECTED(!(zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES))) { + zend_deprecated_dynamic_property(zobj->ce, name); + } Z_TRY_ADDREF_P(value); if (!zobj->properties) { @@ -1050,6 +1059,9 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam zend_forbidden_dynamic_property(zobj->ce, name); return &EG(error_zval); } + if (UNEXPECTED(!(zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES))) { + zend_deprecated_dynamic_property(zobj->ce, name); + } if (UNEXPECTED(!zobj->properties)) { rebuild_object_properties(zobj); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index bf12c06df7b..65f17983fb0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2422,7 +2422,7 @@ ZEND_VM_C_LABEL(fast_assign_obj): } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index f2d73fd451d..797ac66c96d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -22924,7 +22924,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -23055,7 +23055,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -23186,7 +23186,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -23317,7 +23317,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -25482,7 +25482,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -25613,7 +25613,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -25744,7 +25744,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -25875,7 +25875,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -29407,7 +29407,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -29538,7 +29538,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -29669,7 +29669,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -29800,7 +29800,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -31862,7 +31862,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -31993,7 +31993,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -32124,7 +32124,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -32255,7 +32255,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -33724,7 +33724,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -33855,7 +33855,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -33986,7 +33986,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -34117,7 +34117,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -36203,7 +36203,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -36334,7 +36334,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -36465,7 +36465,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -36596,7 +36596,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -40346,7 +40346,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -40477,7 +40477,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -40608,7 +40608,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -40739,7 +40739,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -43986,7 +43986,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -44117,7 +44117,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -44248,7 +44248,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -44379,7 +44379,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -49028,7 +49028,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -49159,7 +49159,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -49290,7 +49290,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } @@ -49421,7 +49421,7 @@ fast_assign_obj: } } - if (!zobj->ce->__set) { + if (!zobj->ce->__set && (zobj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) { if (EXPECTED(zobj->properties == NULL)) { rebuild_object_properties(zobj); } diff --git a/ext/date/tests/DateTimeZone_clone_basic3.phpt b/ext/date/tests/DateTimeZone_clone_basic3.phpt index 5f853337898..c5e8761c852 100644 --- a/ext/date/tests/DateTimeZone_clone_basic3.phpt +++ b/ext/date/tests/DateTimeZone_clone_basic3.phpt @@ -37,6 +37,10 @@ object(DateTimeZone)#%d (2) { } -- Add some properties -- + +Deprecated: Creation of dynamic property DateTimeZone::$property1 is deprecated in %s on line %d + +Deprecated: Creation of dynamic property DateTimeZone::$property2 is deprecated in %s on line %d object(DateTimeZone)#%d (4) { ["property1"]=> int(99) @@ -61,6 +65,10 @@ object(DateTimeZone)#%d (4) { } -- Add some more properties -- + +Deprecated: Creation of dynamic property DateTimeZone::$property3 is deprecated in %s on line %d + +Deprecated: Creation of dynamic property DateTimeZone::$property4 is deprecated in %s on line %d object(DateTimeZone)#%d (6) { ["property1"]=> int(99) diff --git a/ext/date/tests/DateTime_clone_basic3.phpt b/ext/date/tests/DateTime_clone_basic3.phpt index dd7220799d3..c57d829fc62 100644 --- a/ext/date/tests/DateTime_clone_basic3.phpt +++ b/ext/date/tests/DateTime_clone_basic3.phpt @@ -39,6 +39,10 @@ object(DateTime)#%d (3) { } -- Add some properties -- + +Deprecated: Creation of dynamic property DateTime::$property1 is deprecated in %s on line %d + +Deprecated: Creation of dynamic property DateTime::$property2 is deprecated in %s on line %d object(DateTime)#%d (5) { ["property1"]=> int(99) @@ -67,6 +71,10 @@ object(DateTime)#%d (5) { } -- Add some more properties -- + +Deprecated: Creation of dynamic property DateTime::$property3 is deprecated in %s on line %d + +Deprecated: Creation of dynamic property DateTime::$property4 is deprecated in %s on line %d object(DateTime)#%d (7) { ["property1"]=> int(99) diff --git a/ext/date/tests/bug65672.phpt b/ext/date/tests/bug65672.phpt index a01287d9b4c..a3a4542e69d 100644 --- a/ext/date/tests/bug65672.phpt +++ b/ext/date/tests/bug65672.phpt @@ -32,7 +32,7 @@ $period->dynamic3[] = "array"; var_dump($period->dynamic3); ?> ---EXPECT-- +--EXPECTF-- string(5) "stuff" string(8) "modified" array(1) { @@ -40,11 +40,17 @@ array(1) { string(5) "array" } bool(false) + +Deprecated: Creation of dynamic property DatePeriod@anonymous::$dynamic1 is deprecated in %s on line %d string(7) "dynamic" + +Deprecated: Creation of dynamic property DatePeriod@anonymous::$dynamic2 is deprecated in %s on line %d array(1) { [0]=> string(5) "array" } + +Deprecated: Creation of dynamic property DatePeriod@anonymous::$dynamic3 is deprecated in %s on line %d array(1) { [0]=> string(5) "array" diff --git a/ext/date/tests/call_function_from_method.phpt b/ext/date/tests/call_function_from_method.phpt index 7cbe68481e2..de49b06839b 100644 --- a/ext/date/tests/call_function_from_method.phpt +++ b/ext/date/tests/call_function_from_method.phpt @@ -6,6 +6,8 @@ date.timezone=UTC date = date_create($in); } diff --git a/ext/date/tests/date_interval_prop_dim.phpt b/ext/date/tests/date_interval_prop_dim.phpt index 5d33badebed..6b5423d1373 100644 --- a/ext/date/tests/date_interval_prop_dim.phpt +++ b/ext/date/tests/date_interval_prop_dim.phpt @@ -12,5 +12,6 @@ while ($i < 1026) { } ?> ==NOCRASH== ---EXPECT-- +--EXPECTF-- +Deprecated: Creation of dynamic property Z::$prop is deprecated in %s on line %d ==NOCRASH== diff --git a/ext/dom/tests/domobject_debug_handler.phpt b/ext/dom/tests/domobject_debug_handler.phpt index 8dbaa61a165..8318fc70ed1 100644 --- a/ext/dom/tests/domobject_debug_handler.phpt +++ b/ext/dom/tests/domobject_debug_handler.phpt @@ -15,6 +15,7 @@ $d->loadXML($xml); print_r($d); ?> --EXPECTF-- +Deprecated: Creation of dynamic property DOMDocument::$dynamicProperty is deprecated in %s on line %d DOMDocument Object ( [config] => diff --git a/ext/exif/tests/bug68799.phpt b/ext/exif/tests/bug68799.phpt index edd8eba8a0d..be26275007f 100644 --- a/ext/exif/tests/bug68799.phpt +++ b/ext/exif/tests/bug68799.phpt @@ -8,6 +8,7 @@ exif * Pollute the heap. Helps trigger bug. Sometimes not needed. */ class A { + public $a; function __construct() { $a = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa'; $this->a = $a . $a . $a . $a . $a . $a; diff --git a/ext/gmp/tests/serialize.phpt b/ext/gmp/tests/serialize.phpt index 4b42db7606d..65c2f34e13d 100644 --- a/ext/gmp/tests/serialize.phpt +++ b/ext/gmp/tests/serialize.phpt @@ -51,6 +51,8 @@ object(GMP)#%d (1) { ["num"]=> string(2) "42" } + +Deprecated: Creation of dynamic property GMP::$foo is deprecated in %s on line %d string(56) "O:3:"GMP":2:{i:0;s:1:"d";i:1;a:1:{s:3:"foo";s:3:"bar";}}" object(GMP)#%d (2) { ["foo"]=> diff --git a/ext/json/tests/bug42785.phpt b/ext/json/tests/bug42785.phpt index 698f193a708..49a301c7074 100644 --- a/ext/json/tests/bug42785.phpt +++ b/ext/json/tests/bug42785.phpt @@ -15,8 +15,7 @@ setlocale(LC_ALL, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1") $foo = array(100.10,"bar"); var_dump(json_encode($foo)); -class bar {} -$bar1 = new bar; +$bar1 = new stdClass; $bar1->a = 100.10; $bar1->b = "foo"; var_dump(json_encode($bar1)); diff --git a/ext/json/tests/json_encode_basic.phpt b/ext/json/tests/json_encode_basic.phpt index b8c2e328d9b..43e7a0391dd 100644 --- a/ext/json/tests/json_encode_basic.phpt +++ b/ext/json/tests/json_encode_basic.phpt @@ -12,10 +12,7 @@ unset ($unset_var); $fp = fopen(__FILE__, "r"); // get an object -class sample { -} - -$obj = new sample(); +$obj = new stdClass(); $obj->MyInt = 99; $obj->MyFloat = 123.45; $obj->MyBool = true; diff --git a/ext/json/tests/json_encode_pretty_print2.phpt b/ext/json/tests/json_encode_pretty_print2.phpt index e872852a38d..f182fb559e1 100644 --- a/ext/json/tests/json_encode_pretty_print2.phpt +++ b/ext/json/tests/json_encode_pretty_print2.phpt @@ -2,6 +2,7 @@ json_encode() with JSON_PRETTY_PRINT on declared properties --FILE-- resolveExternals = true; diff --git a/ext/libxml/tests/bug61367-read_2.phpt b/ext/libxml/tests/bug61367-read_2.phpt index 8adad1ce429..92f1829a44d 100644 --- a/ext/libxml/tests/bug61367-read_2.phpt +++ b/ext/libxml/tests/bug61367-read_2.phpt @@ -14,6 +14,8 @@ open_basedir=. * Note: Using error_reporting=E_ALL & ~E_NOTICE to suppress "Trying to get property of non-object" notices. */ class StreamExploiter { + public $context; + public function stream_close ( ) { $doc = new DOMDocument; $doc->resolveExternals = true; diff --git a/ext/libxml/tests/bug61367-write.phpt b/ext/libxml/tests/bug61367-write.phpt index 47ab33870e7..c65341e1972 100644 --- a/ext/libxml/tests/bug61367-write.phpt +++ b/ext/libxml/tests/bug61367-write.phpt @@ -8,6 +8,8 @@ open_basedir=. appendChild($doc->createTextNode('hello')); diff --git a/ext/mysqli/tests/bug46614.phpt b/ext/mysqli/tests/bug46614.phpt index 1d2a4610e01..34c03585dfb 100644 --- a/ext/mysqli/tests/bug46614.phpt +++ b/ext/mysqli/tests/bug46614.phpt @@ -13,6 +13,7 @@ if (!defined("MYSQLI_ASYNC")) { + NULL + ["label"]=> + NULL ["a"]=> NULL ["b"]=> diff --git a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt index 86ddb9a04c7..2ddba280f43 100644 --- a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt @@ -49,7 +49,8 @@ require_once('skipifconnectfailure.inc'); } class mysqli_fetch_object_test { - + public $ID; + public $label; public $a = null; public $b = null; diff --git a/ext/opcache/tests/jit/fetch_obj_003.phpt b/ext/opcache/tests/jit/fetch_obj_003.phpt index d1dc873c76e..97a7c05e075 100644 --- a/ext/opcache/tests/jit/fetch_obj_003.phpt +++ b/ext/opcache/tests/jit/fetch_obj_003.phpt @@ -9,6 +9,7 @@ opcache.jit_buffer_size=1M opcache --FILE-- prop = PHP_INT_MAX - 5; diff --git a/ext/opcache/tests/opt/dce_005.phpt b/ext/opcache/tests/opt/dce_005.phpt index 7c90a971505..add703e966a 100644 --- a/ext/opcache/tests/opt/dce_005.phpt +++ b/ext/opcache/tests/opt/dce_005.phpt @@ -10,6 +10,7 @@ opcache.preload= opcache --FILE-- prepare('SELECT classtypes.name, test.id AS id, test.val AS val FRO class Test1 { + public $id; + public $val; + public function __construct() { echo __METHOD__ . "()\n"; @@ -37,6 +40,9 @@ class Test1 class Test2 { + public $id; + public $val; + public function __construct() { echo __METHOD__ . "()\n"; @@ -45,6 +51,9 @@ class Test2 class Test3 { + public $id; + public $val; + public function __construct() { echo __METHOD__ . "()\n"; diff --git a/ext/pdo/tests/pdo_010.phpt b/ext/pdo/tests/pdo_010.phpt index 3c78f8df4f0..1d47741b386 100644 --- a/ext/pdo/tests/pdo_010.phpt +++ b/ext/pdo/tests/pdo_010.phpt @@ -29,6 +29,9 @@ $stmt = $db->prepare('SELECT classtypes.name, test.grp AS grp, test.id AS id, te class Test1 { + public $id; + public $val; + public function __construct() { echo __METHOD__ . "()\n"; @@ -37,6 +40,9 @@ class Test1 class Test2 { + public $id; + public $val; + public function __construct() { echo __METHOD__ . "()\n"; @@ -45,6 +51,9 @@ class Test2 class Test3 { + public $id; + public $val; + public function __construct() { echo __METHOD__ . "()\n"; diff --git a/ext/pdo/tests/pdo_011.phpt b/ext/pdo/tests/pdo_011.phpt index d9d1b304e4c..53bf34d442a 100644 --- a/ext/pdo/tests/pdo_011.phpt +++ b/ext/pdo/tests/pdo_011.phpt @@ -23,9 +23,8 @@ $db->exec('INSERT INTO test VALUES(4, \'D\', \'Group2\')'); class DerivedStatement extends PDOStatement { - private function __construct($name, $db) + private function __construct(public $name, $db) { - $this->name = $name; echo __METHOD__ . "($name)\n"; } @@ -41,11 +40,9 @@ $derived = $db->prepare('SELECT id, val FROM test', array(PDO::ATTR_STATEMENT_CL class Test1 { - public function __construct($id, $val) + public function __construct(public $id, public $val) { echo __METHOD__ . "($id,$val)\n"; - $this->id = $id; - $this->val = $val; } static public function factory($id, $val) diff --git a/ext/pdo/tests/pdo_012.phpt b/ext/pdo/tests/pdo_012.phpt index 956a3144cc6..9c5cf51d24f 100644 --- a/ext/pdo/tests/pdo_012.phpt +++ b/ext/pdo/tests/pdo_012.phpt @@ -26,6 +26,9 @@ var_dump($stmt->fetchAll()); class Test { + public $val; + public $grp; + function __construct($name = 'N/A') { echo __METHOD__ . "($name)\n"; diff --git a/ext/pdo/tests/pdo_013.phpt b/ext/pdo/tests/pdo_013.phpt index d3946a019b6..df43d20527f 100644 --- a/ext/pdo/tests/pdo_013.phpt +++ b/ext/pdo/tests/pdo_013.phpt @@ -32,6 +32,9 @@ foreach ($stmt as $data) class Test { + public $val; + public $grp; + function __construct($name = 'N/A') { echo __METHOD__ . "($name)\n"; diff --git a/ext/pdo/tests/pdo_014.phpt b/ext/pdo/tests/pdo_014.phpt index c864c74a2dd..d607481e92c 100644 --- a/ext/pdo/tests/pdo_014.phpt +++ b/ext/pdo/tests/pdo_014.phpt @@ -22,6 +22,9 @@ $SELECT = 'SELECT val, grp FROM test'; class Test { + public $val; + public $grp; + function __construct($name = 'N/A') { echo __METHOD__ . "($name)\n"; diff --git a/ext/pdo/tests/pdo_023.phpt b/ext/pdo/tests/pdo_023.phpt index 8e07840f19f..b2356c13445 100644 --- a/ext/pdo/tests/pdo_023.phpt +++ b/ext/pdo/tests/pdo_023.phpt @@ -14,6 +14,7 @@ PDOTest::skip(); if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; +#[AllowDynamicProperties] class PDOStatementX extends PDOStatement { public $test1 = 1; @@ -31,6 +32,7 @@ class PDOStatementX extends PDOStatement } } +#[AllowDynamicProperties] class PDODatabaseX extends PDO { public $test1 = 1; diff --git a/ext/pdo_mysql/tests/bug46292.phpt b/ext/pdo_mysql/tests/bug46292.phpt index 156be1faf2d..8664df7ddeb 100644 --- a/ext/pdo_mysql/tests/bug46292.phpt +++ b/ext/pdo_mysql/tests/bug46292.phpt @@ -15,6 +15,8 @@ MySQLPDOTest::skip(); class myclass { + public $value; + public function __construct() { printf("%s()\n", __METHOD__); } diff --git a/ext/pdo_mysql/tests/bug63176.phpt b/ext/pdo_mysql/tests/bug63176.phpt index 3e0e5e02eee..599aaaa67c0 100644 --- a/ext/pdo_mysql/tests/bug63176.phpt +++ b/ext/pdo_mysql/tests/bug63176.phpt @@ -20,6 +20,7 @@ class PDO3 extends PDO { class ModelA { + public $db; public function __construct($h) { var_dump($h); if ($h) { diff --git a/ext/pdo_mysql/tests/bug70862.phpt b/ext/pdo_mysql/tests/bug70862.phpt index e91319b2b9f..95e68896eac 100644 --- a/ext/pdo_mysql/tests/bug70862.phpt +++ b/ext/pdo_mysql/tests/bug70862.phpt @@ -19,6 +19,7 @@ MySQLPDOTest::skip(); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); class HelloWrapper { + public $context; public function stream_open() { return true; } public function stream_eof() { return true; } public function stream_read() { return NULL; } diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt index 9cff31ffea6..5b65c8d5444 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt @@ -14,6 +14,7 @@ MySQLPDOTest::skip(); try { + #[AllowDynamicProperties] class myclass implements Serializable { private static $instance = null; diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt index 54f5826fff5..9f1bbd2d0f6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt @@ -30,6 +30,7 @@ try { $query = "SELECT id, '', NULL, \"\" FROM test ORDER BY id ASC LIMIT 3"; $stmt = $db->prepare($query); + #[AllowDynamicProperties] class myclass { private $set_calls = 0; diff --git a/ext/pdo_pgsql/tests/bug72294.phpt b/ext/pdo_pgsql/tests/bug72294.phpt index 6528c1211a7..8b55b033f61 100644 --- a/ext/pdo_pgsql/tests/bug72294.phpt +++ b/ext/pdo_pgsql/tests/bug72294.phpt @@ -70,6 +70,8 @@ class PHPUnit_Framework_TestFailure class PHPUnit_Framework_TestResult { + private $errors; + public function run( $test) { $error = false; diff --git a/ext/pdo_sqlite/tests/bug46139.phpt b/ext/pdo_sqlite/tests/bug46139.phpt index fabc312634e..7ec94aff0cf 100644 --- a/ext/pdo_sqlite/tests/bug46139.phpt +++ b/ext/pdo_sqlite/tests/bug46139.phpt @@ -8,6 +8,7 @@ pdo_sqlite require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); +#[AllowDynamicProperties] class Person { public $test = NULL; public function __construct() { diff --git a/ext/pdo_sqlite/tests/bug70862.phpt b/ext/pdo_sqlite/tests/bug70862.phpt index eff0f8fb914..5becca7c759 100644 --- a/ext/pdo_sqlite/tests/bug70862.phpt +++ b/ext/pdo_sqlite/tests/bug70862.phpt @@ -14,6 +14,7 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); class HelloWrapper { + public $context; public function stream_open() { return true; } public function stream_eof() { return true; } public function stream_read() { return NULL; } diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt index b10013d2a93..5e35859c7ce 100644 --- a/ext/reflection/tests/002.phpt +++ b/ext/reflection/tests/002.phpt @@ -3,6 +3,7 @@ Reflection properties are read only --FILE-- --EXPECTF-- Object of class [ class C1 ] { - @@ %s024.php 2-6 + @@ %s - Constants [0] { } diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt index f1cac44e958..b5fbf59b439 100644 --- a/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt @@ -58,6 +58,8 @@ array(1) { } } Modify the object, and it is apparently no longer referenced. + +Deprecated: Creation of dynamic property ReflectionClass::$x is deprecated in %s on line %d array(1) { ["I"]=> object(ReflectionClass)#%d (2) { diff --git a/ext/reflection/tests/ReflectionObject___toString_basic2.phpt b/ext/reflection/tests/ReflectionObject___toString_basic2.phpt index e93dd9b331a..4d0a48d9113 100644 --- a/ext/reflection/tests/ReflectionObject___toString_basic2.phpt +++ b/ext/reflection/tests/ReflectionObject___toString_basic2.phpt @@ -3,6 +3,7 @@ ReflectionObject::__toString() : very basic test with dynamic properties --FILE-- --EXPECTF-- Object of class [ class Foo ] { - @@ %s 3-5 + @@ %s - Constants [0] { } diff --git a/ext/reflection/tests/ReflectionObject_export_basic3.phpt b/ext/reflection/tests/ReflectionObject_export_basic3.phpt index 612bfa5916b..9c3d78da6e0 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic3.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic3.phpt @@ -6,6 +6,7 @@ class C { private $p = 1; } +#[AllowDynamicProperties] class D extends C{ } @@ -15,7 +16,7 @@ echo new ReflectionObject($Obj); ?> --EXPECTF-- Object of class [ class D extends C ] { - @@ %s 6-7 + @@ %s - Constants [0] { } diff --git a/ext/reflection/tests/ReflectionParameter_isDefault.phpt b/ext/reflection/tests/ReflectionParameter_isDefault.phpt index ea958781709..3ab0d980fd0 100644 --- a/ext/reflection/tests/ReflectionParameter_isDefault.phpt +++ b/ext/reflection/tests/ReflectionParameter_isDefault.phpt @@ -2,6 +2,7 @@ ReflectionParameter::isDefault() --FILE-- isProtected()); echo "=== 3rd test ===\n"; +#[AllowDynamicProperties] class test3 { } @@ -59,6 +61,7 @@ class test5 { private $value = 1; } +#[AllowDynamicProperties] class test4 extends test5{ } diff --git a/ext/reflection/tests/bug46064.phpt b/ext/reflection/tests/bug46064.phpt index 4a97b3b22a6..c866ee83be7 100644 --- a/ext/reflection/tests/bug46064.phpt +++ b/ext/reflection/tests/bug46064.phpt @@ -3,6 +3,7 @@ Bug #46064 (Exception when creating ReflectionProperty object on dynamicly creat --FILE-- foobar = 2; diff --git a/ext/reflection/tests/bug46064_2.phpt b/ext/reflection/tests/bug46064_2.phpt index f1aac5b5c0e..623b6743a99 100644 --- a/ext/reflection/tests/bug46064_2.phpt +++ b/ext/reflection/tests/bug46064_2.phpt @@ -3,6 +3,7 @@ Bug #46064.2 (Exception when creating ReflectionProperty object on dynamicly cre --FILE-- getProperty('test')); +#[AllowDynamicProperties] class bar { public function __construct() { $this->a = 1; diff --git a/ext/reflection/tests/bug53366.phpt b/ext/reflection/tests/bug53366.phpt index 61493d53020..e2bc250ebfe 100644 --- a/ext/reflection/tests/bug53366.phpt +++ b/ext/reflection/tests/bug53366.phpt @@ -3,6 +3,7 @@ Bug #53366 (Reflection doesn't get dynamic property value from getProperty()) --FILE-- array(3) { diff --git a/ext/soap/tests/bugs/bug39815.phpt b/ext/soap/tests/bugs/bug39815.phpt index 688c995822d..7ad18d3505e 100644 --- a/ext/soap/tests/bugs/bug39815.phpt +++ b/ext/soap/tests/bugs/bug39815.phpt @@ -4,8 +4,7 @@ Bug #39815 (to_zval_double() in ext/soap/php_encoding.c is not locale-independen soap --SKIPIF-- --INI-- precision=14 @@ -16,6 +15,7 @@ function test(){ return 123.456; } class LocalSoapClient extends SoapClient { + private $server; function __construct($wsdl, $options) { parent::__construct($wsdl, $options); @@ -35,10 +35,10 @@ class LocalSoapClient extends SoapClient { $x = new LocalSoapClient(NULL,array('location'=>'test://', 'uri'=>'http://testuri.org', "trace"=>1)); -setlocale(LC_ALL,"sv_SE","sv_SE.ISO8859-1"); +setlocale(LC_ALL,"de_DE","de_DE.ISO8859-1"); var_dump($x->test()); echo $x->__getLastResponse(); -setlocale(LC_ALL,"en_US","en_US.ISO8859-1"); +setlocale(LC_ALL, "C"); var_dump($x->test()); echo $x->__getLastResponse(); ?> diff --git a/ext/spl/tests/ArrayObject_sort_different_backing_storage.phpt b/ext/spl/tests/ArrayObject_sort_different_backing_storage.phpt index 0b9bbd63307..93dd6570791 100644 --- a/ext/spl/tests/ArrayObject_sort_different_backing_storage.phpt +++ b/ext/spl/tests/ArrayObject_sort_different_backing_storage.phpt @@ -28,7 +28,7 @@ $ao5->uasort(function($a, $b) { return $a <=> $b; }); var_dump($ao5); ?> ---EXPECT-- +--EXPECTF-- object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> object(stdClass)#1 (2) { @@ -50,6 +50,10 @@ object(ArrayObject)#3 (1) { } } } + +Deprecated: Creation of dynamic property ArrayObject::$a is deprecated in %s on line %d + +Deprecated: Creation of dynamic property ArrayObject::$b is deprecated in %s on line %d object(ArrayObject)#4 (2) { ["b"]=> int(1) diff --git a/ext/spl/tests/ArrayObject_std_props_no_recursion.phpt b/ext/spl/tests/ArrayObject_std_props_no_recursion.phpt index 193e9725300..55ec57762fa 100644 --- a/ext/spl/tests/ArrayObject_std_props_no_recursion.phpt +++ b/ext/spl/tests/ArrayObject_std_props_no_recursion.phpt @@ -13,7 +13,10 @@ $c->prop = 'c'; var_dump((array) $c); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d + +Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d array(3) { [0]=> int(1) @@ -22,6 +25,8 @@ array(3) { [2]=> int(3) } + +Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d array(1) { ["prop"]=> string(1) "c" diff --git a/ext/spl/tests/SplFileObject_fflush_basic_001.phpt b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt index 2060bd2b433..b399a852008 100644 --- a/ext/spl/tests/SplFileObject_fflush_basic_001.phpt +++ b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt @@ -13,8 +13,9 @@ var_dump($obj->fflush()); */ //create a basic stream class class VariableStream { - var $position; - var $varname; + public $position; + public $varname; + public $context; function stream_open($path, $mode, $options, &$opened_path) { diff --git a/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt index 4e0642c6ae4..a77257cc575 100644 --- a/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt +++ b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt @@ -5,8 +5,9 @@ SplFileObject::ftruncate function - truncating with stream that does not support //create a basic stream class class VariableStream { - var $position; - var $varname; + public $position; + public $varname; + public $context; function stream_open($path, $mode, $options, &$opened_path) { diff --git a/ext/spl/tests/arrayObject___construct_basic2.phpt b/ext/spl/tests/arrayObject___construct_basic2.phpt index 4de31370800..0d993a14e78 100644 --- a/ext/spl/tests/arrayObject___construct_basic2.phpt +++ b/ext/spl/tests/arrayObject___construct_basic2.phpt @@ -54,6 +54,8 @@ function testAccess($c, $ao) { NULL string(12) "C::prop.orig" - Write: + +Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d string(8) "changed1" string(8) "changed2" - Isset: diff --git a/ext/spl/tests/arrayObject___construct_basic3.phpt b/ext/spl/tests/arrayObject___construct_basic3.phpt index 1d6015ce6ac..3fb4dda5a6e 100644 --- a/ext/spl/tests/arrayObject___construct_basic3.phpt +++ b/ext/spl/tests/arrayObject___construct_basic3.phpt @@ -54,6 +54,8 @@ function testAccess($c, $ao) { NULL string(12) "C::prop.orig" - Write: + +Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d string(8) "changed1" string(8) "changed2" - Isset: diff --git a/ext/spl/tests/arrayObject___construct_basic6.phpt b/ext/spl/tests/arrayObject___construct_basic6.phpt index 681e6e0d318..4ba17b6526d 100644 --- a/ext/spl/tests/arrayObject___construct_basic6.phpt +++ b/ext/spl/tests/arrayObject___construct_basic6.phpt @@ -21,7 +21,8 @@ var_dump($ao); $ao = new MyArrayObject(array(1,2,3), ArrayObject::STD_PROP_LIST); var_dump($ao); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Creation of dynamic property ArrayObject::$p is deprecated in %s on line %d object(ArrayObject)#1 (2) { ["p"]=> int(1) @@ -35,6 +36,8 @@ object(ArrayObject)#1 (2) { int(3) } } + +Deprecated: Creation of dynamic property ArrayObject::$p is deprecated in %s on line %d object(ArrayObject)#2 (2) { ["p"]=> int(1) diff --git a/ext/spl/tests/arrayObject_clone_basic2.phpt b/ext/spl/tests/arrayObject_clone_basic2.phpt index 3bcebc7970b..b0a82ccfbc3 100644 --- a/ext/spl/tests/arrayObject_clone_basic2.phpt +++ b/ext/spl/tests/arrayObject_clone_basic2.phpt @@ -2,6 +2,8 @@ SPL: Cloning an instance of ArrayObject which wraps an object. --FILE-- --EXPECTF-- --> Write existent, non-existent and dynamic: + +Deprecated: Creation of dynamic property ArrayObject::$a is deprecated in %s on line %d + +Deprecated: Creation of dynamic property ArrayObject::$dynamic is deprecated in %s on line %d Original wrapped object: object(UsesMagic)#1 (4) { ["a"]=> diff --git a/ext/spl/tests/array_003.phpt b/ext/spl/tests/array_003.phpt index e4c0a1f9f82..3ca23f09dc7 100644 --- a/ext/spl/tests/array_003.phpt +++ b/ext/spl/tests/array_003.phpt @@ -7,6 +7,7 @@ SPL: ArrayObject from object // since they cannot be accessed from the external object which iterates // them. +#[AllowDynamicProperties] class test { public $pub = "public"; diff --git a/ext/spl/tests/array_007.phpt b/ext/spl/tests/array_007.phpt index dc8a9a5bad7..3cdd40a1dbc 100644 --- a/ext/spl/tests/array_007.phpt +++ b/ext/spl/tests/array_007.phpt @@ -7,6 +7,7 @@ SPL: ArrayObject/Iterator from IteratorAggregate // since they cannot be accessed from the external object which iterates // them. +#[AllowDynamicProperties] class test implements IteratorAggregate { public $pub = "public"; diff --git a/ext/spl/tests/array_017.phpt b/ext/spl/tests/array_017.phpt index fb152543d7e..ba4842dce20 100644 --- a/ext/spl/tests/array_017.phpt +++ b/ext/spl/tests/array_017.phpt @@ -3,6 +3,7 @@ SPL: ArrayObject::exchangeArray($this) --FILE-- foo = 'bar'; var_dump($aobj1 == $aobj3); ?> ---EXPECT-- +--EXPECTF-- bool(false) bool(true) + +Deprecated: Creation of dynamic property ArrayObject::$foo is deprecated in %s on line %d bool(false) diff --git a/ext/spl/tests/bug65387.phpt b/ext/spl/tests/bug65387.phpt index 1e3c8fe4d07..243be76e0ec 100644 --- a/ext/spl/tests/bug65387.phpt +++ b/ext/spl/tests/bug65387.phpt @@ -14,6 +14,7 @@ $it2 = new CallbackFilterIterator($it, function($elem) use(&$it2) { // Callback object new class { + private $it; public function __construct() { $it = new ArrayIterator([1, 2, 3]); $this->it = new CallbackFilterIterator($it, function($elem) { diff --git a/ext/spl/tests/iterator_037.phpt b/ext/spl/tests/iterator_037.phpt index baa15f36847..c6c465baa2b 100644 --- a/ext/spl/tests/iterator_037.phpt +++ b/ext/spl/tests/iterator_037.phpt @@ -27,10 +27,7 @@ function test($ar, $flags) class MyItem { - function __construct($value) - { - $this->value = $value; - } + function __construct(public $value) {} function __toString() { diff --git a/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt b/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt index ef165607366..e6c774d6f07 100644 --- a/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt +++ b/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt @@ -13,6 +13,7 @@ $insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (1, ?)"); class HelloWrapper { + public $context; public function stream_open() { return true; } public function stream_eof() { return true; } public function stream_read() { return NULL; } diff --git a/ext/sqlite3/tests/stream_test.inc b/ext/sqlite3/tests/stream_test.inc index 0d53d0f7be2..7017cce4781 100644 --- a/ext/sqlite3/tests/stream_test.inc +++ b/ext/sqlite3/tests/stream_test.inc @@ -2,6 +2,7 @@ class SQLite3_Test_Stream { + public $context; private $position; public static $string_length = 10; public static $string = "abcdefg\0hi"; diff --git a/ext/standard/tests/array/bug39576.phpt b/ext/standard/tests/array/bug39576.phpt index 61600fa5784..3834200bf43 100644 --- a/ext/standard/tests/array/bug39576.phpt +++ b/ext/standard/tests/array/bug39576.phpt @@ -4,10 +4,10 @@ Bug #39576 (array_walk() doesn't separate userdata zval) --EXPECTF-- -Fatal error: Uncaught ArgumentCountError: Too few arguments to function VariableStream::__construct(), 0 passed and exactly 1 expected in %sbug38450_3.php:7 +Fatal error: Uncaught ArgumentCountError: Too few arguments to function VariableStream::__construct(), 0 passed and exactly 1 expected in %sbug38450_3.php:%d Stack trace: #0 [internal function]: VariableStream->__construct() #1 %s(%d): fopen('var://myvar', 'r+') diff --git a/ext/standard/tests/file/bug39551.phpt b/ext/standard/tests/file/bug39551.phpt index c4f148c8623..e6982fcaab1 100644 --- a/ext/standard/tests/file/bug39551.phpt +++ b/ext/standard/tests/file/bug39551.phpt @@ -5,7 +5,7 @@ Bug #39551 (Segfault with stream_bucket_new in user filter) $bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); -class bucketFilter { +class bucketFilter extends php_user_filter { public function filter($in, $out, &$consumed, $closing ): int { $bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); diff --git a/ext/standard/tests/file/bug71287.phpt b/ext/standard/tests/file/bug71287.phpt index f88414f2c28..1824015e056 100644 --- a/ext/standard/tests/file/bug71287.phpt +++ b/ext/standard/tests/file/bug71287.phpt @@ -3,6 +3,8 @@ Bug #71287 (Error message contains hexadecimal instead of decimal number) --FILE-- '; private $pos; private $stream = null; @@ -98,10 +99,10 @@ include "test2://hello"; -Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_include=0 in %sinclude_userstream_002.php on line 10 +Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_include=0 in %sinclude_userstream_002.php on line 11 -Warning: fopen(test1://hello): Failed to open stream: no suitable wrapper could be found in %sinclude_userstream_002.php on line 10 +Warning: fopen(test1://hello): Failed to open stream: no suitable wrapper could be found in %sinclude_userstream_002.php on line 11 -Warning: include(test2://hello): Failed to open stream: "test::stream_open" call failed in %sinclude_userstream_002.php on line 89 +Warning: include(test2://hello): Failed to open stream: "test::stream_open" call failed in %sinclude_userstream_002.php on line 90 -Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %sinclude_userstream_002.php on line 89 +Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %sinclude_userstream_002.php on line 90 diff --git a/ext/standard/tests/file/include_userstream_003.phpt b/ext/standard/tests/file/include_userstream_003.phpt index d71a09fc732..1f2c44821f8 100644 --- a/ext/standard/tests/file/include_userstream_003.phpt +++ b/ext/standard/tests/file/include_userstream_003.phpt @@ -6,6 +6,7 @@ allow_url_include=1 --FILE-- '; private $pos; private $stream = null; @@ -97,28 +98,28 @@ include "test2://hello"; --EXPECTF-- Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 -Warning: file_get_contents(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 86 +Warning: file_get_contents(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %s on line %d -Warning: file_get_contents(test1://hello): Failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 86 +Warning: file_get_contents(test1://hello): Failed to open stream: no suitable wrapper could be found in %s on line %d -Warning: include(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 87 +Warning: include(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %s on line %d -Warning: include(test1://hello): Failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 87 +Warning: include(test1://hello): Failed to open stream: no suitable wrapper could be found in %s on line %d -Warning: include(): Failed opening 'test1://hello' for inclusion (include_path='%s') in %sinclude_userstream_003.php on line 87 +Warning: include(): Failed opening 'test1://hello' for inclusion (include_path='%s') in %s on line %d -Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 10 +Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %s on line %d -Warning: fopen(test1://hello): Failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 10 +Warning: fopen(test1://hello): Failed to open stream: no suitable wrapper could be found in %s on line %d -Warning: file_get_contents(test2://hello): Failed to open stream: "test::stream_open" call failed in %sinclude_userstream_003.php on line 88 +Warning: file_get_contents(test2://hello): Failed to open stream: "test::stream_open" call failed in %s on line %d -Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 10 +Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %s on line %d -Warning: fopen(test1://hello): Failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 10 +Warning: fopen(test1://hello): Failed to open stream: no suitable wrapper could be found in %s on line %d -Warning: include(test2://hello): Failed to open stream: "test::stream_open" call failed in %sinclude_userstream_003.php on line 89 +Warning: include(test2://hello): Failed to open stream: "test::stream_open" call failed in %s on line %d -Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %sinclude_userstream_003.php on line 89 +Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %s on line %d diff --git a/ext/standard/tests/file/userdirstream.phpt b/ext/standard/tests/file/userdirstream.phpt index e2f03dabb7f..eb6db1fb509 100644 --- a/ext/standard/tests/file/userdirstream.phpt +++ b/ext/standard/tests/file/userdirstream.phpt @@ -4,6 +4,7 @@ Directory Streams a = 0; } function __toString() { return $this->a++ ? str_repeat("a", 0x8000) : "a"; } } diff --git a/ext/standard/tests/general_functions/debug_zval_dump_o.phpt b/ext/standard/tests/general_functions/debug_zval_dump_o.phpt index 89ed4a63d21..d4972b9a863 100644 --- a/ext/standard/tests/general_functions/debug_zval_dump_o.phpt +++ b/ext/standard/tests/general_functions/debug_zval_dump_o.phpt @@ -17,6 +17,7 @@ function zval_dump( $values ) { /* checking on objects type */ echo "*** Testing debug_zval_dump() on objects ***\n"; +#[AllowDynamicProperties] class object_class { var $value1 = 1; private $value2 = 10; @@ -45,6 +46,7 @@ class no_member_class{ } /* class with member as object of other class */ +#[AllowDynamicProperties] class contains_object_class { var $p = 30; diff --git a/ext/standard/tests/general_functions/is_object.phpt b/ext/standard/tests/general_functions/is_object.phpt index ed4a2f7a349..6a0123d23eb 100644 --- a/ext/standard/tests/general_functions/is_object.phpt +++ b/ext/standard/tests/general_functions/is_object.phpt @@ -62,7 +62,7 @@ class myClass $this->public_var = 10; $this->public_var1 = new foo(); $this->private_var = new foo(); - $this->proected_var = new foo(); + $this->protected_var = new foo(); } } diff --git a/ext/standard/tests/general_functions/print_r.phpt b/ext/standard/tests/general_functions/print_r.phpt index 112e436d4e7..0ea60658aed 100644 --- a/ext/standard/tests/general_functions/print_r.phpt +++ b/ext/standard/tests/general_functions/print_r.phpt @@ -136,6 +136,7 @@ $arrays = array ( check_printr($arrays); echo "\n*** Testing print_r() on object variables ***\n"; +#[AllowDynamicProperties] class object_class { var $value; @@ -168,6 +169,7 @@ class no_member_class { } /* class with member as object of other class */ +#[AllowDynamicProperties] class contains_object_class { var $p = 30; diff --git a/ext/standard/tests/general_functions/print_r_64bit.phpt b/ext/standard/tests/general_functions/print_r_64bit.phpt index 1d61df4f9f5..6026b959d7c 100644 --- a/ext/standard/tests/general_functions/print_r_64bit.phpt +++ b/ext/standard/tests/general_functions/print_r_64bit.phpt @@ -140,6 +140,7 @@ $arrays = array ( check_printr($arrays); echo "\n*** Testing print_r() on object variables ***\n"; +#[AllowDynamicProperties] class object_class { var $value; @@ -172,6 +173,7 @@ class no_member_class { } /* class with member as object of other class */ +#[AllowDynamicProperties] class contains_object_class { var $p = 30; diff --git a/ext/standard/tests/general_functions/var_dump.phpt b/ext/standard/tests/general_functions/var_dump.phpt index 32f5c9ab393..0cbd1fce9c6 100644 --- a/ext/standard/tests/general_functions/var_dump.phpt +++ b/ext/standard/tests/general_functions/var_dump.phpt @@ -134,6 +134,7 @@ $arrays = array ( check_vardump($arrays); echo "\n*** Testing var_dump() on object variables ***\n"; +#[AllowDynamicProperties] class object_class { var $value; @@ -166,6 +167,7 @@ class no_member_class { } /* class with member as object of other class */ +#[AllowDynamicProperties] class contains_object_class { var $p = 30; diff --git a/ext/standard/tests/general_functions/var_dump_64bit.phpt b/ext/standard/tests/general_functions/var_dump_64bit.phpt index 463308427a3..cbf9c003bdb 100644 --- a/ext/standard/tests/general_functions/var_dump_64bit.phpt +++ b/ext/standard/tests/general_functions/var_dump_64bit.phpt @@ -134,6 +134,7 @@ $arrays = array ( check_vardump($arrays); echo "\n*** Testing var_dump() on object variables ***\n"; +#[AllowDynamicProperties] class object_class { var $value; @@ -166,6 +167,7 @@ class no_member_class { } /* class with member as object of other class */ +#[AllowDynamicProperties] class contains_object_class { var $p = 30; diff --git a/ext/standard/tests/general_functions/var_export-locale_32.phpt b/ext/standard/tests/general_functions/var_export-locale_32.phpt index 4033eff5c37..81ddacb1a35 100644 --- a/ext/standard/tests/general_functions/var_export-locale_32.phpt +++ b/ext/standard/tests/general_functions/var_export-locale_32.phpt @@ -236,7 +236,7 @@ class myClass $this->public_var = 10; $this->public_var1 = new foo(); $this->private_var = new foo(); - $this->proected_var = new foo(); + $this->protected_var = new foo(); } } @@ -961,8 +961,7 @@ myClass::__set_state(array( 'private_var' => foo::__set_state(array( )), - 'protected_var' => NULL, - 'proected_var' => + 'protected_var' => foo::__set_state(array( )), )) @@ -977,12 +976,11 @@ myClass::__set_state(array( 'private_var' => foo::__set_state(array( )), - 'protected_var' => NULL, - 'proected_var' => + 'protected_var' => foo::__set_state(array( )), )) -string(293) "myClass::__set_state(array( +string(266) "myClass::__set_state(array( 'foo_object' => foo::__set_state(array( )), @@ -993,8 +991,7 @@ string(293) "myClass::__set_state(array( 'private_var' => foo::__set_state(array( )), - 'protected_var' => NULL, - 'proected_var' => + 'protected_var' => foo::__set_state(array( )), ))" @@ -1012,8 +1009,7 @@ myClass::__set_state(array( 'private_var' => foo::__set_state(array( )), - 'protected_var' => NULL, - 'proected_var' => + 'protected_var' => foo::__set_state(array( )), )) @@ -1028,12 +1024,11 @@ myClass::__set_state(array( 'private_var' => foo::__set_state(array( )), - 'protected_var' => NULL, - 'proected_var' => + 'protected_var' => foo::__set_state(array( )), )) -string(293) "myClass::__set_state(array( +string(266) "myClass::__set_state(array( 'foo_object' => foo::__set_state(array( )), @@ -1044,8 +1039,7 @@ string(293) "myClass::__set_state(array( 'private_var' => foo::__set_state(array( )), - 'protected_var' => NULL, - 'proected_var' => + 'protected_var' => foo::__set_state(array( )), ))" diff --git a/ext/standard/tests/serialize/001.phpt b/ext/standard/tests/serialize/001.phpt index 147c355b08c..f2ac0340cf0 100644 --- a/ext/standard/tests/serialize/001.phpt +++ b/ext/standard/tests/serialize/001.phpt @@ -4,6 +4,7 @@ serialize()/unserialize()/var_dump() serialize_precision=100 --FILE-- a = 'hello'; diff --git a/ext/standard/tests/serialize/bug36424.phpt b/ext/standard/tests/serialize/bug36424.phpt index 55bc38e94c2..27c18afb5fe 100644 --- a/ext/standard/tests/serialize/bug36424.phpt +++ b/ext/standard/tests/serialize/bug36424.phpt @@ -3,6 +3,7 @@ Bug #36424 - Serializable interface breaks object references --FILE-- constructorCalled = true; diff --git a/ext/standard/tests/streams/bug53903.phpt b/ext/standard/tests/streams/bug53903.phpt index 7ee62ad2dec..01061842422 100644 --- a/ext/standard/tests/streams/bug53903.phpt +++ b/ext/standard/tests/streams/bug53903.phpt @@ -4,6 +4,7 @@ Bug #53903 streamwrapper/stream_stat causes problems - #phparty7 - @phpsp - novatec/2015 - sao p */ final class StreamWrapper { + public $context; public function stream_open( string $path, string $mode, diff --git a/tests/classes/dereferencing_001.phpt b/tests/classes/dereferencing_001.phpt index 4ec2a87659f..d1af58b0a8b 100644 --- a/tests/classes/dereferencing_001.phpt +++ b/tests/classes/dereferencing_001.phpt @@ -4,9 +4,7 @@ ZE2 dereferencing of objects from methods name = $_name; - } + function __construct(public $name) {} function display() { echo $this->name . "\n"; diff --git a/tests/classes/iterators_006.phpt b/tests/classes/iterators_006.phpt index 86c2481b50a..a3e74fdadb6 100644 --- a/tests/classes/iterators_006.phpt +++ b/tests/classes/iterators_006.phpt @@ -6,6 +6,8 @@ ZE2 iterators and array wrapping class ai implements Iterator { private $array; + private $key; + private $current; function __construct() { $this->array = array('foo', 'bar', 'baz'); diff --git a/tests/classes/method_call_variation_001.phpt b/tests/classes/method_call_variation_001.phpt index 5b6b725bc2f..c407f1c942d 100644 --- a/tests/classes/method_call_variation_001.phpt +++ b/tests/classes/method_call_variation_001.phpt @@ -2,7 +2,9 @@ In $a->$b[Y]() and $a->X[Y]() both $a->$b[Y] and $a->X[Y] represent a global function name --FILE-- p = 'changed in D'; @@ -78,7 +79,7 @@ object(C)#%d (1) { Unset a private property, and attempt to recreate at global scope (expecting failure): -Fatal error: Uncaught Error: Cannot access private property C::$p in %s:46 +Fatal error: Uncaught Error: Cannot access private property C::$p in %s:%d Stack trace: #0 {main} - thrown in %s on line 46 + thrown in %s on line %d diff --git a/tests/classes/static_properties_003.phpt b/tests/classes/static_properties_003.phpt index 30a6e2a510b..175b3e0b2c5 100644 --- a/tests/classes/static_properties_003.phpt +++ b/tests/classes/static_properties_003.phpt @@ -2,6 +2,7 @@ Attempting to access static properties using instance property syntax --FILE-- y)); --> Access visible static prop like instance prop: bool(false) -Notice: Accessing static property C::$x as non static in %s on line 11 - Notice: Accessing static property C::$x as non static in %s on line 12 -Warning: Undefined property: C::$x in %s on line %d - Notice: Accessing static property C::$x as non static in %s on line 13 -Notice: Accessing static property C::$x as non static in %s on line 15 +Warning: Undefined property: C::$x in %s on line %d + +Notice: Accessing static property C::$x as non static in %s on line 14 Notice: Accessing static property C::$x as non static in %s on line 16 + +Notice: Accessing static property C::$x as non static in %s on line 17 string(3) "ref" string(5) "C::$x" diff --git a/tests/classes/visibility_005.phpt b/tests/classes/visibility_005.phpt index ac7a2dd35a1..914322a729d 100644 --- a/tests/classes/visibility_005.phpt +++ b/tests/classes/visibility_005.phpt @@ -3,6 +3,7 @@ ZE2 foreach and property visibility --FILE-- Name = $name; diff --git a/tests/lang/035.phpt b/tests/lang/035.phpt index 0292868d7fc..b39dea1875d 100644 --- a/tests/lang/035.phpt +++ b/tests/lang/035.phpt @@ -3,9 +3,7 @@ ZE2: set_exception_handler() --FILE-- error = $_error; - } + function __construct(public $error) {} function getException() { diff --git a/tests/lang/bug22510.phpt b/tests/lang/bug22510.phpt index e79972d29e5..ea48e3b1955 100644 --- a/tests/lang/bug22510.phpt +++ b/tests/lang/bug22510.phpt @@ -2,6 +2,8 @@ Bug #22510 (segfault among complex references) --FILE-- instance = new foo(); diff --git a/tests/lang/bug27439.phpt b/tests/lang/bug27439.phpt index c9f08a0403b..ebbb489b2bf 100644 --- a/tests/lang/bug27439.phpt +++ b/tests/lang/bug27439.phpt @@ -12,6 +12,7 @@ class test_props { class test { public $array = array(1,2,3); public $string = "string"; + public $object; public function __construct() { $this->object = new test_props; diff --git a/tests/lang/error_2_exception_001.phpt b/tests/lang/error_2_exception_001.phpt index 32d85bf1cb1..4dba9b7a121 100644 --- a/tests/lang/error_2_exception_001.phpt +++ b/tests/lang/error_2_exception_001.phpt @@ -4,10 +4,7 @@ ZE2 errors caught as exceptions errno = $_errno; - $this->errmsg = $_errmsg; - } + function __construct(public $errno, public $errmsg) {} function getErrno() { return $this->errno; diff --git a/tests/lang/foreachLoopObjects.003.phpt b/tests/lang/foreachLoopObjects.003.phpt index e70d6a386d5..c8405797f01 100644 --- a/tests/lang/foreachLoopObjects.003.phpt +++ b/tests/lang/foreachLoopObjects.003.phpt @@ -3,6 +3,7 @@ Foreach loop tests - modifying the object during the loop. --FILE-- bar = str_repeat("1", 2); } function &__get($x) { return $this->bar; } function __set($x, $v) { $this->bar = $v; }