krakjoe / uopz

User Operations for Zend
Other
358 stars 47 forks source link

Add Reflection information for global functions? #123

Closed TysonAndre closed 3 years ago

TysonAndre commented 4 years ago

Currently, NULL is passed instead of an arginfo structure, so ReflectionFunction has no information for param names, types, or return types. This makes it difficult for tooling using Reflection to check what options are available (e.g. future optional flags) in a given uopz version, or for type checkers to check types or param counts.

For https://www.php.net/uopz_set_return , I'd expect string $function_or_class, $value_or_function, ....)

php > var_export((new ReflectionFunction('uopz_set_return'))->getParameters());
array (
)
#define UOPZ_FE(f) PHP_FE(f, NULL)
static const zend_function_entry uopz_functions[] = {
    UOPZ_FE(uopz_set_return)
    UOPZ_FE(uopz_get_return)
    UOPZ_FE(uopz_unset_return)
// ...
cmb69 commented 4 years ago

It might make sense to use a stub file and gen_stub.php for this; see https://news-web.php.net/php.pecl.dev/16708.

krakjoe commented 3 years ago

Because of the way the API is built, it's not really possible to add useful arginfo.

I prefer to keep the API stable.