Skip to content

Remove exclude pattern from ruleset and add more rules #48

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 7 commits into from
May 1, 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
36 changes: 18 additions & 18 deletions SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class ArrayDeclarationSniff implements Sniff
*/
public function register()
{
return array(
return [
T_ARRAY,
T_OPEN_SHORT_ARRAY,
);
];
}

/**
Expand Down Expand Up @@ -151,7 +151,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
// Check if there are multiple values. If so, then it has to be multiple lines
// unless it is contained inside a function call or condition.
$valueCount = 0;
$commas = array();
$commas = [];
for ($i = ($arrayStart + 1); $i < $arrayEnd; $i++) {
// Skip bracketed statements, like function calls.
if (T_OPEN_PARENTHESIS === $tokens[$i]['code']) {
Expand Down Expand Up @@ -182,7 +182,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
if (T_WHITESPACE !== $tokens[($nextArrow - 1)]['code']) {
$content = $tokens[($nextArrow - 1)]['content'];
$error = 'Expected 1 space between "%s" and double arrow; 0 found';
$data = array($content);
$data = [$content];
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'NoSpaceBeforeDoubleArrow', $data);
if (true === $fix) {
$phpcsFile->fixer->addContentBefore($nextArrow, ' ');
Expand All @@ -192,7 +192,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
if (1 !== $spaceLength) {
$content = $tokens[($nextArrow - 2)]['content'];
$error = 'Expected 1 space between "%s" and double arrow; %s found';
$data = array($content, $spaceLength);
$data = [$content, $spaceLength];

$fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data);
if (true === $fix) {
Expand All @@ -204,7 +204,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
if (T_WHITESPACE !== $tokens[($nextArrow + 1)]['code']) {
$content = $tokens[($nextArrow + 1)]['content'];
$error = 'Expected 1 space between double arrow and "%s"; 0 found';
$data = array($content);
$data = [$content];

$fix = $phpcsFile->addFixableError($error, $nextArrow, 'NoSpaceAfterDoubleArrow', $data);
if (true === $fix) {
Expand All @@ -215,7 +215,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
if (1 !== $spaceLength) {
$content = $tokens[($nextArrow + 2)]['content'];
$error = 'Expected 1 space between double arrow and "%s"; %s found';
$data = array($content, $spaceLength);
$data = [$content, $spaceLength];

$fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data);
if (true === $fix) {
Expand Down Expand Up @@ -300,7 +300,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
$expected = ($currentIndent);
$found = ($tokens[$arrayEnd]['column'] - 1);
$error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s';
$data = array($expected, $found);
$data = [$expected, $found];

$fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceNotAligned', $data);
if (true === $fix) {
Expand All @@ -314,7 +314,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $

$keyUsed = false;
$singleUsed = false;
$indices = array();
$indices = [];
$maxLength = 0;

if (T_ARRAY === $tokens[$stackPtr]['code']) {
Expand All @@ -340,7 +340,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
) {
// Let subsequent calls of this test handle nested arrays.
if (T_DOUBLE_ARROW !== $tokens[$lastToken]['code']) {
$indices[] = array('value' => $nextToken);
$indices[] = ['value' => $nextToken];
$lastToken = $nextToken;
}

Expand Down Expand Up @@ -369,7 +369,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
continue;
}

$currentEntry = array();
$currentEntry = [];

if (T_COMMA === $tokens[$nextToken]['code']) {
$stackPtrCount = 0;
Expand Down Expand Up @@ -410,10 +410,10 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
}

$error = 'Expected 0 spaces between "%s" and comma; %s found';
$data = array(
$data = [
$content,
$spaceLength,
);
];

$fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data);
if (true === $fix) {
Expand All @@ -428,7 +428,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
true
);

$indices[] = array('value' => $valueContent);
$indices[] = ['value' => $valueContent];
$singleUsed = true;
}

Expand Down Expand Up @@ -540,7 +540,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
$found = ($tokens[$first]['column'] - 1);
if ($found !== $expected) {
$error = 'Array value not aligned correctly; expected %s spaces but found %s';
$data = array($expected, $found);
$data = [$expected, $found];

$fix = $phpcsFile->addFixableError($error, $value['value'], 'ValueNotAligned', $data);
if (true === $fix) {
Expand Down Expand Up @@ -636,7 +636,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
$expected = ($indicesStart - 1);
$found = ($tokens[$index['index']]['column'] - 1);
$error = 'Array key not aligned correctly; expected %s spaces but found %s';
$data = array($expected, $found);
$data = [$expected, $found];

$fix = $phpcsFile->addFixableError($error, $index['index'], 'KeyNotAligned', $data);

Expand All @@ -661,7 +661,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
}

$error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s';
$data = array($expected, $found);
$data = [$expected, $found];

if ('newline' !== $found || false === $this->ignoreNewLines) {
$fix = $phpcsFile->addFixableError($error, $index['arrow'], 'DoubleArrowNotAligned', $data);
Expand Down Expand Up @@ -786,7 +786,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
$content = $tokens[($nextComma - 2)]['content'];
$spaceLength = $tokens[($nextComma - 1)]['length'];
$error = 'Expected 0 spaces between "%s" and comma; %s found';
$data = array($content, $spaceLength);
$data = [$content, $spaceLength];

$fix = $phpcsFile->addFixableError($error, $nextComma, 'SpaceBeforeComma', $data);
if (true === $fix) {
Expand Down
6 changes: 3 additions & 3 deletions SymfonyCustom/Sniffs/Classes/ClassDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class ClassDeclarationSniff
*/
public function register()
{
return array(
return [
T_CLASS,
T_INTERFACE,
T_TRAIT,
);
];
}

