Skip to content

Commit 5fb982a

Browse files
committed
Test deprecated class constants with values unknown at compile time
1 parent b4e9d9a commit 5fb982a

File tree

1 file changed

+21
-0
lines changed
  • Zend/tests/attributes/deprecated/class_constants

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
#[\Deprecated]: Class constant with value unknown at compile time.
3+
--FILE--
4+
<?php
5+
6+
define('SUFFIX', random_int(1, 2) == 1 ? 'a' : 'b');
7+
8+
class Clazz {
9+
#[\Deprecated]
10+
public const CONSTANT = self::class . '-' . SUFFIX;
11+
}
12+
13+
$value = Clazz::CONSTANT;
14+
var_dump($value);
15+
var_dump($value === 'Clazz-' . SUFFIX);
16+
17+
?>
18+
--EXPECTF--
19+
Deprecated: Constant Clazz::CONSTANT is deprecated in %s on line %d
20+
string(7) "Clazz-%c"
21+
bool(true)

0 commit comments

Comments
 (0)