]> granicus.if.org Git - php/commitdiff
Don't optimize (string) cast on arrays
authorNikita Popov <nikic@php.net>
Fri, 9 Sep 2016 14:36:26 +0000 (16:36 +0200)
committerNikita Popov <nikic@php.net>
Fri, 9 Sep 2016 14:38:26 +0000 (16:38 +0200)
Otherwise we throw a notice during pass1_5 optimization.

ext/opcache/Optimizer/pass1_5.c

index 53abb5b3bd1252d73e0fae06c4a93707275b0c33..1a0fdb54154fa98aee87de08f9f73929c867d64f 100644 (file)
@@ -106,7 +106,9 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
                        if (ZEND_OP1_TYPE(opline) == IS_CONST &&
                                opline->extended_value != IS_ARRAY &&
                                opline->extended_value != IS_OBJECT &&
-                               opline->extended_value != IS_RESOURCE) {
+                               opline->extended_value != IS_RESOURCE &&
+                               (opline->extended_value != IS_STRING
+                                       || Z_TYPE(ZEND_OP1_LITERAL(opline)) != IS_ARRAY)) {
                                /* cast of constant operand */
                                zend_uchar type = opline->result_type;
                                uint32_t tv = ZEND_RESULT(opline).var;          /* temporary variable */