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

Ignore parent parameter name mismatch #2315

Merged
merged 1 commit into from
May 26, 2021
Merged

Conversation

franmomu
Copy link
Contributor

@franmomu franmomu commented May 24, 2021

This could lead to problems using named arguments in PHP 8

Q A
Type improvement
BC Break no
Fixed issues

Summary

Psalm was failing because of https://psalm.dev/docs/running_psalm/issues/ParamNameMismatch/

UPDATE: It would be BC break to change the parameter as pointed out in #2315 (comment), so ignoring the issue for now.

@SenseException
Copy link
Member

Psalm is listing the mismatch because of interchangeable classes that should use the same variable names, but the current renaming would AFAIK also be a BC break.

@franmomu franmomu changed the title Fix parent parameter name mismatch Ignore parent parameter name mismatch May 25, 2021
@franmomu
Copy link
Contributor Author

franmomu commented May 25, 2021

the current renaming would AFAIK also be a BC break.

Makes sense, I've ignored the psalm issues instead.

SenseException
SenseException previously approved these changes May 25, 2021
Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

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

I'm not sure how to handle this in the next major release though.

@malarzm
Copy link
Member

malarzm commented May 25, 2021

Not sure if this is a standard, but lately I've seen @no-named-arguments in PHPUnit (https://github.com/sebastianbergmann/phpunit/blob/564e78a6c088916467cd4bc0af2e1bb9da9b1a0c/src/TextUI/ResultPrinter.php#L16). Personally I'd be happy to slap this on most of our public API, named arguments should be used where it makes sense, not everywhere

@franmomu
Copy link
Contributor Author

In fact, in this case are methods with just one argument which I'm not sure if it makes sense to use named parameters.

About @no-named-arguments 👍, to read more about it: Roave/BackwardCompatibilityCheck#264, but I guess that should be decided internally if apply it or not in general, I'll open an issue in doctrine/persistence.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

IMO:

  • Named parameters are a new feature, which highlights inconsistencies in APIs
  • Such inconsistencies should either be fixed before named args are widely used, or fixed in a backwards compatible way once thy are

Considering that all of these arguments are single, required method arguments, I'll argue that most people won't be using named arguments for that; and if they are then the impact would be caught early (static analysis should catch using named args that don't exist).

Sorry for the back and forth, but it's preferable to rename the arguments for consistency and be done with this. I've left additional comments regarding no-named-arguments in the linked persistence PR, but for ODM I'd definitely prefer cleaning up the API rather than telling people not to use named args.

This could lead to problems using named arguments in PHP 8
@alcaeus alcaeus self-assigned this May 26, 2021
@alcaeus alcaeus dismissed SenseException’s stale review May 26, 2021 06:29

Stale review on different patch.

@alcaeus alcaeus added this to the 2.3.0 milestone May 26, 2021
@alcaeus alcaeus merged commit eb49d59 into doctrine:2.3.x May 26, 2021
@alcaeus
Copy link
Member

alcaeus commented May 26, 2021

Thanks @franmomu!

@franmomu
Copy link
Contributor Author

Sorry for the back and forth, but it's preferable to rename the arguments for consistency and be done with this. I've left additional comments regarding no-named-arguments in the linked persistence PR, but for ODM I'd definitely prefer cleaning up the API rather than telling people not to use named args.

No worries! It's something that has to be discussed.

@franmomu franmomu deleted the fix_psalm branch May 26, 2021 06:32
@alcaeus alcaeus modified the milestones: 2.3.0-alpha1, 2.3.0 Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants