com php-src: Fixed bug #73746 (Method that returns string returns UNKNOWN:0 instead): NEWS ext/opcache/Optimizer/zend_optimizer.c ext
/opcache/tests/bug73746.phpt
| From: | Xinchen Hui | Date: | Fri, 16 Dec 2016 03:06:27 +0000 |
| Subject: | com php-src: Fixed bug #73746 (Method that returns string returns UNKNOWN:0 instead): NEWS ext/opcache/Optimizer/zend_optimizer.c ext /opcache/tests/bug73746.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96338@lists.php.net to get a copy of this message | ||
Commit: 7cef66c6352eb6398517fcf3acde128052e0fbd9
Author: Xinchen Hui <laruence@gmail.com> Fri, 16 Dec 2016 11:06:27 +0800
Parents: b441ff6cf948586f6f3fe943281bda5e75cf1691
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7cef66c6352eb6398517fcf3acde128052e0fbd9
Log:
Fixed bug #73746 (Method that returns string returns UNKNOWN:0 instead)
Bugs:
https://bugs.php.net/73746
Changed paths:
M NEWS
M ext/opcache/Optimizer/zend_optimizer.c
A ext/opcache/tests/bug73746.phpt
Diff:
diff --git a/NEWS b/NEWS
index e6e9c34..1f22b92 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ PHP NEWS
usage. (Andrey)
- Opcache:
+ . Fixed bug #73746 (Method that returns string returns UNKNOWN:0 instead).
+ (Laruence)
. Fixed bug #73654 (Segmentation fault in zend_call_function). (Nikita)
. Fixed bug #73668 ("SIGFPE Arithmetic exception" in opcache when divide by
minus 1). (Nikita)
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index b6506e0..ef79eb8 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -506,7 +506,6 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array,
}
case ZEND_VERIFY_RETURN_TYPE: {
zend_arg_info *ret_info = op_array->arg_info - 1;
- ZEND_ASSERT((opline + 1)->opcode == ZEND_RETURN || (opline + 1)->opcode ==
ZEND_RETURN_BY_REF);
if (ret_info->class_name
|| ret_info->type_hint == IS_CALLABLE
|| !ZEND_SAME_FAKE_TYPE(ret_info->type_hint, Z_TYPE_P(val))
@@ -515,7 +514,10 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array,
return 0;
}
MAKE_NOP(opline);
- opline++;
+ /* zend_handle_loops_and_finally may inserts other oplines */
+ do {
+ ++opline;
+ } while (opline->opcode != ZEND_RETURN && opline->opcode != ZEND_RETURN_BY_REF);
break;
}
default:
diff --git a/ext/opcache/tests/bug73746.phpt b/ext/opcache/tests/bug73746.phpt
new file mode 100644
index 0000000..c97833a
--- /dev/null
+++ b/ext/opcache/tests/bug73746.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #73746 (Method that returns string returns UNKNOWN:0 instead)
+--FILE--
+<?php
+namespace Core\Bundle\Service\Property\Room\Rooms;
+
+class CountryMapping
+{
+ const CZ = 'CZ';
+ const EN = 'EN';
+
+ public function get(string $countryIsoCode = null) : string // Works correctly if return type is
removed
+ {
+ switch (strtoupper($countryIsoCode)) {
+ case 'CZ':
+ case 'SK':
+ return self::CZ; // Works correctly if changed to CountryMapping::CZ
+ default:
+ return self::EN; // Works correctly if changed to CountryMapping::EN
+ }
+ }
+}
+
+$mapping = new CountryMapping();
+var_dump($mapping->get('CZ'));
+?>
+--EXPECT--
+string(2) "CZ"