In case of
$a = new A(CONST_ONE, CONST_TWO);
$b = new A(CONST_ONE, CONST_TWO);
we want
- Constructor of class
A with parameters CONST_ONE, CONST_TWO to be called once and transpiled as global variable that is initialized only once
- Each invocation of
new A(CONST_ONE, CONST_TWO) to be replaced with such a variable
It would allow use some constructions such as
const c = new A(CONST_ONE, CONST_TWO);
with the following restrictions on class A:
- Marked as
@kphp-immutable-class
- Has constructor that marked as
@kphp-pure-function
CONST_ONE, CONST_TWO are constant expressions
It would possibly improve performance and definitely help to implement enums in a natural way.