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.
In case of
we want
Awith parametersCONST_ONE, CONST_TWOto be called once and transpiled as global variable that is initialized only oncenew A(CONST_ONE, CONST_TWO)to be replaced with such a variableIt would allow use some constructions such as
with the following restrictions on
class A:@kphp-immutable-class@kphp-pure-functionCONST_ONE, CONST_TWOare constant expressionsIt would possibly improve performance and definitely help to implement
enumsin a natural way.