-
Notifications
You must be signed in to change notification settings - Fork 51
New with parentheses #20
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
Conversation
@carusogabriel I can write the sniff for https://github.com/slevomat/coding-standard, would it be ok? |
@kukulich Perfect. I'm not good at sniffers, so I appreciate your help 😄 |
Please test: slevomat/coding-standard@a3c36e9 |
tests/fixed/new-with-parentheses.php
Outdated
$foo = new \DateTimeImmutable(); | ||
|
||
$barClassName = 'Bar'; | ||
$bar = new $barClassName(); |
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 aligned with the one in the line above (this file only)
tests/fixed/new-with-parentheses.php
Outdated
$bar = new $barClassName(); | ||
|
||
$classNamesInArray = ['Baz']; | ||
$foo = new $classNamesInArray[0](); |
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 aligned with the one in the line above (this file only)
tests/fixed/new-with-parentheses.php
Outdated
$classNamesInArray = ['Baz']; | ||
$foo = new $classNamesInArray[0](); | ||
|
||
$classNamesInObject = new stdClass(); |
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 aligned with the one in the line bellow (this file only)
tests/fixed/new-with-parentheses.php
Outdated
|
||
$classNamesInObject = new stdClass(); | ||
$classNamesInObject->foo = 'Foo'; | ||
$foo = new $classNamesInObject->foo(); |
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 aligned with the one in the line above (this file only)
lib/Doctrine/ruleset.xml
Outdated
@@ -95,6 +95,8 @@ | |||
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/> | |||
<!-- Require language constructs without parentheses --> | |||
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/> | |||
<!-- Require new instances with parentheses --> | |||
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParenthesesSniff"/> |
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 What is the correct Sniff name? Travis isn't find 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.
@carusogabriel Remove "Sniff" at the end :)
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
composer.json
Outdated
@@ -18,7 +18,7 @@ | |||
"php": "^7.1", | |||
"squizlabs/php_codesniffer": "^3.2", | |||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2", | |||
"slevomat/coding-standard": "^4.3.0" | |||
"slevomat/coding-standard": "dev-master" |
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 needs to become a stable dependency before merging
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.
+ requires bump once tagged in 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.
4.4 is out
@carusogabriel I'd say this is good to go. We just need a stable version of |
@carusogabriel I only wait for confirmation that slevomat/coding-standard#258 is ok and I'll do a release. |
@carusogabriel Version bumped in 979478d. |
Please, always rebase on top of master, not merge it into PR branch. |
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.
🚢
Something to start with: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.10/src/Fixer/Operator/NewWithBracesFixer.php
Already proposed and voted in #9 (comment)