From: Christoph M. Becker Date: Tue, 15 Oct 2019 12:30:23 +0000 (+0200) Subject: Add Zend class/interface arginfo stubs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=273731fb762d661fb40015afd851ab340cf7a429;p=php Add Zend class/interface arginfo stubs We also change `Generator::throw()` to expect a `Throwable` in the first place, and we now throw a TypeError instead of returning `false` from `Exception::getTraceAsString()`. --- diff --git a/Zend/tests/generators/throw_not_an_exception.phpt b/Zend/tests/generators/throw_not_an_exception.phpt index 920d8eb847..abf9a3c894 100644 --- a/Zend/tests/generators/throw_not_an_exception.phpt +++ b/Zend/tests/generators/throw_not_an_exception.phpt @@ -12,9 +12,8 @@ $gen->throw(new stdClass); ?> --EXPECTF-- -Fatal error: Uncaught Error: Cannot throw objects that do not implement Throwable in %s:%d +Fatal error: Uncaught TypeError: Generator::throw() expects parameter 1 to be Throwable, object given in %s:%d Stack trace: -#0 [internal function]: gen() -#1 %s(%d): Generator->throw(Object(stdClass)) -#2 {main} +#0 %s(%d): Generator->throw(Object(stdClass)) +#1 {main} thrown in %s on line %d diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index f5d692ad32..26184d3d35 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -26,6 +26,7 @@ #include "zend_objects.h" #include "zend_objects_API.h" #include "zend_globals.h" +#include "zend_closures_arginfo.h" #define ZEND_CLOSURE_PRINT_NAME "Closure object" @@ -591,32 +592,12 @@ ZEND_COLD ZEND_METHOD(Closure, __construct) } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_bindto, 0, 0, 1) - ZEND_ARG_INFO(0, newthis) - ZEND_ARG_INFO(0, newscope) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_bind, 0, 0, 2) - ZEND_ARG_INFO(0, closure) - ZEND_ARG_INFO(0, newthis) - ZEND_ARG_INFO(0, newscope) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_call, 0, 0, 1) - ZEND_ARG_INFO(0, newthis) - ZEND_ARG_VARIADIC_INFO(0, parameters) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_fromcallable, 0, 0, 1) - ZEND_ARG_INFO(0, callable) -ZEND_END_ARG_INFO() - static const zend_function_entry closure_functions[] = { - ZEND_ME(Closure, __construct, NULL, ZEND_ACC_PRIVATE) - ZEND_ME(Closure, bind, arginfo_closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_MALIAS(Closure, bindTo, bind, arginfo_closure_bindto, ZEND_ACC_PUBLIC) - ZEND_ME(Closure, call, arginfo_closure_call, ZEND_ACC_PUBLIC) - ZEND_ME(Closure, fromCallable, arginfo_closure_fromcallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE) + ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_MALIAS(Closure, bindTo, bind, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC) + ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC) + ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_FE_END }; diff --git a/Zend/zend_closures.stub.php b/Zend/zend_closures.stub.php new file mode 100644 index 0000000000..cc859b2b10 --- /dev/null +++ b/Zend/zend_closures.stub.php @@ -0,0 +1,17 @@ +test(); ?> --EXPECTF-- -Exception in %s:%d -Stack trace: -#0 {main} - -Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "unknown" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d +Fatal error: Uncaught TypeError: trace is not an array in %s:%d +%a + thrown in %s on line %d diff --git a/sapi/cli/tests/005.phpt b/sapi/cli/tests/005.phpt index 0a366b6975..d268104606 100644 --- a/sapi/cli/tests/005.phpt +++ b/sapi/cli/tests/005.phpt @@ -37,7 +37,7 @@ string(183) "Class [ class stdClass ] { } " -string(1607) "Class [ class Exception implements Throwable ] { +string(1969) "Class [ class Exception implements Throwable ] { - Constants [0] { } @@ -60,42 +60,72 @@ string(1607) "Class [ class Exception implements Throwable ] { - Methods [11] { Method [ final private method __clone ] { + + - Parameters [0] { + } } Method [ public method __construct ] { - Parameters [3] { - Parameter #0 [ $message ] - Parameter #1 [ $code ] - Parameter #2 [ $previous ] + Parameter #0 [ string $message ] + Parameter #1 [ int $code ] + Parameter #2 [ ?Throwable $previous ] } } Method [ public method __wakeup ] { + + - Parameters [0] { + } } Method [ final public method getMessage ] { + + - Parameters [0] { + } } Method [ final public method getCode ] { + + - Parameters [0] { + } } Method [ final public method getFile ] { + + - Parameters [0] { + } } Method [ final public method getLine ] { + + - Parameters [0] { + } } Method [ final public method getTrace ] { + + - Parameters [0] { + } } Method [ final public method getPrevious ] { + + - Parameters [0] { + } } Method [ final public method getTraceAsString ] { + + - Parameters [0] { + } } Method [ public method __toString ] { + + - Parameters [0] { + } } } }