Skip to content

Commit

Permalink
Obey phpcsdevcs, add example usage of ConcatenationUsage
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Jul 28, 2020
1 parent 037c959 commit a76b66e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
17 changes: 15 additions & 2 deletions PSR12NeutronRuleset/Sniffs/Strings/ConcatenationUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,40 @@

/**
* Prohibit usage of "." operator.
*
* @package PSR12NeutronRuleset
*/

namespace PSR12NeutronRuleset\Sniffs\Strings;

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

/**
* ConcatenationUsage sniff.
*/
class ConcatenationUsageSniff implements Sniff
{

/**
* @return array<int>
* Register sniff.
*
* @return array<int, int>
*/
public function register()
{
return [\T_STRING_CONCAT];
}

/**
* Process sniff.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile 1
* @param int $stackPtr 2
*
* @return void
*/
public function process(File $phpcsFile, $stackPtr)
public function process(File $phpcsFile, int $stackPtr)
{
$phpcsFile->addError('Concat operator is prohibited', $stackPtr, 'NotAllowed');
}
Expand Down
5 changes: 5 additions & 0 deletions PSR12NeutronRuleset/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
<exclude name="WordPress.NamingConventions.ValidFunctionName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>

<exclude name="Squiz.Operators.IncrementDecrementUsage"/>

<exclude name="NeutronStandard.Whitespace.RequireParenthesisSpacing.Missing"/>
<exclude name="NeutronStandard.Constants.DisallowDefine.Define"/>

Expand Down Expand Up @@ -203,4 +205,7 @@
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>

<!-- Own rules -->
<!-- <rule ref="PSR12NeutronRuleset.Strings.ConcatenationUsage"/> -->
</ruleset>
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0"
},
"scripts": {
"lint": "tests/xmllint.sh"
"test:cs": "phpcs --standard=PHPCSDev PSR12NeutronRuleset/",
"test:xml": "tests/xmllint.sh"
},
"require-dev": {
"phpcsstandards/phpcsdevcs": "^1.0"
}
}

0 comments on commit a76b66e

Please sign in to comment.