/**
Expand All @@ -39,7 +39,7 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$nextElement = $phpcsFile->findNext(array(T_WHITESPACE), $openingBrace + 1, null, true);
$nextElement = $phpcsFile->findNext([T_WHITESPACE], $openingBrace + 1, null, true);

if ($tokens[$openingBrace]['line'] + 1 < $tokens[$nextElement]['line']) {
$fix = $phpcsFile->addFixableError(
Expand Down
8 changes: 4 additions & 4 deletions SymfonyCustom/Sniffs/Classes/PropertyDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class PropertyDeclarationSniff implements Sniff
*/
public function register()
{
return array(
return [
T_CLASS,
);
];
}

/**
Expand All @@ -46,11 +46,11 @@ public function process(File $phpcsFile, $stackPtr)
$end
);

$wantedTokens = array(
$wantedTokens = [
T_PUBLIC,
T_PROTECTED,
T_PRIVATE,
);
];

while ($scope) {
$scope = $phpcsFile->findNext(
Expand Down
48 changes: 24 additions & 24 deletions SymfonyCustom/Sniffs/Commenting/ClassCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,61 +25,61 @@ class ClassCommentSniff extends PEARClassCommentSniff
*
* @var array
*/
protected $tags = array(
'category' => array(
protected $tags = [
'category' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'precedes @package',
),
'package' => array(
],
'package' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @category',
),
'subpackage' => array(
],
'subpackage' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @package',
),
'author' => array(
],
'author' => [
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @subpackage (if used) or @package',
),
'copyright' => array(
],
'copyright' => [
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @author',
),
'license' => array(
],
'license' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @copyright (if used) or @author',
),
'version' => array(
],
'version' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @license',
),
'link' => array(
],
'link' => [
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @version',
),
'see' => array(
],
'see' => [
'required' => false,
'allow_multiple' => true,
'order_text' => 'follows @link',
),
'since' => array(
],
'since' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @see (if used) or @link',
),
'deprecated' => array(
],
'deprecated' => [
'required' => false,
'allow_multiple' => false,
'order_text' => 'follows @since (if used) or @see (if used) or @link',
),
);
],
];
}
10 changes: 5 additions & 5 deletions SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class DocCommentForbiddenTagsSniff implements Sniff
*
* @var array
*/
public $tags = array(
public $tags = [
'@package',
'@subpackage',
);
];

/**
* A list of tokenizers this sniff supports.
Expand All @@ -27,9 +27,9 @@ class DocCommentForbiddenTagsSniff implements Sniff
*/
public function register()
{
return array(
return [
T_DOC_COMMENT_TAG
);
];
}

/**
Expand All @@ -53,7 +53,7 @@ public function process(File $phpcsFile, $stackPtr)
'The %s annotation is forbidden to use',
$stackPtr,
'',
array($tokens[$stackPtr]['content'])
[$tokens[$stackPtr]['content']]
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DocCommentGroupSameTypeSniff implements Sniff
*
* @var array
*/
public $tags = array(
public $tags = [
'@api',
'@author',
'@category',
Expand Down Expand Up @@ -46,7 +46,7 @@ class DocCommentGroupSameTypeSniff implements Sniff
'@uses',
'@var',
'@version',
);
];

/**
* A list of tokenizers this sniff supports.
Expand All @@ -55,9 +55,9 @@ class DocCommentGroupSameTypeSniff implements Sniff
*/
public function register()
{
return array(
return [
T_DOC_COMMENT_OPEN_TAG
);
];
}

/**
Expand Down Expand Up @@ -148,7 +148,7 @@ public function process(File $phpcsFile, $stackPtr)

if ($previousLine === $commentTagLine - 1) {
$firstOnLine = $phpcsFile->findFirstOnLine(
array(),
[],
$commentTag,
true
);
Expand Down
4 changes: 2 additions & 2 deletions SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function process(File $phpcsFile, $stackPtr)
if (count($realParams) > 0) {
foreach ($realParams as $neededParam) {
$error = 'Doc comment for parameter "%s" missing';
$data = array($neededParam['name']);
$data = [$neededParam['name']];
$phpcsFile->addError($error, $stackPtr, 'MissingParamTag', $data);
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function processWhitespace(
$rule = 'SpacingBeforeFunction';
}

$data = array($found);
$data = [$found];
$fix = $phpcsFile->addFixableError($error, $commentStart, $rule, $data);

if (true === $fix) {
Expand Down
Loading