Skip to content

Commit 5ff9ca3

Browse files
TomasVotrubajaapio
authored andcommitted
[cs] finalize, spaces, concat and strict comparison
1 parent 833126e commit 5ff9ca3

File tree

11 files changed

+32
-14
lines changed

11 files changed

+32
-14
lines changed

easy-coding-standard.neon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
includes:
22
- temp/ecs/config/clean-code.neon
33
- temp/ecs/config/psr2-checkers.neon
4+
- temp/ecs/config/spaces.neon
5+
- temp/ecs/config/common.neon
6+
7+
checkers:
8+
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
9+
spacing: one
410

511
parameters:
12+
exclude_checkers:
13+
# from temp/ecs/config/common.neon
14+
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
15+
- PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer
16+
- PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer
17+
# from temp/ecs/config/spaces.neon
18+
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
19+
620
skip:
721
SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff:
22+
# WIP code
23+
- src/DocBlock/StandardTagFactory.php
24+
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff:
25+
# WIP code
826
- src/DocBlock/StandardTagFactory.php
927
PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff:
1028
- src/DocBlock/Tags/Return_.php
1129
- src/DocBlock/Tags/Var_.php
30+
PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff:
31+
- */tests/**

src/DocBlock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function getTagsByName($name)
174174

175175
/** @var Tag $tag */
176176
foreach ($this->getTags() as $tag) {
177-
if ($tag->getName() != $name) {
177+
if ($tag->getName() !== $name) {
178178
continue;
179179
}
180180

@@ -197,7 +197,7 @@ public function hasTag($name)
197197

198198
/** @var Tag $tag */
199199
foreach ($this->getTags() as $tag) {
200-
if ($tag->getName() == $name) {
200+
if ($tag->getName() === $name) {
201201
return true;
202202
}
203203
}

src/DocBlock/Description.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct($bodyTemplate, array $tags = [])
6969
$this->bodyTemplate = $bodyTemplate;
7070
$this->tags = $tags;
7171
}
72-
72+
7373
/**
7474
* Returns the tags for this DocBlock.
7575
*

src/DocBlock/Tags/Param.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function create(
7777
}
7878

7979
// if the next item starts with a $ or ...$ it must be the variable name
80-
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')) {
80+
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) {
8181
$variableName = array_shift($parts);
8282
array_shift($parts);
8383

src/DocBlock/Tags/Property.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function create(
7070
}
7171

7272
// if the next item starts with a $ or ...$ it must be the variable name
73-
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
73+
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
7474
$variableName = array_shift($parts);
7575
array_shift($parts);
7676

src/DocBlock/Tags/PropertyRead.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function create(
7070
}
7171

7272
// if the next item starts with a $ or ...$ it must be the variable name
73-
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
73+
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
7474
$variableName = array_shift($parts);
7575
array_shift($parts);
7676

src/DocBlock/Tags/PropertyWrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function create(
7070
}
7171

7272
// if the next item starts with a $ or ...$ it must be the variable name
73-
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
73+
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
7474
$variableName = array_shift($parts);
7575
array_shift($parts);
7676

src/DocBlock/Tags/Var_.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function create(
7070
}
7171

7272
// if the next item starts with a $ or ...$ it must be the variable name
73-
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
73+
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
7474
$variableName = array_shift($parts);
7575
array_shift($parts);
7676

@@ -111,8 +111,8 @@ public function getType()
111111
*/
112112
public function __toString()
113113
{
114-
return ($this->type ? $this->type.' ' : '')
115-
.(empty($this->variableName) ? null : ('$'.$this->variableName))
116-
.($this->description ? ' '.$this->description : '');
114+
return ($this->type ? $this->type . ' ' : '')
115+
. (empty($this->variableName) ? null : ('$' . $this->variableName))
116+
. ($this->description ? ' ' . $this->description : '');
117117
}
118118
}

src/DocBlockFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private function stripDocComment($comment)
120120
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
121121

122122
// reg ex above is not able to remove */ from a single line docblock
123-
if (substr($comment, -2) == '*/') {
123+
if (substr($comment, -2) === '*/') {
124124
$comment = trim(substr($comment, 0, -2));
125125
}
126126

tests/integration/DocblocksWithAnnotationsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function testDocblockWithAnnotations()
2727
*/
2828
DOCCOMMENT;
2929

30-
3130
$factory = DocBlockFactory::createInstance();
3231
$docblock = $factory->create($docComment);
3332

0 commit comments

Comments
 (0)