mirror of
https://github.com/php/php-src.git
synced 2025-01-27 06:03:45 +08:00
Fixed type-hint compatibility check in namespaces
This commit is contained in:
parent
98b3c247a8
commit
8646d9afce
31
Zend/tests/ns_056.phpt
Executable file
31
Zend/tests/ns_056.phpt
Executable file
@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
056: type-hint compatibility in namespaces
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
namespace test::ns1;
|
||||
|
||||
class Foo implements SplObserver {
|
||||
function update(SplSubject $x) {
|
||||
echo "ok\n";
|
||||
}
|
||||
}
|
||||
|
||||
class Bar implements SplSubject {
|
||||
function attach(SplObserver $x) {
|
||||
echo "ok\n";
|
||||
}
|
||||
function notify() {
|
||||
}
|
||||
function detach(SplObserver $x) {
|
||||
}
|
||||
}
|
||||
$foo = new Foo();
|
||||
$bar = new Bar();
|
||||
$bar->attach($foo);
|
||||
$foo->update($bar);
|
||||
?>
|
||||
--EXPECT--
|
||||
ok
|
||||
ok
|
@ -2176,7 +2176,18 @@ static zend_bool zend_do_perform_implementation_check(zend_function *fe, zend_fu
|
||||
}
|
||||
if (fe->common.arg_info[i].class_name
|
||||
&& strcmp(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)!=0) {
|
||||
return 0;
|
||||
char *colon;
|
||||
|
||||
if (fe->common.type == ZEND_USER_FUNCTION &&
|
||||
strchr(proto->common.arg_info[i].class_name, ':') == NULL &&
|
||||
(colon = zend_memrchr(fe->common.arg_info[i].class_name, ':', fe->common.arg_info[i].class_name_len)) != NULL &&
|
||||
strcmp(colon+1, proto->common.arg_info[i].class_name) == 0) {
|
||||
efree((char*)fe->common.arg_info[i].class_name);
|
||||
fe->common.arg_info[i].class_name = estrndup(proto->common.arg_info[i].class_name, proto->common.arg_info[i].class_name_len);
|
||||
fe->common.arg_info[i].class_name_len = proto->common.arg_info[i].class_name_len;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (fe->common.arg_info[i].array_type_hint != proto->common.arg_info[i].array_type_hint) {
|
||||
/* Only one has an array type hint and the other one doesn't */
|
||||
|
Loading…
Reference in New Issue
Block a user