Typed class constants support
thekid opened this issue · 3 comments
thekid commented
In a nutshell
class T {
public const string NAME= 'Test';
}
- Syntactic support with erasure at compile time (see cad16ee)
- Emit type in meta information for PHP < 8.3
- Extend reflection to support types for class constants
- Emit types once the Typed class constants RFC implementation is merged into PHP 8.3
See also
- https://wiki.php.net/rfc/typed_class_constants - RFC
- php/php-src#10444 - RFC implementation
- #163 - Emit meta information
- xp-framework/reflection#32 - Extend reflection
- #165 - Emit types
thekid commented
The RFC has been accepted, need to wait for php/php-src#10444 before adding this to the PHP 8.3 emitter.
thekid commented
PR has been merged, the build from https://github.com/shivammathur/php-builder-windows/actions/runs/4715949822 contains the change:
$ XP_RT=8.3 xp -w 'class T { const string NAME= "Test"; } return T::NAME'
Test
thekid commented