cvs: ZendEngine2(PHP_5_2) / zend_execute.c /tests bug39003.phpt php-src NEWS php-src/tests/classes type_hinting_002.phpt
| From: | Antony Dovgal | Date: | Mon, 02 Oct 2006 11:09:52 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_2) / zend_execute.c /tests bug39003.phpt php-src NEWS php-src/tests/classes type_hinting_002.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5287@lists.php.net to get a copy of this message | ||
tony2001 Mon Oct 2 11:09:52 2006 UTC
Added files: (Branch: PHP_5_2)
/ZendEngine2/tests bug39003.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_execute.c
/php-src/tests/classes type_hinting_002.phpt
Log:
MFH: fix #39003 (__autoload() is called for type hinting)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.274&r2=1.2027.2.547.2.275&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.274 php-src/NEWS:1.2027.2.547.2.275
--- php-src/NEWS:1.2027.2.547.2.274 Sun Oct 1 20:58:02 2006
+++ php-src/NEWS Mon Oct 2 11:09:52 2006
@@ -6,6 +6,7 @@
- Fixed mess with CGI/CLI -d option (now it works with cgi; constants are
working exactly like in php.ini; with FastCGI -d affects all requests).
(Dmitry)
+- Fixed bug #39003 (__autoload() is called for type hinting). (Dmitry, Tony)
- Fixed bug #38993 (Fixed safe_mode/open_basedir checks for
session.save_path, allowing them to account for extra parameters). (Ilia)
- Fixed bug #38981 (using FTP URLs in get_headers() causes crash). (Tony)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.11&r2=1.716.2.12.2.12&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.11 ZendEngine2/zend_execute.c:1.716.2.12.2.12
--- ZendEngine2/zend_execute.c:1.716.2.12.2.11 Tue Jul 18 09:06:32 2006
+++ ZendEngine2/zend_execute.c Mon Oct 2 11:09:52 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.716.2.12.2.11 2006/07/18 09:06:32 dmitry Exp $ */
+/* $Id: zend_execute.c,v 1.716.2.12.2.12 2006/10/02 11:09:52 tony2001 Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -449,11 +449,12 @@
}
}
-static inline char * zend_verify_arg_class_kind(zend_arg_info *cur_arg_info, zend_class_entry **pce
TSRMLS_DC)
+static inline char * zend_verify_arg_class_kind(zend_arg_info *cur_arg_info, char **class_name,
zend_class_entry **pce TSRMLS_DC)
{
- *pce = zend_fetch_class(cur_arg_info->class_name, cur_arg_info->class_name_len,
ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
+ *pce = zend_fetch_class(cur_arg_info->class_name, cur_arg_info->class_name_len,
(ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD) TSRMLS_CC);
- if ((*pce)->ce_flags & ZEND_ACC_INTERFACE) {
+ *class_name = (*pce) ? (*pce)->name: cur_arg_info->class_name;
+ if (*pce && (*pce)->ce_flags & ZEND_ACC_INTERFACE) {
return "implement interface ";
} else {
return "be an instance of ";
@@ -497,18 +498,20 @@
cur_arg_info = &zf->common.arg_info[arg_num-1];
if (cur_arg_info->class_name) {
+ char *class_name;
+
if (!arg) {
- need_msg = zend_verify_arg_class_kind(cur_arg_info, &ce TSRMLS_CC);
- return zend_verify_arg_error(zf, arg_num, cur_arg_info, need_msg, ce->name, "none",
"" TSRMLS_CC);
+ need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC);
+ return zend_verify_arg_error(zf, arg_num, cur_arg_info, need_msg, class_name, "none",
"" TSRMLS_CC);
}
if (Z_TYPE_P(arg) == IS_OBJECT) {
- need_msg = zend_verify_arg_class_kind(cur_arg_info, &ce TSRMLS_CC);
- if (!instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) {
- return zend_verify_arg_error(zf, arg_num, cur_arg_info, need_msg, ce->name, "instance
of ", Z_OBJCE_P(arg)->name TSRMLS_CC);
+ need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC);
+ if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) {
+ return zend_verify_arg_error(zf, arg_num, cur_arg_info, need_msg, class_name, "instance of
", Z_OBJCE_P(arg)->name TSRMLS_CC);
}
} else if (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null) {
- need_msg = zend_verify_arg_class_kind(cur_arg_info, &ce TSRMLS_CC);
- return zend_verify_arg_error(zf, arg_num, cur_arg_info, need_msg, ce->name,
zend_zval_type_name(arg), "" TSRMLS_CC);
+ need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce TSRMLS_CC);
+ return zend_verify_arg_error(zf, arg_num, cur_arg_info, need_msg, class_name,
zend_zval_type_name(arg), "" TSRMLS_CC);
}
} else if (cur_arg_info->array_type_hint) {
if (!arg) {
http://cvs.php.net/viewvc.cgi/php-src/tests/classes/type_hinting_002.phpt?r1=1.1&r2=1.1.6.1&diff_format=u
Index: php-src/tests/classes/type_hinting_002.phpt
diff -u php-src/tests/classes/type_hinting_002.phpt:1.1
php-src/tests/classes/type_hinting_002.phpt:1.1.6.1
--- php-src/tests/classes/type_hinting_002.phpt:1.1 Sat Mar 27 15:49:23 2004
+++ php-src/tests/classes/type_hinting_002.phpt Mon Oct 2 11:09:52 2006
@@ -13,5 +13,4 @@
$o->a($o);
?>
--EXPECTF--
-
-Fatal error: Class 'NonExisting' not found in %stype_hinting_002.php on line %d
+Catchable fatal error: Argument 1 passed to Foo::a() must be an instance of NonExisting, instance
of Foo given, called in %s on line %d and defined in %s on line %d
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug39003.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug39003.phpt
+++ ZendEngine2/tests/bug39003.phpt
--TEST--
Bug #39003 (__autoload() is called for type hinting)
--FILE--
<?php
class ClassName
{
public $var = 'bla';
}
function test (OtherClassName $object) { }
function __autoload($class)
{
var_dump("__autload($class)");
}
$obj = new ClassName;
test($obj);
echo "Done\n";
?>
--EXPECTF--
Catchable fatal error: Argument 1 passed to test() must be an instance of OtherClassName, instance
of ClassName given, called in %s on line %d and defined in %s on line %d