Skip to content

Commit ccec609

Browse files
committed
Fix bug #62441
These checks were introduced by 8646d9a back when name resolution was working differently.
1 parent 7f2261d commit ccec609

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

Zend/tests/bug62441.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #62441: Incorrect strong typing in namespaced child classes
3+
--FILE--
4+
<?php
5+
namespace {
6+
interface Iface {
7+
function method(stdClass $o);
8+
}
9+
}
10+
namespace ns {
11+
class Foo implements \Iface {
12+
function method(stdClass $o) { }
13+
}
14+
15+
(new Foo)->method(new \stdClass);
16+
}
17+
?>
18+
--EXPECTF--
19+
Fatal error: Declaration of ns\Foo::method(ns\stdClass $o) must be compatible with Iface::method(stdClass $o) in %s on line %d
20+

Zend/zend_inheritance.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,11 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
213213
}
214214

215215
if (strcasecmp(ZSTR_VAL(fe_class_name), ZSTR_VAL(proto_class_name)) != 0) {
216-
const char *colon;
217-
218216
if (fe->common.type != ZEND_USER_FUNCTION) {
219217
zend_string_release(proto_class_name);
220218
zend_string_release(fe_class_name);
221219
return 0;
222-
} else if (strchr(ZSTR_VAL(proto_class_name), '\\') != NULL ||
223-
(colon = zend_memrchr(ZSTR_VAL(fe_class_name), '\\', ZSTR_LEN(fe_class_name))) == NULL ||
224-
strcasecmp(colon+1, ZSTR_VAL(proto_class_name)) != 0) {
220+
} else {
225221
zend_class_entry *fe_ce, *proto_ce;
226222

227223
fe_ce = zend_lookup_class(fe_class_name);

0 commit comments

Comments
 (0)