Skip to content

4.0 (or later) | Named parameter support for PHPCS code #392

Open
@jrfnl

Description

@jrfnl

Setting the scene

PHP 8.0 introduced support for using named parameters in function calls.

While the minimum supported PHP version for PHP_CodeSniffer itself is currently below PHP 8.0 (and will still be with PHPCS 4.0), external standards may choose to have a higher minimum supported PHP version and may like to start using named parameters in function calls.

At this time, PHP_CodeSniffer does not explicitly support the use of named parameters in function calls and supporting this feature would mean that any changes to parameter names will become a backward compatibility break, which can only be made in a major version.

Proposal

I'd like to propose supporting named parameters as of PHPCS 4.0 (?) for the explicit public API.

In practice this means that the following tasks will need to be executed:

  • Annotate what code is considered part of the public API and what code is considered internal API.
  • Review the method signatures of all methods in the public API to have descriptive parameter names and come up with a more detailed proposal of which parameters will be renamed and to what names.
    In particular, I'd advocate to rename parameters which mirror the names of PHP keywords to different names to prevent confusing function calls.
  • Create a patch with the parameter renames for the target major.

Detailed proposal

To be filled in

Opinions ?

I'd welcome opinions on this proposal. In particular, I'd like to get answer to the following questions:

  • Should PHPCS support named parameters ?
  • Should this support be as of PHPCS 4.0 or can this be delayed to PHPCS 5.0 or later ?
  • Are there particular method parameters which come to mind as prime candidates for renaming ?

/cc @asispts @dingo-d @fredden @GaryJones @greg0ire @kukulich @michalbundyra @Ocramius @sirbrillig @stronk7 @weierophinney @wimg

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions