Closed as not planned
Description
Description
Ref: RFC: typed_class_constants
The following code https://3v4l.org/MUm1l:
<?php
// overriding an untyped parent constant with a typed one
class A {
public const VALUE = 42; // untyped
}
class B extends A {
public const float VALUE = 42.5; // narrowing to `float`
}
echo "Parent type: " . gettype(A::VALUE) . "\n";
echo "Child value: " . B::VALUE . "\n";
Resulted in this output:
Parent type: integer
Child value: 42.5
But I expected this output instead:
Fatal error: Cannot override constant A::VALUE with incompatible type in %s on line %d
PHP Version
8.3.0 - 8.3.23, 8.4.1 - 8.4.10
Operating System
No response