xp-framework/compiler

Typed class constants support

thekid opened this issue · 3 comments

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

The RFC has been accepted, need to wait for php/php-src#10444 before adding this to the PHP 8.3 emitter.

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