Skip to content

Proposal: Rename FFI getFuncArg* to getFuncParameter*, $arg_index->$index #7236

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

Merged
merged 3 commits into from
Jul 14, 2021

Conversation

TysonAndre
Copy link
Contributor

PHP is already already using "Parameter" instead of "Argument" for reflection on types elsewhere.

Parameter is used to refer to the function declarations
(AST_PARAM internally in the AST, ReflectionFunctionAbstract->getParameters(),
etc.)
Argument is used to refer to expressions passed to the functions by the caller
(ArgumentCountError, etc.).
(Error messages were also changed in php 8.x to refer to passing too many arguments to a
function)

Other languages use similar definitions,
e.g. https://developer.mozilla.org/en-US/docs/Glossary/Parameter

Followup to #7217 (review)


Looking at this again, I don't see a need to drop the "Func" - there's already getFuncABI.

If you look at the current implementation, there's getStruct*, getArray*, getPointer*, meaning getFunc* sort of makes sense for a naming scheme to make it easier to find functionality associated with a given function.

PHP is already already using "Parameter" instead of "Argument" for reflection on types elsewhere.

Parameter is used to refer to the function declarations
(AST_PARAM internally in the AST, ReflectionFunctionAbstract->getParameters(),
etc.)
Argument is used to refer to expressions passed to the functions by the caller
(ArgumentCountError, etc.).
(Error messages were also changed in php 8.x to refer to passing too many arguments to a
function)

Other languages use similar definitions,
e.g. https://developer.mozilla.org/en-US/docs/Glossary/Parameter
@TysonAndre TysonAndre requested review from nikic and dstogov July 13, 2021 14:17
Elsewhere, just $index is used in stubs such as for ext/zip
@TysonAndre TysonAndre changed the title Proposal: Rename FFI getFuncArg* to getFuncParameter* Proposal: Rename FFI getFuncArg* to getFuncParameter*, $arg_index->$index Jul 13, 2021
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I also agree to change $arg_index into $index. Thanks.

@TysonAndre TysonAndre merged commit efbdcb8 into php:master Jul 14, 2021
nikic added a commit that referenced this pull request Jul 14, 2021
By convention, parameter names of camel case methods should also
be camel case, i.e. the name should be $fieldName rather than
$field_name.

However, following GH-7236, which changed $arg_index to just $index,
this also changes $field_name to just $name. The fact that it is
a field name is obvious from context.
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 this pull request may close these issues.

3 participants