diff --git a/easy-coding-standard.neon b/easy-coding-standard.neon index f58075a..7c2ba6e 100644 --- a/easy-coding-standard.neon +++ b/easy-coding-standard.neon @@ -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/** diff --git a/src/DocBlock.php b/src/DocBlock.php index 7e7ef3c..46605b7 100644 --- a/src/DocBlock.php +++ b/src/DocBlock.php @@ -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; } } diff --git a/src/DocBlock/Description.php b/src/DocBlock/Description.php index 70fd131..25a79e0 100644 --- a/src/DocBlock/Description.php +++ b/src/DocBlock/Description.php @@ -69,7 +69,7 @@ class Description $this->bodyTemplate = $bodyTemplate; $this->tags = $tags; } - + /** * Returns the tags for this DocBlock. * diff --git a/src/DocBlock/Tags/Param.php b/src/DocBlock/Tags/Param.php index 1a51dc0..7d699d8 100644 --- a/src/DocBlock/Tags/Param.php +++ b/src/DocBlock/Tags/Param.php @@ -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); diff --git a/src/DocBlock/Tags/Property.php b/src/DocBlock/Tags/Property.php index 3c59713..f0ef7c0 100644 --- a/src/DocBlock/Tags/Property.php +++ b/src/DocBlock/Tags/Property.php @@ -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); diff --git a/src/DocBlock/Tags/PropertyRead.php b/src/DocBlock/Tags/PropertyRead.php index bf2b805..e41c0c1 100644 --- a/src/DocBlock/Tags/PropertyRead.php +++ b/src/DocBlock/Tags/PropertyRead.php @@ -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); diff --git a/src/DocBlock/Tags/PropertyWrite.php b/src/DocBlock/Tags/PropertyWrite.php index db37e0f..cfdb0ed 100644 --- a/src/DocBlock/Tags/PropertyWrite.php +++ b/src/DocBlock/Tags/PropertyWrite.php @@ -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); diff --git a/src/DocBlock/Tags/Var_.php b/src/DocBlock/Tags/Var_.php index f431a86..8907c95 100644 --- a/src/DocBlock/Tags/Var_.php +++ b/src/DocBlock/Tags/Var_.php @@ -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 : ''); } } diff --git a/src/DocBlockFactory.php b/src/DocBlockFactory.php index 880cc05..1bdb8f4 100644 --- a/src/DocBlockFactory.php +++ b/src/DocBlockFactory.php @@ -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)); } diff --git a/tests/integration/DocblocksWithAnnotationsTest.php b/tests/integration/DocblocksWithAnnotationsTest.php index 6db1604..54ac332 100644 --- a/tests/integration/DocblocksWithAnnotationsTest.php +++ b/tests/integration/DocblocksWithAnnotationsTest.php @@ -27,7 +27,6 @@ final class DocblocksWithAnnotationsTest extends \PHPUnit_Framework_TestCase */ DOCCOMMENT; - $factory = DocBlockFactory::createInstance(); $docblock = $factory->create($docComment); diff --git a/tests/unit/DocBlock/StandardTagFactoryTest.php b/tests/unit/DocBlock/StandardTagFactoryTest.php index 51e7633..3ccf0a8 100644 --- a/tests/unit/DocBlock/StandardTagFactoryTest.php +++ b/tests/unit/DocBlock/StandardTagFactoryTest.php @@ -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);