When running phpcbf, the processing of the fix for IncorrectParamVarName does not account for multiple possible types for the param

@param Array|int $arg

is currently being replaced by

@param array $arg

instead of

@param array|int $arg

Comments

anoopjohn created an issue. See original summary.

anoopjohn’s picture

Status: Active » Needs review
StatusFileSize
new10.9 KB

Please find attached a patch that fixes this error. Do note that I have refactored the foreach loop that tested for param types and moved the tests that tested for the type hints outside of the loop. These tests for typehints only runs when the number of types is 1 and the type is not an invalid type. I had to re-factor the foreach because the error was earlier triggering on each type as it loops through the types. I combined these to trigger just one error message and just one fix. Fixing each type individually would have involved keeping track of the string index and imploding and replacing wrong types for each wrong type. I hope this approach is fine. This is the same approach used in return types auto fix.

Edit: Although it looks like there is a lot of changes, if you use git diff -w you can see that the logic for type hints just moved out of the loop.

klausi’s picture

Status: Needs review » Needs work

Patch does not apply anymore, can you reroll?

anoopjohn’s picture

Status: Needs work » Needs review
StatusFileSize
new1.54 KB
new10.92 KB

I have rerolled the patch. Please find attached the patch and the diff.

  • klausi committed 9083c67 on 8.x-2.x authored by anoopjohn
    Issue #2735365 by anoopjohn: Error in fixing incorrect parameter types...
klausi’s picture

Status: Needs review » Fixed

Great work, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.