summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorAaron Piotrowski <aaron@trowski.com>2016-06-04 09:44:49 -0500
committerAaron Piotrowski <aaron@trowski.com>2016-06-04 09:44:49 -0500
commit4da3e77b4ce4beb1735a679c58cb2bce3fdfece1 (patch)
tree1cfc63254e939f231fcba9587f453e64dd0c73fe /Zend/zend_compile.c
parentbea9df52811d1b5f99fd59dfd4d8232d8448b538 (diff)
downloadphp-git-4da3e77b4ce4beb1735a679c58cb2bce3fdfece1.tar.gz
Covariance on inheriting classes with iterable
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index bd4dba88ff..62fa76b5b1 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1253,17 +1253,20 @@ static void zend_mark_function_as_generator() /* {{{ */
}
if (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
- const char *msg = "Generators may only declare a return type of Generator, Iterator or Traversable, %s is not permitted";
zend_arg_info return_info = CG(active_op_array)->arg_info[-1];
- if (!return_info.class_name) {
- zend_error_noreturn(E_COMPILE_ERROR, msg, zend_get_type_by_const(return_info.type_hint));
- }
+ if (return_info.type_hint != IS_ITERABLE) {
+ const char *msg = "Generators may only declare a return type of Generator, Iterator, Traversable, or iterable, %s is not permitted";
+
+ if (!return_info.class_name) {
+ zend_error_noreturn(E_COMPILE_ERROR, msg, zend_get_type_by_const(return_info.type_hint));
+ }
- if (!zend_string_equals_literal_ci(return_info.class_name, "Traversable")
- && !zend_string_equals_literal_ci(return_info.class_name, "Iterator")
- && !zend_string_equals_literal_ci(return_info.class_name, "Generator")) {
- zend_error_noreturn(E_COMPILE_ERROR, msg, ZSTR_VAL(return_info.class_name));
+ if (!zend_string_equals_literal_ci(return_info.class_name, "Traversable")
+ && !zend_string_equals_literal_ci(return_info.class_name, "Iterator")
+ && !zend_string_equals_literal_ci(return_info.class_name, "Generator")) {
+ zend_error_noreturn(E_COMPILE_ERROR, msg, ZSTR_VAL(return_info.class_name));
+ }
}
}