Last active
November 14, 2016 10:21
-
-
Save krakjoe/a57cc82b0e5c1b9e83ecd8856193642e to your computer and use it in GitHub Desktop.
variance corrections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/tests/object_types/variance_in_param.phpt b/Zend/tests/object_types/variance_in_param.phpt | |
index bcc528e..cf28dd8 100644 | |
--- a/Zend/tests/object_types/variance_in_param.phpt | |
+++ b/Zend/tests/object_types/variance_in_param.phpt | |
@@ -15,6 +15,7 @@ class Bar extends Foo { | |
var_dump(new Bar); | |
?> | |
--EXPECTF-- | |
+Warning: Declaration of Bar::qux(Qux $qux) should be compatible with Foo::qux(object $object) in %s on line 10 | |
object(Bar)#%d (0) { | |
} | |
diff --git a/Zend/tests/object_types/variance_in_param_error.phpt b/Zend/tests/object_types/variance_in_param_contravariance.phpt | |
similarity index 58% | |
rename from Zend/tests/object_types/variance_in_param_error.phpt | |
rename to Zend/tests/object_types/variance_in_param_contravariance.phpt | |
index 921fcc2..feaefa9 100644 | |
--- a/Zend/tests/object_types/variance_in_param_error.phpt | |
+++ b/Zend/tests/object_types/variance_in_param_contravariance.phpt | |
@@ -1,5 +1,5 @@ | |
--TEST-- | |
-Variance of object parameter type (fail) | |
+Variance of object parameter type | |
--FILE-- | |
<?php | |
class Foo { | |
@@ -15,7 +15,6 @@ class Bar extends Foo { | |
var_dump(new Bar); | |
?> | |
--EXPECTF-- | |
-Warning: Declaration of Bar::qux(object $qux) should be compatible with Foo::qux(Qux $object) in %s on line 10 | |
object(Bar)#%d (0) { | |
} | |
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c | |
index 511d18b..a04e054 100644 | |
--- a/Zend/zend_inheritance.c | |
+++ b/Zend/zend_inheritance.c | |
@@ -183,12 +183,12 @@ static zend_always_inline zend_bool zend_iterable_compatibility_check(zend_arg_i | |
static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_info *fe_arg_info, const zend_function *proto, zend_arg_info *proto_arg_info) /* {{{ */ | |
{ | |
- if (ZEND_TRUTH(fe_arg_info->class_name) == 0 && ZEND_TRUTH(proto_arg_info->class_name)) { | |
+ if (ZEND_LOG_XOR(fe_arg_info->class_name, proto_arg_info->class_name)) { | |
/* Only one has a type declaration and the other one doesn't */ | |
return 0; | |
} | |
- if (fe_arg_info->class_name && proto_arg_info->class_name) { | |
+ if (fe_arg_info->class_name) { | |
zend_string *fe_class_name, *proto_class_name; | |
const char *class_name; | |
@@ -336,6 +336,10 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c | |
return 0; | |
} | |
break; | |
+ | |
+ case IS_OBJECT: { | |
+ return !fe_arg_info->class_name && proto_arg_info->class_name; | |
+ } break; | |
default: | |
return 0; | |
@@ -369,6 +373,10 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c | |
return 0; | |
} | |
break; | |
+ | |
+ case IS_OBJECT: { | |
+ return !proto->common.arg_info[-1].class_name && fe->common.arg_info[-1].class_name; | |
+ } break; | |
default: | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment