From: Nikita Popov Date: Sun, 17 May 2015 19:49:53 +0000 (+0200) Subject: Show argument causing TypeException in trace X-Git-Tag: PRE_PHP7_NSAPI_REMOVAL~42^2~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ea1d8a9c7f7a2292db720e61799656511df2c61;p=php Show argument causing TypeException in trace Not sure why that check was there, did I miss something? --- diff --git a/Zend/tests/array_type_hint_001.phpt b/Zend/tests/array_type_hint_001.phpt index f5cc76de1d..bad724679a 100644 --- a/Zend/tests/array_type_hint_001.phpt +++ b/Zend/tests/array_type_hint_001.phpt @@ -14,6 +14,6 @@ foo(123); Fatal error: Uncaught TypeException: Argument 1 passed to foo() must be of the type array, integer given, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php:2 Stack trace: -#0 %s(%d): foo() +#0 %s(%d): foo(123) #1 {main} thrown in %sarray_type_hint_001.php on line 2 diff --git a/Zend/tests/bug39003.phpt b/Zend/tests/bug39003.phpt index 80ed7c897f..87cce6fb35 100644 --- a/Zend/tests/bug39003.phpt +++ b/Zend/tests/bug39003.phpt @@ -23,6 +23,6 @@ echo "Done\n"; --EXPECTF-- Fatal error: Uncaught TypeException: 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:%d Stack trace: -#0 %s(%d): test() +#0 %s(%d): test(Object(ClassName)) #1 {main} thrown in %s on line %d diff --git a/Zend/tests/bug42802.phpt b/Zend/tests/bug42802.phpt index abbac47c9e..9b7482f727 100644 --- a/Zend/tests/bug42802.phpt +++ b/Zend/tests/bug42802.phpt @@ -39,6 +39,6 @@ ok Fatal error: Uncaught TypeException: Argument 1 passed to foo\test5() must be an instance of bar, instance of foo\bar given, called in %sbug42802.php on line %d and defined in %sbug42802.php:%d Stack trace: -#0 %s(%d): foo\test5() +#0 %s(%d): foo\test5(Object(foo\bar)) #1 {main} thrown in %sbug42802.php on line %d diff --git a/Zend/tests/bug43332_1.phpt b/Zend/tests/bug43332_1.phpt index 6506f9c591..ce4ce52833 100644 --- a/Zend/tests/bug43332_1.phpt +++ b/Zend/tests/bug43332_1.phpt @@ -14,6 +14,6 @@ $foo->bar(new \stdclass); // Error, ok! --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to foobar\foo::bar() must be an instance of foobar\foo, instance of stdClass given, called in %sbug43332_1.php on line 10 and defined in %sbug43332_1.php:5 Stack trace: -#0 %s(%d): foobar\foo->bar() +#0 %s(%d): foobar\foo->bar(Object(stdClass)) #1 {main} thrown in %sbug43332_1.php on line 5 diff --git a/Zend/tests/bug68446.phpt b/Zend/tests/bug68446.phpt index 6a7f914810..a9507b89da 100644 --- a/Zend/tests/bug68446.phpt +++ b/Zend/tests/bug68446.phpt @@ -34,7 +34,7 @@ array(1) { Fatal error: Uncaught TypeException: Argument 1 passed to a() must be of the type array, null given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): a() +#0 %s(%d): a(NULL) #1 {main} thrown in %s on line %d diff --git a/Zend/tests/closure_027.phpt b/Zend/tests/closure_027.phpt index 7024a93c55..0b604c3ac4 100644 --- a/Zend/tests/closure_027.phpt +++ b/Zend/tests/closure_027.phpt @@ -30,6 +30,6 @@ NULL Fatal error: Uncaught TypeException: Argument 1 passed to test() must be an instance of Closure, instance of stdClass given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): test() +#0 %s(%d): test(Object(stdClass)) #1 {main} thrown in %s on line %d diff --git a/Zend/tests/ns_071.phpt b/Zend/tests/ns_071.phpt index 08a0b898d6..7dbca07b8d 100644 --- a/Zend/tests/ns_071.phpt +++ b/Zend/tests/ns_071.phpt @@ -20,6 +20,6 @@ NULL Fatal error: Uncaught TypeException: Argument 1 passed to foo\bar::__construct() must be of the type array, object given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): foo\bar->__construct() +#0 %s(%d): foo\bar->__construct(Object(stdClass)) #1 {main} thrown in %s on line %d diff --git a/Zend/tests/ns_072.phpt b/Zend/tests/ns_072.phpt index 95f8f95045..c797cf0fac 100644 --- a/Zend/tests/ns_072.phpt +++ b/Zend/tests/ns_072.phpt @@ -32,6 +32,6 @@ NULL Fatal error: Uncaught TypeException: Argument 1 passed to foo\bar::__construct() must implement interface foo\foo, instance of stdClass given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): foo\bar->__construct() +#0 %s(%d): foo\bar->__construct(Object(stdClass)) #1 {main} thrown in %s on line %d diff --git a/Zend/tests/objects_022.phpt b/Zend/tests/objects_022.phpt index e96a6aa163..982b2d1a62 100644 --- a/Zend/tests/objects_022.phpt +++ b/Zend/tests/objects_022.phpt @@ -38,6 +38,6 @@ object(baz)#%d (0) { Fatal error: Uncaught TypeException: Argument 1 passed to foo::testFoo() must be an instance of foo, instance of stdClass given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): foo->testFoo() +#0 %s(%d): foo->testFoo(Object(stdClass)) #1 {main} thrown in %s on line %d diff --git a/Zend/tests/typehints/explicit_weak_include_strict.phpt b/Zend/tests/typehints/explicit_weak_include_strict.phpt index d39c6b6a0a..579ebcb3c0 100644 --- a/Zend/tests/typehints/explicit_weak_include_strict.phpt +++ b/Zend/tests/typehints/explicit_weak_include_strict.phpt @@ -13,7 +13,7 @@ require 'weak_include_strict_2.inc'; --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to takes_int() must be of the type integer, float given, called in %sweak_include_strict_2.inc on line 9 and defined in %sweak_include_strict_2.inc:5 Stack trace: -#0 %s(%d): takes_int() +#0 %s(%d): takes_int(1) #1 %s(%d): require('%s') #2 {main} thrown in %sweak_include_strict_2.inc on line 5 diff --git a/Zend/tests/typehints/strict_call_weak.phpt b/Zend/tests/typehints/strict_call_weak.phpt index 3b92244824..5031644a7f 100644 --- a/Zend/tests/typehints/strict_call_weak.phpt +++ b/Zend/tests/typehints/strict_call_weak.phpt @@ -15,7 +15,7 @@ function_declared_in_weak_mode(1.0); --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to function_declared_in_weak_mode() must be of the type integer, float given, called in %sstrict_call_weak.php on line 10 and defined in %sstrict_call_weak_2.inc:5 Stack trace: -#0 %s(%d): function_declared_in_weak_mode() +#0 %s(%d): function_declared_in_weak_mode(1) #1 {main} thrown in %sstrict_call_weak_2.inc on line 5 diff --git a/Zend/tests/typehints/strict_call_weak_explicit.phpt b/Zend/tests/typehints/strict_call_weak_explicit.phpt index fdb92fcf29..37f527bb0b 100644 --- a/Zend/tests/typehints/strict_call_weak_explicit.phpt +++ b/Zend/tests/typehints/strict_call_weak_explicit.phpt @@ -15,7 +15,7 @@ function_declared_in_weak_mode(1.0); --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to function_declared_in_weak_mode() must be of the type integer, float given, called in %sstrict_call_weak_explicit.php on line 10 and defined in %sstrict_call_weak_explicit_2.inc:5 Stack trace: -#0 %s(%d): function_declared_in_weak_mode() +#0 %s(%d): function_declared_in_weak_mode(1) #1 {main} thrown in %sstrict_call_weak_explicit_2.inc on line 5 diff --git a/Zend/tests/typehints/weak_include_strict.phpt b/Zend/tests/typehints/weak_include_strict.phpt index 4d91e7baa8..da7c7a4d13 100644 --- a/Zend/tests/typehints/weak_include_strict.phpt +++ b/Zend/tests/typehints/weak_include_strict.phpt @@ -13,7 +13,7 @@ require 'weak_include_strict_2.inc'; --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to takes_int() must be of the type integer, float given, called in %sweak_include_strict_2.inc on line 9 and defined in %sweak_include_strict_2.inc:5 Stack trace: -#0 %s(%d): takes_int() +#0 %s(%d): takes_int(1) #1 %s(%d): require('%s') #2 {main} thrown in %sweak_include_strict_2.inc on line 5 diff --git a/Zend/tests/variadic/typehint_error.phpt b/Zend/tests/variadic/typehint_error.phpt index f901147dc5..2cbe2f32a2 100644 --- a/Zend/tests/variadic/typehint_error.phpt +++ b/Zend/tests/variadic/typehint_error.phpt @@ -35,6 +35,6 @@ array(3) { Fatal error: Uncaught TypeException: Argument 3 passed to test() must be of the type array, integer given, called in %s:%d Stack trace: -#0 %s(%d): test(Array, Array) +#0 %s(%d): test(Array, Array, 2) #1 {main} thrown in %s on line %d diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index d29014d3b2..1be3de41a2 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -593,7 +593,6 @@ ZEND_API void zend_verify_arg_error(const zend_function *zf, uint32_t arg_num, c const char *fname = zf->common.function_name->val; const char *fsep; const char *fclass; - zval old_arg; if (zf->common.scope) { fsep = "::"; @@ -604,11 +603,6 @@ ZEND_API void zend_verify_arg_error(const zend_function *zf, uint32_t arg_num, c } if (zf->common.type == ZEND_USER_FUNCTION) { - if (arg) { - ZVAL_COPY_VALUE(&old_arg, arg); - ZVAL_UNDEF(arg); - } - if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) { zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind, @@ -616,10 +610,6 @@ ZEND_API void zend_verify_arg_error(const zend_function *zf, uint32_t arg_num, c } else { zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind); } - - if (arg) { - ZVAL_COPY_VALUE(arg, &old_arg); - } } else { zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind); } diff --git a/tests/classes/autoload_009.phpt b/tests/classes/autoload_009.phpt index 2af2d9adc4..b25d7eb69d 100644 --- a/tests/classes/autoload_009.phpt +++ b/tests/classes/autoload_009.phpt @@ -16,6 +16,6 @@ Ensure type hints for unknown types do not trigger autoload. --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to f() must be an instance of UndefClass, instance of stdClass given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): f() +#0 %s(%d): f(Object(stdClass)) #1 {main} thrown in %s on line %d diff --git a/tests/classes/type_hinting_001.phpt b/tests/classes/type_hinting_001.phpt index 393f157167..da3de4611f 100644 --- a/tests/classes/type_hinting_001.phpt +++ b/tests/classes/type_hinting_001.phpt @@ -37,6 +37,6 @@ $a->b($b); Fatal error: Uncaught TypeException: Argument 1 passed to FooBar::a() must implement interface Foo, instance of Blort given, called in %s on line 27 and defined in %s:12 Stack trace: -#0 %s(%d): FooBar->a() +#0 %s(%d): FooBar->a(Object(Blort)) #1 {main} thrown in %s on line 12 diff --git a/tests/classes/type_hinting_002.phpt b/tests/classes/type_hinting_002.phpt index 1ebceb4549..1988e24d97 100644 --- a/tests/classes/type_hinting_002.phpt +++ b/tests/classes/type_hinting_002.phpt @@ -15,6 +15,6 @@ $o->a($o); --EXPECTF-- Fatal error: Uncaught TypeException: 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:%d Stack trace: -#0 %s(%d): Foo->a() +#0 %s(%d): Foo->a(Object(Foo)) #1 {main} thrown in %s on line %d diff --git a/tests/classes/type_hinting_003.phpt b/tests/classes/type_hinting_003.phpt index d8734b1136..a58c579dc5 100644 --- a/tests/classes/type_hinting_003.phpt +++ b/tests/classes/type_hinting_003.phpt @@ -59,6 +59,6 @@ array(1) { Fatal error: Uncaught TypeException: Argument 1 passed to Test::f1() must be of the type array, integer given, called in %s on line %d and defined in %s:%d Stack trace: -#0 %s(%d): Test::f1() +#0 %s(%d): Test::f1(1) #1 {main} thrown in %s on line %d diff --git a/tests/lang/bug24658.phpt b/tests/lang/bug24658.phpt index 236d8ed394..6e57d9b66b 100644 --- a/tests/lang/bug24658.phpt +++ b/tests/lang/bug24658.phpt @@ -55,7 +55,7 @@ object(foo)#%d (0) { Fatal error: Uncaught TypeException: Argument 1 passed to typehint() must be an instance of foo, integer given in %s:%d Stack trace: -#0 [internal function]: typehint(1) +#0 [internal function]: typehint(1, 1) #1 %s(%d): array_walk(Array, 'typehint') #2 {main} thrown in %s on line %d diff --git a/tests/lang/catchable_error_001.phpt b/tests/lang/catchable_error_001.phpt index f58b26e847..4343ac0e8f 100644 --- a/tests/lang/catchable_error_001.phpt +++ b/tests/lang/catchable_error_001.phpt @@ -21,6 +21,6 @@ Catchable fatal error [1] --EXPECTF-- Fatal error: Uncaught TypeException: Argument 1 passed to blah() must be an instance of Foo, instance of stdClass given, called in %scatchable_error_001.php on line 15 and defined in %scatchable_error_001.php:5 Stack trace: -#0 %s(%d): blah() +#0 %s(%d): blah(Object(stdClass)) #1 {main} thrown in %scatchable_error_001.php on line 5 diff --git a/tests/lang/type_hints_001.phpt b/tests/lang/type_hints_001.phpt index 71ef9f30c3..0a061b7d9e 100644 --- a/tests/lang/type_hints_001.phpt +++ b/tests/lang/type_hints_001.phpt @@ -25,6 +25,6 @@ type_hint_foo($bar); Fatal error: Uncaught TypeException: Argument 1 passed to type_hint_foo() must be an instance of Foo, instance of Bar given, called in %s on line 16 and defined in %s:9 Stack trace: -#0 %s(%d): type_hint_foo() +#0 %s(%d): type_hint_foo(Object(Bar)) #1 {main} thrown in %s on line 9