Skip to content

Commit 273720d

Browse files
committed
Add str_replace/array_unique to ct eval list
Taken from GH-5870.
1 parent ffc30c5 commit 273720d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Zend/Optimizer/sccp.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,9 @@ static inline int ct_eval_array_key_exists(zval *result, zval *op1, zval *op2) {
797797
}
798798

799799
static bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zval **args) {
800-
/* Functions that can be evaluated independently of what the arguments are.
801-
* It's okay if these functions throw on invalid arguments, but they should not warn. */
800+
/* Functions in this list must always produce the same result for the same arguments,
801+
* and have no dependence on global state (such as locales). It is okay if they throw
802+
* or warn on invalid arguments, as we detect this and will discard the evaluation result. */
802803
if (false
803804
|| zend_string_equals_literal(name, "array_diff")
804805
|| zend_string_equals_literal(name, "array_diff_assoc")
@@ -811,6 +812,7 @@ static bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zval **a
811812
|| zend_string_equals_literal(name, "array_merge_recursive")
812813
|| zend_string_equals_literal(name, "array_replace")
813814
|| zend_string_equals_literal(name, "array_replace_recursive")
815+
|| zend_string_equals_literal(name, "array_unique")
814816
|| zend_string_equals_literal(name, "array_values")
815817
|| zend_string_equals_literal(name, "base64_decode")
816818
|| zend_string_equals_literal(name, "base64_encode")
@@ -834,6 +836,7 @@ static bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zval **a
834836
|| zend_string_equals_literal(name, "serialize")
835837
|| zend_string_equals_literal(name, "str_contains")
836838
|| zend_string_equals_literal(name, "str_ends_with")
839+
|| zend_string_equals_literal(name, "str_replace")
837840
|| zend_string_equals_literal(name, "str_split")
838841
|| zend_string_equals_literal(name, "str_starts_with")
839842
|| zend_string_equals_literal(name, "strpos")

0 commit comments

Comments
 (0)