- Issue created by @Chris64
- Status changed to Needs review
10 months ago 2:43pm 23 February 2024 - π«π·France Chris64 France
A Commit corresponding nearly to the patch 9B β . As said in #9 π Switch long-form single-line assign and null coalesce (= ??) to null coalesce assign operator (??=) Needs work this need review and comments.
- Status changed to Needs work
10 months ago 2:55pm 23 February 2024 - πΊπΈUnited States smustgrave
Also if this is a spin off of the other ticket can it be noticed how come?
Also if comments can be copied so reviewers/committers don't have to jump between tickets to follow a conversation.
- π«π·France Chris64 France
The MR faced obstructions from phpstan: 4 = 2x2 errors: 2 files,
------ --------------------------------------------------------------------------------------------- Line core/modules/views/src/Plugin/views/display/PathPluginBase.php ------ --------------------------------------------------------------------------------------------- Ignored error pattern #^Variable \$access_plugin in isset\(\) always exists and is not nullable\.$# in path /builds/issue/drupal-3423310/core/modules/views/src/Plugin/views/display/PathPluginBase.php was not matched in reported errors. 199 Variable $access_plugin on left side of ??= always exists and is not nullable. ------ --------------------------------------------------------------------------------------------- ------ --------------------------------------------------------------------------------------------------- Line core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php ------ --------------------------------------------------------------------------------------------------- Ignored error pattern #^Variable \$message in isset\(\) always exists and is not nullable\.$# in path /builds/issue/drupal-3423310/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php was not matched in reported errors. 309 Variable $message on left side of ??= always exists and is not nullable. ------ --------------------------------------------------------------------------------------------------- [ERROR] Found 4 errors
The problem seems not the present code transformation but an other problem. To allow a MR we propose,
- to remove these 2 files from this MR,
- to create an other issue about these phpstan problems,
- to treat in an other issue the ??= code transformation of these 2 remaining files. - Status changed to Needs review
10 months ago 9:53pm 25 February 2024 - π«π·France Chris64 France
Okay @smustgrave: MR is powerful, compare to patch. Lot of validation work is made by the machine. Now MR mergeable got, the human work needed is smaller.
Then, compared to the initial goal,
ideally a coding standards sniff we could enable to prevent this code from creeping back in.
all the cases are not considered here. Two sets are known missing: #8 π Use null coalescing assignment operator: multi-lines case. Needs work and #9 π Use null coalescing assignment operator: multi-lines case. Needs work .
#8 is not explicit enough about "generated files". That is some php files with header,/** * This file was generated via php core/scripts/generate-proxy-class.php <*> <*>. */
I plan 2 other issues for them.
- πΊπΈUnited States smustgrave
Do you know if there is a code sniffing rule we could enable that would prevent these from coming back?
- Status changed to Needs work
10 months ago 1:47am 8 March 2024 The Needs Review Queue Bot β tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- π«π·France Chris64 France
As observed by @dpi for an other case π Switch long-form single-line assign and null coalesce (= ??) to null coalesce assign operator (??=) Needs work , some files are missed. Since some directories was ignored.
- π«π·France Chris64 France
A new commit, since a rebase was needed. 4 conflicts, in,
core/lib/Drupal/Core/Database/Query/Insert.php core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php core/modules/workspaces/src/WorkspaceManager.php core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php
- Status changed to Needs review
10 months ago 6:55pm 8 March 2024 - π«π·France Chris64 France
MR mergeable. NR.
Two sets are voluntary ignored here,
- generator/generated files π Change !isset to ??= assignment operator: generator and their generated files case. Needs review .
- 2 files with phpstan obstruction π Use null coalescing assignment operator ??=: phpstan obstruction case. Closed: won't fix .For a code sniff rule, this multi-line case is much more complicate than the uni-line case. Since several different configurations exist, and many should be exclude from this transformation:
if else
,if elseif
, etc.The sed command used has a rule to reach the good targets. Not perfect. Maybe the best is to use rector rule, as suggest by @dpi in #3418494-#23 π Switch long-form single-line assign and null coalesce (= ??) to null coalesce assign operator (??=) Needs work . However the rule doesn't exist (?).
Questions,
-1. Did the transformations done are right?
-2. Did some files are missed?
-3. Did some cases are missed? - π«π·France Chris64 France
Do you know if there is a code sniffing rule we could enable that would prevent these from coming back?
Okay @smustgrave, you mean a rule for phpcs... There is,
slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/RequireNullCoalesceEqualOperatorSniff
but is missing indrupal/coder/coder_sniffer/Drupal/ruleset.xml
. That is,
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator" />
Maybe to be after,
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
- Status changed to Needs work
9 months ago 12:21pm 21 March 2024 The Needs Review Queue Bot β tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs review
9 months ago 4:07pm 23 March 2024 - π«π·France Chris64 France
and ideally a coding standards sniff we could enable to prevent this code from creeping back in.
A coding standards sniff rule now ready for this multi-line case. And now case fixable with
phpcbf
. MR mergeable. Need review. - π«π·France Chris64 France
phpcs
command used,
phpcs --standard=SlevomatCodingStandard --sniffs=SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperatorIsset --extensions=php,module,inc core
The fileRequireNullCoalesceOperatorIssetSniff.php
has to be in the right place: inslevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures
, in/home/.config/composer/vendor
. - πΊπΈUnited States smustgrave
On the coding standard decision #3436307: Change !isset to the null coalescing assignment operator ??= β
- Status changed to Postponed
9 months ago 11:31pm 26 March 2024