I noticed a couple calls to phpunit assertEquals which clearly had the "expected" and "actual" parameters reversed, which can lead to confusing failure messages (and accidental propagation of the incorrect form, when other people copy/paste code blocks that look good). Anyway, I did a search and found a few more where obvious strings or integers, etc, were in the "actual" position. This is a very simple issue, but might as well be fixed...
| Comment | File | Size | Author |
|---|
Issue fork drupal-2879159
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2879159-some-calls-to
changes, plain diff MR !704
Comments
Comment #2
lomo commentedPatch uploaded.
Comment #5
borisson_I don't the value of this outweighs the cost of having other patches needing rerolls.
Comment #6
borisson_In addition to #5 (limited value), we should only do this if we can write a phpcs rule to ensure that this behavior stays consistent.
Comment #8
joachim commented> if we can write a phpcs rule to ensure that this behavior stays consistent.
I don't see how we could write a test that properly enforces this. Sometimes $expected is an expression as well as $actual. Best we could do is enforce that $actual is ALWAYS an expression and never a constant value.
But I don't think that should hold this patch up.
Comment #15
spokjeStumbled over a PhpStorm warning about the reverse arguments in one
9.3.xfile and ran the inspection on the whole ofcore/.Comment #16
spokjeComment #17
spokjeHidden
2879159-2.patch.Comment #19
spokjeComment #20
spokjeComment #21
quietone commented@Spokje, what inspection are you referring to in #15? Is it just available with PhpStorm?
Comment #22
spokje@quietone This is the PHPStorm inspection I referred to: https://www.jetbrains.com/help/phpstorm/php-misordered-assertequals-asse...
Comment #23
quietone commentedAh, so no way to prevent this from happening again in core?
Comment #24
spokje@quietone: Nope, looks like that PHPStorm inspection is doing exactly what @joachim stated in #18 (emphasis mine)
And I fully agree with the last line of the quote.
Basically: Waiting on a new sniff would take time, and the sniff will never be perfect.
Comment #25
quietone commented@Spokje, my apologies. I should have read all the comments.
Assigning to myself for review. Hope to do it in the next few days.
Comment #26
mondrakeComment #27
quietone commentedmondrake did a review before I could.
Comment #28
ravi.shankar commentedWorking on above feedbacks.
Comment #29
mondrake@quietone I stepped on your toes, sorry
Comment #30
ravi.shankar commented@mondrake, please review if this is fine.
Comment #31
mondrakeHousekeeping this is a bit like Penelope's shroud, but all the changes here seem OK to me. Till the next time...
Comment #32
spokjeThanks @mondrake
Totally agree, but there's really no sniff (I can think of) that will catch-'em-all. So I fear/think this is the best we can run with at this point in time.
Comment #35
catchCommitted/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!