mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add recursion protection when emitting deprecation warnings for class constants, since the deprecation message can come from an attribute that is using the same constant for the message, or otherwise result in recursion. But, internal constants are persisted, and thus cannot have recursion protection. Otherwise, if a user error handler triggers bailout before the recursion flag is removed then a subsequent request (e.g. with `--repeat 2`) would start with that flag already applied. Internal constants can presumably be trusted not to use deprecation messages that come from recursive attributes. Fixes GH-18463 Fixes GH-17711
29 lines
526 B
PHP
29 lines
526 B
PHP
--TEST--
|
|
GH-17711: Infinite recursion through deprecated class constants self-referencing through deprecation message
|
|
--FILE--
|
|
<?php
|
|
|
|
class C {
|
|
#[\Deprecated(self::C)]
|
|
const C = TEST;
|
|
}
|
|
|
|
const TEST = 'Message';
|
|
var_dump(C::C);
|
|
|
|
class D {
|
|
#[\Deprecated(Alias::C)]
|
|
const C = 'test';
|
|
}
|
|
|
|
class_alias('D', 'Alias');
|
|
var_dump(D::C);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Deprecated: Constant C::C is deprecated, Message in %s on line %d
|
|
string(7) "Message"
|
|
|
|
Deprecated: Constant D::C is deprecated, test in %s on line %d
|
|
string(4) "test"
|