[cs] finalize, spaces, concat and strict comparison

This commit is contained in:
TomasVotruba
2017-11-12 21:23:54 +01:00
committed by Jaap van Otterdijk
parent 833126e6a3
commit 5ff9ca38c5
11 changed files with 32 additions and 14 deletions
+20
View File
@@ -1,11 +1,31 @@
includes:
- temp/ecs/config/clean-code.neon
- temp/ecs/config/psr2-checkers.neon
- temp/ecs/config/spaces.neon
- temp/ecs/config/common.neon
checkers:
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
spacing: one
parameters:
exclude_checkers:
# from temp/ecs/config/common.neon
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
- PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer
- PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer
# from temp/ecs/config/spaces.neon
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
skip:
SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff:
# WIP code
- src/DocBlock/StandardTagFactory.php
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff:
# WIP code
- src/DocBlock/StandardTagFactory.php
PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff:
- src/DocBlock/Tags/Return_.php
- src/DocBlock/Tags/Var_.php
PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff:
- */tests/**
+2 -2
View File
@@ -174,7 +174,7 @@ final class DocBlock
/** @var Tag $tag */
foreach ($this->getTags() as $tag) {
if ($tag->getName() != $name) {
if ($tag->getName() !== $name) {
continue;
}
@@ -197,7 +197,7 @@ final class DocBlock
/** @var Tag $tag */
foreach ($this->getTags() as $tag) {
if ($tag->getName() == $name) {
if ($tag->getName() === $name) {
return true;
}
}
+1 -1
View File
@@ -69,7 +69,7 @@ class Description
$this->bodyTemplate = $bodyTemplate;
$this->tags = $tags;
}
/**
* Returns the tags for this DocBlock.
*
+1 -1
View File
@@ -77,7 +77,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) {
$variableName = array_shift($parts);
array_shift($parts);
+1 -1
View File
@@ -70,7 +70,7 @@ class Property extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
+1 -1
View File
@@ -70,7 +70,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
+1 -1
View File
@@ -70,7 +70,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
+4 -4
View File
@@ -70,7 +70,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
@@ -111,8 +111,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod
*/
public function __toString()
{
return ($this->type ? $this->type.' ' : '')
.(empty($this->variableName) ? null : ('$'.$this->variableName))
.($this->description ? ' '.$this->description : '');
return ($this->type ? $this->type . ' ' : '')
. (empty($this->variableName) ? null : ('$' . $this->variableName))
. ($this->description ? ' ' . $this->description : '');
}
}
+1 -1
View File
@@ -120,7 +120,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
// reg ex above is not able to remove */ from a single line docblock
if (substr($comment, -2) == '*/') {
if (substr($comment, -2) === '*/') {
$comment = trim(substr($comment, 0, -2));
}
@@ -27,7 +27,6 @@ final class DocblocksWithAnnotationsTest extends \PHPUnit_Framework_TestCase
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
@@ -343,7 +343,6 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
$tagFactory->addService($typeResolver, TypeResolver::class);
/** @var Return_ $tag */
$tag = $tagFactory->create('@return mixed', $context);