Skip to content

Commit 85e7668

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 6bf5c85 + 003c13d commit 85e7668

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/opcache/Optimizer/dfa_pass.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ static inline zend_bool can_elide_return_type_check(
327327
return 0;
328328
}
329329

330-
if (ZEND_TYPE_CODE(info->type) == IS_CALLABLE) {
330+
/* These types are not represented exactly */
331+
if (ZEND_TYPE_CODE(info->type) == IS_CALLABLE || ZEND_TYPE_CODE(info->type) == IS_ITERABLE) {
331332
return 0;
332333
}
333334

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Don't optimize object -> iterable
3+
--FILE--
4+
<?php
5+
6+
function test(object $arg): iterable {
7+
return $arg;
8+
}
9+
test(new stdClass);
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Uncaught TypeError: Return value of test() must be iterable, object returned in %s:%d
14+
Stack trace:
15+
#0 %s(%d): test(Object(stdClass))
16+
#1 {main}
17+
thrown in %s on line %d

0 commit comments

Comments
 (0)