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

Warn about passing named arguments to most internal functions with varargs #4284

Closed
TysonAndre opened this issue Dec 7, 2020 · 0 comments · Fixed by #4294
Closed

Warn about passing named arguments to most internal functions with varargs #4284

TysonAndre opened this issue Dec 7, 2020 · 0 comments · Fixed by #4294
Labels
enhancement This improves the quality of Phan's analysis of a codebase php8 Tracks changes to prepare for analyzing php 8 code

Comments

@TysonAndre
Copy link
Member

TysonAndre commented Dec 7, 2020

Excluding call_user_func, most functions probably can't handle them?

<?php
printf('%s', name: 'name');
// Fatal error: Uncaught ArgumentCountError: printf() does not accept unknown named parameters

Observed: does not warn

Exceptions are marked with Z_PARAM_VARIADIC_WITH_NAMED

/* {{{ Call a user function which is the first parameter
   Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
PHP_FUNCTION(call_user_func)
{
	zval retval;
	zend_fcall_info fci;
	zend_fcall_info_cache fci_cache;

	ZEND_PARSE_PARAMETERS_START(1, -1)
		Z_PARAM_FUNC(fci, fci_cache)
		Z_PARAM_VARIADIC_WITH_NAMED(fci.params, fci.param_count, fci.named_params)
	ZEND_PARSE_PARAMETERS_END();
@TysonAndre TysonAndre added enhancement This improves the quality of Phan's analysis of a codebase php8 Tracks changes to prepare for analyzing php 8 code labels Dec 7, 2020
TysonAndre added a commit to TysonAndre/phan that referenced this issue Dec 11, 2020
Warn about code such as `sprintf('foo=%s', foo: 'value')`

Fixes phan#4284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This improves the quality of Phan's analysis of a codebase php8 Tracks changes to prepare for analyzing php 8 code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant