-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Add phpcs to build and apply automatic fixes #1743
Conversation
@@ -200,7 +205,7 @@ public function facet() | |||
* @see http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/ | |||
* | |||
* @param float|array|Point $x | |||
* @param float $y | |||
* @param float $y |
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.
We have a rule to align params?
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.
Apparently. Personally, I dislike it but I tried to not deviate too much from our official coding standard (except for space before colon because what kind of monster would want that?!?)
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.
except for space before colon because what kind of monster would want that?!?
Me for example. 🐲
namespace Doctrine\ODM\MongoDB\Aggregation\Stage; | ||
|
||
/** | ||
* Fluent interface for adding a $addFields stage to an aggregation pipeline. | ||
* | ||
* @author Boris Guéry <guery.b@gmail.com> |
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.
Nitpicking, but empty line above should be removed
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.
@kukulich might know if that's easily added to the sniff in question - if not I'd leave it until the sniff can deal with it.
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.
It's not the only place, is there any way to configure CS fixer to disallow empty lines in comments when it's last line?
EDIT: or first line as well
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.
I'll improve/fix the fixer. I hope it will be done today in next bugfix version.
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.
No rush - we'll have plenty more pull requests until we're done fixing phpcs in this project. Thank you for your help!
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.
Have experienced that one in doctrine/doctrine2#7046 as well
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 can try dev-master
of Slevomat CS.
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.
Hmm, been fixing these empty lines manually... :| You have it too easy @alcaeus. :P
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.
@kukulich Btw same applies to TypeHintDeclaration sniff when @param
/@return
is removed. That really sounds like a candidate for DocCommentSpacingSniff
? 😊
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.
Yes, new sniff is the best solution. It should be easy so maybe in the weekend or next week :)
* @param array $changeSet | ||
* | ||
* @param object $document | ||
* @param array $changeSet |
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.
This is not treated as redundant with method definition?
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.
Interesting, seems to be a bug. I'll revisit those anyways when requiring 7.2 and introducing object
typehint along with scalar typehints.
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.
object
is not required because of enableObjectTypeHint
option that is enabled by default only if you run phpcs on PHP 7.2+.
array
is ok because there is <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification" />
in phpcs.xml.
* | ||
* @return void |
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.
This got removed even though there's no : void
in the definition, is it desirable? I mean will some tool later infer that there's no return
in the function so : void
should be added?
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.
On the other hand next methods don't have @return void
at all so I guess it's not a big deal
* @return MongoDBException | ||
*/ | ||
public static function invalidValueForType($type, $expected, $got) | ||
{ | ||
if (is_array($expected)) { | ||
$expected = sprintf('%s or %s', | ||
$expected = sprintf( | ||
'%s or %s', | ||
join(', ', array_slice($expected, 0, -1)), |
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.
Forbidden functions are not changed automatically or it's not that version of our CS yet?
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.
It doesn't fix them automatically (it allows free configuration, so function signatures may vary), which is why it's not fixed in this PR.
new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document)) | ||
)); | ||
if (! empty($class->lifecycleCallbacks[Events::preUpdate])) { | ||
$class->invokeLifecycleCallbacks(Events::preUpdate, $document, [new PreUpdateEventArgs($document, $this->dm, $this->uow->getDocumentChangeSet($document))]); |
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.
Are we ignoring line's length from now on?
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.
PSR-2 does not include a hard limit. That said, I'm fine changing any lines you mark as "too long, could be split into multiples" 😛
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.
No need, it just stood out, I don't mind scrolling sideways that much ;)
.travis.yml
Outdated
script: | ||
- vendor/bin/phpstan analyse -l 1 lib | ||
|
||
- stage: Code Quality | ||
php: 7.2 |
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.
This should be 7.1 since 7.1 is required in composer, otherwise you may end up with object
typehint.
ff0d2c4
to
60e293e
Compare
Yeah, have to catch up with the times...we're running an antique version of our coding-standard here 😉 |
aee5bea
to
e8fafce
Compare
Damn, I thought I had that in there as well. Yes, feel free to do so. |
Part of #1702. To help with reviews, this PR only applies automatic fixes and disables all other sniffs for later fixing.
Note: some tests fail, these will have to be fixed. Most of them are due to strict typing.
Note: if you want to expand all diffs by default (at your own risk), you can copy the following snippet into the dev console while on the "Files changed" tab: