com php-src: Fix bug #62441: Zend/tests/bug62441.phpt Zend/zend_inheritance.c
| From: | Nikita Popov | Date: | Fri, 28 Aug 2015 17:00:05 +0000 |
| Subject: | com php-src: Fix bug #62441: Zend/tests/bug62441.phpt Zend/zend_inheritance.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88798@lists.php.net to get a copy of this message | ||
Commit: ccec609b82b69ef96bc52f7c563c7eb8a68f99a0
Author: Nikita Popov <nikic@php.net> Fri, 28 Aug 2015 18:58:49 +0200
Parents: 7f2261d24a1304d144ad2ba60ad3fd70be923f35
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ccec609b82b69ef96bc52f7c563c7eb8a68f99a0
Log:
Fix bug #62441
These checks were introduced by 8646d9afce989718cde927c526684bbbc1c96e97
back when name resolution was working differently.
Bugs:
https://bugs.php.net/62441
Changed paths:
A Zend/tests/bug62441.phpt
M Zend/zend_inheritance.c
Diff:
diff --git a/Zend/tests/bug62441.phpt b/Zend/tests/bug62441.phpt
new file mode 100644
index 0000000..3299f49
--- /dev/null
+++ b/Zend/tests/bug62441.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #62441: Incorrect strong typing in namespaced child classes
+--FILE--
+<?php
+namespace {
+ interface Iface {
+ function method(stdClass $o);
+ }
+}
+namespace ns {
+ class Foo implements \Iface {
+ function method(stdClass $o) { }
+ }
+
+ (new Foo)->method(new \stdClass);
+}
+?>
+--EXPECTF--
+Fatal error: Declaration of ns\Foo::method(ns\stdClass $o) must be compatible with
Iface::method(stdClass $o) in %s on line %d
+
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 0d02bf7..73b67f5 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -213,15 +213,11 @@ static int zend_do_perform_type_hint_check(const zend_function *fe,
zend_arg_inf
}
if (strcasecmp(ZSTR_VAL(fe_class_name), ZSTR_VAL(proto_class_name)) != 0) {
- const char *colon;
-
if (fe->common.type != ZEND_USER_FUNCTION) {
zend_string_release(proto_class_name);
zend_string_release(fe_class_name);
return 0;
- } else if (strchr(ZSTR_VAL(proto_class_name), '\\') != NULL ||
- (colon = zend_memrchr(ZSTR_VAL(fe_class_name), '\\', ZSTR_LEN(fe_class_name))) ==
NULL ||
- strcasecmp(colon+1, ZSTR_VAL(proto_class_name)) != 0) {
+ } else {
zend_class_entry *fe_ce, *proto_ce;
fe_ce = zend_lookup_class(fe_class_name);