-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve coding standard #1136
Improve coding standard #1136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
tests/PedantryTest.php
Outdated
&& $method->getFileName() === $class->getFileName(); // Exclude methods inherited from traits | ||
}, | ||
fn (ReflectionMethod $method) => $method->getDeclaringClass() == $class // Exclude inherited methods | ||
&& $method->getFileName() === $class->getFileName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You lost the 2nd comment
&& $method->getFileName() === $class->getFileName(), | |
&& $method->getFileName() === $class->getFileName(), // Exclude methods inherited from traits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lesson learned: don't trust phpcbf
to preserve your comments.
68f05c9
to
8950057
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question but LGTM.
<property name="enableMixedTypeHint" value="false" /> | ||
<!-- Requires PHP 8.0 --> | ||
<property name="enableUnionTypeHint" value="false" /> | ||
</properties> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these removed for parameters, properties, and return types? Is it irrelevant since we're forcing a lower php_version
above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. When I added the config we didn't use php_version
yet, so I added these as a safeguard against for when someone runs phpcs on a newer version (I typically run PHP 8.2 these days and only use an older version if necessary for specific testing). This came to bite me when phpcs didn't enforce native property types because the property was still set to false
in this block.
With php_version
this becomes irrelevant and the version set there takes precedence over the PHP version being used to run phpcs, so the auto-detection for those features works again and does not enable mixed types or union types until we update php_version
to 80000
.
This adds a rule requiring arrow functions to our coding standard. In addition to that, I enabled a rule requiring single quotes where possible. Commits are split by rule for a better review experience.
The last commit entails no actual changes, this was left over from before we were specifying a PHP version in the config.