- Issue created by @Chris64
- Status changed to Closed: won't fix
9 months ago 4:10pm 27 February 2024 - π¦πΊAustralia dpi Perth, Australia
Generated files are immune to CS changes, and are better off for it. Generated files should only receive changes if there is a fundamental incompatibility due, such as API/PHP changes.
You can see at the top of these files they have an cs ignore directive.
- π«π·France Chris64 France
Yes @dpi, I saw that: // phpcs:ignoreFile. But here it is about code instruction changes. I ask the question: Should we make some change in this kind of files? Your answer is: We should not.
Yes it is a special case. A reason why this issue exists. Critical.
I made the distinction between generated files and generator files. If some changes are made in the generator, some changes will happen in the generated files. And the generated need to be regenerated. Hence the generator is the key.
(The generated files are in the Drupal core package and are not regenerated during a drush cr.)
One an other hand the directive π Switch long-form single-line assign and null coalesce (= ??) to null coalesce assign operator (??=) Needs work is,
.... assume there are many similar changes we could make across all of core, and ideally a coding standards sniff we could enable to prevent this code from creeping back in.
and if I ignore some cases I face a kind of contradiction with this goal.
- π«π·France Chris64 France
The generator file should also concerned by the phpcs. However this file is not protected by the instruction
// phpcs:ignoreFile
. Probably the nowdoc block used is ignored by phpcs. - π«π·France Chris64 France
@dpi, after reading your comments I think the actual problem exposition is not clear enough: generator is not present as it should be. The title and the IS should be changed.
To be more faithful the title might be changed to "... generator and their generated files".
In fact, the ask is about a change in the generator. A Drupal authority has to decide if the asked change is acceptable or not.
If the generator is altered, the regenarated files will be too. The generated files must be in the package. Either the generator script must be applied, or the original generated files must be altered in accordance with the generator.
The motivation for the ask is to make the changes
!isset()
to??=
in the code wherever possible. - Merge request !6942!isset to ??=: modify function lazyLoadItself in generator + their generated: 31 files β (Open) created by Chris64
- Status changed to Needs review
8 months ago 4:55pm 6 March 2024 - π«π·France Chris64 France
A proposal. MR mergeable. Need review. Work done even maybe refused.
Sed used. And not Rector, since I haven't its rule. Normally no files missed. The targeted function is
lazyLoadItself
. 31 files modified. - πΊπΈUnited States smustgrave
Is there a Meta tracking all of these?
Is there a ticket to add a check for this (searching coder now myself)
- π³πΏNew Zealand quietone
There are now several issues on this topic. To help reviews and understand the scoping of the issue it will help if a meta issue is made to discuss the overall change. The issues to implement the change should be children of that meta and then they can be removed as related. Use the component 'other' for these because they are not directly related to a particular subsystem. This is the same component used for Coding Standard fixes.
See special issue titles β for info about '[meta]'
- π«π·France Chris64 France
Actually a parent issue exists, with all the children. Is it the right place for such a [Meta] and discussion? Or some thing else is needed.
Title changed. Is it suitable now?
- π«π·France Chris64 France
To take into account the request #11 π Change !isset to ??= assignment operator: generator and their generated files case. Needs review the parent issue π Use null coalescing assignment operator Active has been updated.
- πΊπΈUnited States smustgrave
Just FYI not ignoring these just trying to find out the correct way these kind of changes are handled. If a check needs to be in place before making these changes for example
- Status changed to Needs work
8 months ago 4:06pm 19 March 2024 - π«π·France Chris64 France
Okay @smustgrave, an important information. How to do this with phpcs due to the obstruction in that case?
- π«π·France Chris64 France
For a method without phpcs. (supposing phpcs part done, processing the remaining part.) Supposing the concerned instruction is
!isset($this->service)
. To get a file list,
sudo grep -nr \!isset | grep service\)
To verify the instructions,
sudo grep -nrA 2 \!isset\(\$this-\>service\)
In the files list, to distinguish generator and generated, as simply generated files are different but the instruction is always at the same line. For generator the line number is singular. - Status changed to Needs review
8 months ago 3:33pm 25 March 2024 - Status changed to Postponed
8 months ago 11:32pm 26 March 2024 - πΊπΈUnited States smustgrave
On the coding standard decision #3436307: Change !isset to the null coalescing assignment operator ??= β