]> granicus.if.org Git - php/commitdiff
Don't elide undef var notice
authorNikita Popov <nikic@php.net>
Thu, 10 Nov 2016 13:54:41 +0000 (14:54 +0100)
committerNikita Popov <nikic@php.net>
Thu, 10 Nov 2016 13:58:54 +0000 (14:58 +0100)
ext/opcache/Optimizer/block_pass.c
ext/opcache/tests/block_pass_001.phpt [new file with mode: 0644]

index 242016e1b3a90e3f008dba47b6f0c3a0ef7d686c..aea670beb37c0a73b1b6d34a0d8ade287123884f 100644 (file)
@@ -1657,7 +1657,10 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use
                                                case ZEND_QM_ASSIGN:
                                                case ZEND_BOOL:
                                                case ZEND_BOOL_NOT:
-                                                       if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR) {
+                                                       if (ZEND_OP1_TYPE(opline) == IS_CV) {
+                                                               opline->opcode = ZEND_CHECK_VAR;
+                                                               SET_UNUSED(opline->result);
+                                                       } else if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR) {
                                                                opline->opcode = ZEND_FREE;
                                                                SET_UNUSED(opline->result);
                                                        } else {
diff --git a/ext/opcache/tests/block_pass_001.phpt b/ext/opcache/tests/block_pass_001.phpt
new file mode 100644 (file)
index 0000000..8a1b691
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Block pass: Don't suppress undefined variable notice
+--FILE--
+<?php
+(bool) (true ? $x : $y);
+?>
+--EXPECTF--
+Notice: Undefined variable: x in %s on line %d