Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReflectionParameter param information for functions and methods? #64

Open
TysonAndre opened this issue Feb 10, 2020 · 1 comment · Fixed by #76
Open

Add ReflectionParameter param information for functions and methods? #64

TysonAndre opened this issue Feb 10, 2020 · 1 comment · Fixed by #76

Comments

@TysonAndre
Copy link
Contributor

TysonAndre commented Feb 10, 2020

and return for some methods.

Currently, ReflectionFunctionAbstract->getParameters() reports most of these have no parameters, in 4.0.5.2.

Instead of arginfo, NULL is passed.

Would you be interested in PRs to add this info, or on working on it yourself?

EDIT: public function get($arg, &$arg, &$arg) {} and function memcache_get($arg, $arg, &$arg, &$arg) {} should also use distinct parameter names

https://github.com/php/php-src/blob/master/scripts/dev/gen_stub.php may be useful to generate readable stub info from a php stub file, but the output is only meant for php 8 and would need to be changed.

zend_function_entry memcache_functions[] = {
	PHP_FE(memcache_connect,				NULL)
	PHP_FE(memcache_pconnect,				NULL)
	PHP_FE(memcache_add_server,				NULL)
	PHP_FE(memcache_set_server_params,		NULL)
	PHP_FE(memcache_set_failure_callback,	NULL)
	PHP_FE(memcache_get_server_status,		NULL)
	PHP_FE(memcache_get_version,			NULL)
	PHP_FE(memcache_add,					NULL)
	PHP_FE(memcache_set,					NULL)
	PHP_FE(memcache_replace,				NULL)
	PHP_FE(memcache_cas,					NULL)
	PHP_FE(memcache_append,					NULL)
	PHP_FE(memcache_prepend,				NULL)
	PHP_FE(memcache_get,					arginfo_memcache_get)
	PHP_FE(memcache_delete,					NULL)
	PHP_FE(memcache_debug,					NULL)
	PHP_FE(memcache_get_stats,				NULL)
	PHP_FE(memcache_get_extended_stats,		NULL)
	PHP_FE(memcache_set_compress_threshold,	NULL)
	PHP_FE(memcache_increment,				NULL)
	PHP_FE(memcache_decrement,				NULL)
	PHP_FE(memcache_close,					NULL)
	PHP_FE(memcache_flush,					NULL)
	PHP_FE(memcache_set_sasl_auth_data,		NULL)
	{NULL, NULL, NULL}
};

static zend_function_entry php_memcache_pool_class_functions[] = {
	PHP_NAMED_FE(connect,				zif_memcache_pool_connect,			NULL)
	PHP_NAMED_FE(addserver,				zif_memcache_pool_addserver,		NULL)
	PHP_FALIAS(setserverparams,			memcache_set_server_params,			NULL)
	PHP_FALIAS(setfailurecallback,		memcache_set_failure_callback,		NULL)
	PHP_FALIAS(getserverstatus,			memcache_get_server_status,			NULL)
	PHP_NAMED_FE(findserver,			zif_memcache_pool_findserver,		NULL)
	PHP_FALIAS(getversion,				memcache_get_version,				NULL)
	PHP_FALIAS(add,						memcache_add,						NULL)
	PHP_FALIAS(set,						memcache_set,						NULL)
	PHP_FALIAS(replace,					memcache_replace,					NULL)
	PHP_FALIAS(cas,						memcache_cas,						NULL)
	PHP_FALIAS(append,					memcache_append,					NULL)
	PHP_FALIAS(prepend,					memcache_prepend,					NULL)
	PHP_FALIAS(get,						memcache_get,						arginfo_memcache_object_get)
	PHP_FALIAS(delete,					memcache_delete,					NULL)
	PHP_FALIAS(getstats,				memcache_get_stats,					NULL)
	PHP_FALIAS(getextendedstats,		memcache_get_extended_stats,		NULL)
	PHP_FALIAS(setcompressthreshold,	memcache_set_compress_threshold,	NULL)
	PHP_FALIAS(increment,				memcache_increment,					NULL)
	PHP_FALIAS(decrement,				memcache_decrement,					NULL)
	PHP_FALIAS(close,					memcache_close,						NULL)
	PHP_FALIAS(flush,					memcache_flush,						NULL)
	PHP_FALIAS(setSaslAuthData,			memcache_set_sasl_auth_data,				NULL)
	
	{NULL, NULL, NULL}
};

static zend_function_entry php_memcache_class_functions[] = {
	PHP_FALIAS(connect,					memcache_connect,					NULL)
	PHP_FALIAS(pconnect,				memcache_pconnect,					NULL)
	PHP_FALIAS(addserver,				memcache_add_server,				NULL)
	{NULL, NULL, NULL}
};

Motivations

  • Improve quality of PHP's error messages and static analysis of code using memcache (e.g. with Phan/Psalm)
  • Make tooling using Reflection information work better.
@TysonAndre
Copy link
Contributor Author

I was going to suggest using https://github.com/JetBrains/phpstorm-stubs/blob/master/memcache/memcache.php , but that's also missing the parameters (based on Reflection).

In addition to the IDE, many third party projects (e.g. analyzers) use those stubs, so I or someone else should create a PR to update those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant