This is already skipped for TMP/VAR, but also needs to be skipped
for CV, because we need to insert CHECK_VAR in that case, if we're
being pedantic. That leaves us with CONST as the only case
we can handle, which is already covered by constant folding.
This optimization never actually triggers in our tests, so it's
not a big loss.
Pass1 handles a number of special functions that can be evaluated
under some circumstances. Move the core logic into a separate
helper, as I believe that SCCP should reuse this.
These can be handled by the generic code. Worth noting that count
will usually go through ZEND_COUNT, and chr on constants is
evaluated in the compiler, so these are not particularly compile-time
sensitive either.
This handles references to the current class through its name
rather than self (and for cases where is is not linked yet and
thus not covered by the context lookup). Rather than handling this
only for FETCH_CLASS_CONSTANT optimization, integrate this into
the generic get_class_entry() utility.
Nowadays self::X is represented using an UNUSED operand with
FETCH_CLASS_SELF flag rather than a separate FETCH_CLASS instruction.
The code already handles the new pattern.
These are supported as constants nowadays, so we can drop the
string check.
Also fix a potential leak, though I believe this doesn't matter in
current usage, as it will effectively be suppressed during persist.
The generic code was rejecting this to go into a special code path
in SCCP. We should directly do that in SCCP instead, to still allow
the generic (and valid) replacement.
While we can't replace the instanceof operand, we will evaluate
the instanceof to false and replace its result anyway. Even in
cases where the instanceof user cannot be replaced, we already
have generic code to convert the opcode to QM_ASSIGN in that
case.
https://wiki.php.net/rfc/strtolower-ascii means that these functions no longer
depend on the current locale in php 8.2. Before that, this was unsafe to
evaluate at compile time.
Followup to GH-7506
Add strcmp/strcasecmp/strtolower/strtoupper functions
Add bin2hex/hex2bin and related functions
Update test of garbage collection using strtolower to use something else to create a refcounted string
This is the same change as 56b18d478e
but for ASSIGN_OP. Changing the operand type may change the error
message and can result in different behavior with operator overloading.
As with the other patch, if there is strong interest this could be
added to the DFA pass instead, with an appropriate type check.