You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run a basic PHPDoc type checker over the code, and tidied up a few things. I think it's probably good for moodle-cs to set a good example.
Note: I know the PHPCS Sniff function process() specifies its return type as void|int, but AFAIK, void is a stand-alone type, and int|null is the correct type.
None of the process() methods that I looked at had a return that was anything other than void (i.e. return;). Where are you seeing int returns? Also, if nullable int were the correct return value, I'd lean towards ?int over int|null because - to me - it implies "sometimes you get an integer" as opposed to "sometimes you get an integer which means A and sometimes you get null which means B".
I hope that helps! I'm sure others will have more comprehensive feedback.
Yeah, I don't think any of the process methods in moodle-cs return int. It would also be valid to specify the return type as just null. It's in the base method, though, and I didn't think there was any point narrowing it. https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Sniffs/Sniff.php
The return statements should probably say return null; for good style, but PHP defaults to null if trying to read the return value of a function when none was provided.
I used int|null because it conforms to PSR-5, which I've been told the Moodle code base uses, so I've leaned into this style where possible. Maybe it's not appropriate for moodle-cs, though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've run a basic PHPDoc type checker over the code, and tidied up a few things. I think it's probably good for moodle-cs to set a good example.
Note: I know the PHPCS Sniff function process() specifies its return type as void|int, but AFAIK, void is a stand-alone type, and int|null is the correct type.