Skip to content

🔧 Update version + some fix #43

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

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Util\Tokens;

/**
* Throws errors if there's no blank line before return statements.
Expand Down Expand Up @@ -92,11 +93,6 @@ public function process(File $phpcsFile, $stackPtr)
*/
private function isComment(array $token)
{
return 'T_COMMENT' === $token['type']
|| 'T_DOC_COMMENT_STRING' === $token['type']
|| 'T_DOC_COMMENT_OPEN_TAG' === $token['type']
|| 'T_DOC_COMMENT_TAG' === $token['type']
|| 'T_DOC_COMMENT_CLOSE_TAG' === $token['type']
|| 'T_DOC_COMMENT_WHITESPACE' === $token['type'];
return in_array($token['code'], Tokens::$commentTokens);
}
}
10 changes: 1 addition & 9 deletions SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ public function process(File $phpcsFile, $stackPtr)

while (false !== $classUsed) {
if (strtolower($tokens[$classUsed]['content']) === $lowerClassName) {
// If the name is used in a PHP 7 function return type declaration stop.
if (T_RETURN_TYPE === $tokens[$classUsed]['code']) {
return;
}

$beforeUsage = $phpcsFile->findPrevious(
Tokens::$emptyTokens,
($classUsed - 1),
Expand All @@ -125,10 +120,7 @@ public function process(File $phpcsFile, $stackPtr)
}
}

$classUsed = $phpcsFile->findNext(
[T_STRING, T_RETURN_TYPE],
($classUsed + 1)
);
$classUsed = $phpcsFile->findNext([T_STRING], ($classUsed + 1));
}

// More checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function invalidFunctionReturnTwo()
function invalidFunctionReturnThree()
{
echo "";

/**
* comment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function getErrorList()
return array(
60 => 1,
67 => 1,
76 => 1,
);
}

Expand Down
6 changes: 3 additions & 3 deletions SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use Route;
use ORM;
use Truc;
use Machin;
use Machine;
use Unused;
use Client;
use Clients;
use PasClient;
use Somewhere\Something;

class Container
{
Expand All @@ -23,9 +23,9 @@ class Container
*
* @param Toto $toto
* @var Truc $truc
* @return Machin|Machine
* @return Machin|\Machine
*/
function test (Bar $bar)
function test (Bar $bar): Something
{
/** @var Client|Clients[]|PasClient $client */

Expand Down
6 changes: 3 additions & 3 deletions SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use Route;
use ORM;
use Truc;
use Machin;
use Machine;
use Client;
use Clients;
use PasClient;
use Somewhere\Something;

class Container
{
Expand All @@ -22,9 +22,9 @@ class Container
*
* @param Toto $toto
* @var Truc $truc
* @return Machin|Machine
* @return Machin|\Machine
*/
function test (Bar $bar)
function test (Bar $bar): Something
{
/** @var Client|Clients[]|PasClient $client */

Expand Down
2 changes: 1 addition & 1 deletion SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class UnusedUseUnitTest extends AbstractSniffUnitTest
public function getErrorList()
{
return array(
12 => 1,
11 => 1,
);
}

Expand Down
90 changes: 45 additions & 45 deletions SymfonyCustom/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,58 @@
<!-- *** PSR2 *** -->
<!-- ************** -->

<!-- Include the whole PSR-2 (so PSR-1) standard -->
<rule ref="PSR2"/>
<!-- Include the whole PSR-2 (so PSR-1) standard -->
<rule ref="PSR2"/>

<!-- Override SuperfluousWhitespace to not ignore blank lines -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<!-- Override SuperfluousWhitespace to not ignore blank lines -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>

<!-- Override FunctionDeclaration to check space after type hinting -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
<severity>5</severity>
</rule>
<!-- Override FunctionDeclaration to check space after type hinting -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
<severity>5</severity>
</rule>

<!-- **************** -->
<!-- *** OTHERS *** -->
<!-- **************** -->

<!-- From djoos repo -->
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
<exclude name="Squiz.NamingConventions.ValidVariableName.ContainsNumbers"/>
</rule>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- From djoos repo -->
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
<exclude name="Squiz.NamingConventions.ValidVariableName.ContainsNumbers"/>
</rule>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="PEAR.Commenting.InlineComment"/>

<!-- From endouble repo -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="SymfonyCustom.Commenting.FunctionComment">
<exclude name="SymfonyCustom.Commenting.FunctionComment.MissingParamComment"/>
</rule>
<!-- From endouble repo -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="SymfonyCustom.Commenting.FunctionComment">
<exclude name="SymfonyCustom.Commenting.FunctionComment.MissingParamComment"/>
</rule>

<!-- Added by VincentLanglet repo -->
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
<rule ref="Squiz.PHP.ForbiddenFunctions"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Added by VincentLanglet repo -->
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
</ruleset>
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
}
],
"require": {
"squizlabs/php_codesniffer": "3.2.*"
"squizlabs/php_codesniffer": "3.4.*"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^7.0"
}
}
Loading