- π³πΏNew Zealand quietone
What exactly is the actionable proposed resolution here? is it to make an issue in core to enable
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"
?Has anyone done a documentation search to see if anything needs to change?
- π¬π§United Kingdom jonathan1055
What exactly is the actionable proposed resolution here? is it to make an issue in core to enable SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator?
Yes that is it. Reading comments #5-9 it suggests that two years ago Core was fixed to use the
??
operator. But we need a core issue to add the sniff. That issue will also be used to re-check if anything has regressed.https://www.drupal.org/docs/develop/standards/php/php-coding-standards#o... β is probably the place where this new standard should be stated.
- Status changed to Needs review
over 1 year ago 3:43am 6 September 2023 - π³π±Netherlands bbrala Netherlands
Fixed IS XML visibilty.
This also seems fine for announcement like this.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
I agree, adding a cs rule for this is a good idea and the rules already exist as well. +1
- Status changed to Needs work
over 1 year ago 8:42am 28 October 2023 - π¬π§United Kingdom jonathan1055
@borisson_ could you update the issue summary to follow the new Coding Standard template? To get the new template, probably the easiest way is to create a new issue, copy/paste the template then discard that issue. Put yourself as a supporter and then fill in as much as you can of the rest of it. Setting to 'needs work' for this.
- π³πΏNew Zealand quietone
The Coding Standards Committee has developed a custom issue template β to assist in managing issues efficiently. We have already found that it's use is helping. For issues created before the template was in use I am adding the new template to the Issue Summary and asking everyone here to help convert to it..
Thank you for your help!
- π¬π§United Kingdom jonathan1055
Made some updates to fill in the new template. Other supporters are required, please add your own (I don't think it is right for anyone to add someone else's name)
The proposed text is currently very short. Do we need an example?
Does the standard / sniff cover other null-coalescing operators, such as assignment using
??=
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Added my name to support. Thanks for updating the issue summary @jonathan1055 π
- π¬π§United Kingdom jonathan1055
I have created a change record but I think it needs more detail. Do we just state the new coding standard text, as shown in the issue summary here?
- Status changed to RTBC
over 1 year ago 10:19pm 19 November 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
The CR looks good to me, I think this is now back for another consideration before an announcement
- Status changed to Needs work
over 1 year ago 9:00am 20 November 2023 - π¬π§United Kingdom jonathan1055
@larowlan I think you must have submitted with stale form data or something, as your updated in #28 has reverted all the changes we made since #23 to bring in the new template and proposed text.
- Status changed to Needs review
over 1 year ago 9:07pm 20 November 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Hmm, I thought all I did was mark 'Add a change record' as done.
I reverted to the previous version and tried again
Apologies
- π¬π§United Kingdom jonathan1055
Thanks for reverting, and getting us back on track.
I have just two questions (from #24) to resolve before this goes to the Coding Standards meeting for review
- Do we also want to include the null coalese equal operator
??=
in this standard? There is a separate phpcodesniffer rule for it, so we can include both in the new standard, and the implementation of the sniffs to enforce can be independent. - Does the proposed text need an example?
- Do we also want to include the null coalese equal operator
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Do we also want to include the null coalese equal operator ??= in this standard? There is a separate phpcodesniffer rule for it, so we can include both in the new standard, and the implementation of the sniffs to enforce can be independent.
I think we should do that in a separate issue to keep the scope tighter and increase the chance of this progressing.
Does the proposed text need an example?
Added one
- Status changed to RTBC
over 1 year ago 1:14pm 23 November 2023 - π¬π§United Kingdom jonathan1055
Agreed,
??=
can be a separate issue.Thanks for adding the example. I have updated the change request β with the same exampe.
I think this is RTBC for the next Standards Meeting. But if anyone sees a problem, feel free to revert to 'needs work' and explain what's missing.
- π¬π§United Kingdom jonathan1055
The announcement has been published
https://www.drupal.org/about/core/blog/coding-standards-proposals-for-fi... β
so removing the "Needs announcement for final discussion" tag.
Now at step 5 - π³πΏNew Zealand quietone
I am late to reviewing this. The proposed text states "Null-coalescing operators such as ??" but "??" is the null coalescing operator. So, it should be
The null coalescing operator
??
should be used to make code more readable. For example use$value = $values['entry'] ?? '';
instead of$value = isset($values['entry']) ? $values['entry'] : '';
and I am thinking further to
The null coalescing operator
??
should be used instead of the ternary operator. For example use$value = $values['entry'] ?? ';'
instead of$value = isset($values['entry']) ? $values['entry'] : '';
But the second idea may be a step to far at this stage.
- π³π±Netherlands arkener
Agree with #35, the current description might indicate that the null coalescing assignment operator is included in this coding standard. Scoping this in the description to
??
would clarify this.I would also clarify the title a bit, the current title has some ambiguity in regards to what we 're replacing.
Use Null-Coalescing Operator ?? to replace isset with ternary operator
with something like
Use Null-Coalescing Operator ?? instead of a ternary operator with an isset statement
- π¬π§United Kingdom jonathan1055
#35 and #36 are both excellent improvements. +1 for updating the title and IS with that.
Also the example, it would be easier to read if we changed the name of $value, maybe to $result or anything other than $value. Then we don't have the extra cognative overload of dealing with $value and $values. The examples must be really clear and simple.
- π¦πΉAustria drunken monkey Vienna, Austria
I agree with #35 and #37. (#36 seems like it has been addressed already?) So maybe something like this:
The null coalescing operator
??
should be used instead of a ternary operator with anisset()
condition. For example, use$result = $values['entry'] ?? ';'
instead of$result = isset($values['entry']) ? $values['entry'] : '';
. - π¬π§United Kingdom jonathan1055
Updated IS with the agreed changes in #36-39
- πΊπΈUnited States dww
This is now formally pending review by core committers. Tagging as such.
- π³π±Netherlands bbrala Netherlands
As per meeting 26-3-2024 by larowlan, this has been approved.
- π³πΏNew Zealand quietone
The was brought up as the core committer meeting on 5 Mar. There was only positive feedback.
- π³π±Netherlands bbrala Netherlands
I don't have permissions right now to do the doc updates. We are working on that.
- π³π±Netherlands bbrala Netherlands
Documentation is updated. Think this is all done :)
I'm not completely sure on the credit rules for this project. So keeping rtbc unril credits are fixed.
- π³πΏNew Zealand quietone
I reviewed the documentation updates and they agree with the Issue Summary.
The core issue exists, π Switch long-form single-line assign and null coalesce (= ??) to null coalesce assign operator (??=) Needs workSo, it is just the publishing of the change record that needs to be done.
- π³π±Netherlands bbrala Netherlands
Think you misreferenced @quietone. I didnt find one specifically for this change. So made π Enforce null coalescing operator ?? instead of a ternary operator through phpcs Fixed .
- Status changed to Fixed
12 months ago 7:58pm 8 May 2024 - π³π±Netherlands bbrala Netherlands
Published the CR, since all is done i'm going ahead and set this to fixed :) Thanks everyone.
Automatically closed - issue fixed for 2 weeks with no activity.