apply code-quality level

This commit is contained in:
Tomas Votruba 2019-03-31 14:45:15 +02:00
parent 24ae3ae211
commit b9fbb3654d
12 changed files with 25 additions and 33 deletions

View File

@ -2606,7 +2606,7 @@ Changes rand, srand and getrandmax by new md_* alternatives.
- class: `Rector\Php\Rector\FuncCall\PregReplaceEModifierRector`
The /e modifier is no longer supported, use preg_replace_callback instead
The /e modifier is no longer supported, use preg_replace_callback instead
```diff
class SomeClass

View File

@ -910,7 +910,7 @@ if (true) {
```php
?>
<strong>feel</strong><?php
<strong>feel</strong><?php
```
<br>

View File

@ -124,7 +124,7 @@ final class AttributeAwareNodeFactory
}
if ($phpDocTagValueNode instanceof MethodTagValueNode) {
$typeNode = $phpDocTagValueNode->returnType ? $this->createFromTypeNode(
$typeNode = $phpDocTagValueNode->returnType !== null ? $this->createFromTypeNode(
$phpDocTagValueNode->returnType
) : null;
return new AttributeAwareMethodTagValueNode(

View File

@ -20,7 +20,7 @@ final class OriginalSpacingRestorer
$oldWhitespaces = $this->detectOldWhitespaces($tokens, $startEndInfo);
// no original whitespaces, return
if (! $oldWhitespaces) {
if ($oldWhitespaces === []) {
return $nodeOutput;
}
@ -54,7 +54,7 @@ final class OriginalSpacingRestorer
if ($this->isQuotedStringWithSpaces($tokens, $i)) {
$matches = Strings::matchAll($tokens[$i][0], '#\s+#m');
if ($matches) {
if ($matches !== []) {
$oldWhitespaces = array_merge($oldWhitespaces, Arrays::flatten($matches));
}
}

View File

@ -107,7 +107,7 @@ final class PhpDocInfoPrinter
foreach ($phpDocNode->children as $phpDocChildNode) {
if ($phpDocChildNode instanceof PhpDocTextNode) {
if ($phpDocChildNode->text) {
if ($phpDocChildNode->text !== '') {
return false;
}
} else {
@ -221,7 +221,7 @@ final class PhpDocInfoPrinter
*/
private function getRemovedNodesPositions(): array
{
if ($this->removedNodePositions) {
if ($this->removedNodePositions !== []) {
return $this->removedNodePositions;
}

View File

@ -78,7 +78,7 @@ CODE_SAMPLE
}
if ($node instanceof For_) {
if ($node->stmts) {
if ($node->stmts !== []) {
return null;
}
@ -92,15 +92,15 @@ CODE_SAMPLE
private function processIf(If_ $if): ?If_
{
if ($if->stmts) {
if ($if->stmts !== []) {
return null;
}
if ($if->else) {
if ($if->else !== null) {
return null;
}
if ($if->elseifs) {
if ($if->elseifs !== []) {
return null;
}
@ -115,7 +115,7 @@ CODE_SAMPLE
private function processForeach(Foreach_ $node): ?Foreach_
{
if ($node->stmts) {
if ($node->stmts !== []) {
return null;
}
@ -137,11 +137,6 @@ CODE_SAMPLE
if ($expr instanceof Scalar) {
return false;
}
if ($this->isBool($expr)) {
return false;
}
return true;
return ! $this->isBool($expr);
}
}

View File

@ -200,10 +200,10 @@ final class EregToPcreTransformer
}
$bound = substr($s, $i + 1, $ii - ($i + 1));
if (! preg_match(
'/^([0-9]|[1-9][0-9]|1[0-9][0-9]|
2[0-4][0-9]|25[0-5])
(,([0-9]|[1-9][0-9]|1[0-9][0-9]|
2[0-4][0-9]|25[0-5])?)?$/x',
'/^(\d|[1-9]\d|1\d\d|
2[0-4]\d|25[0-5])
(,(\d|[1-9]\d|1\d\d|
2[0-4]\d|25[0-5])?)?$/x',
$bound,
$m
)) {

View File

@ -104,7 +104,7 @@ abstract class AbstractTypeDeclarationRector extends AbstractRector
}
$classNode = $classMethod->getAttribute(Attribute::CLASS_NODE);
if (! ($classNode instanceof Class_ || $classNode instanceof Interface_)) {
if (! $classNode instanceof Class_ && ! $classNode instanceof Interface_) {
return false;
}

View File

@ -131,7 +131,7 @@ final class PhpSpecMocksToPHPUnitMocksRector extends AbstractPhpSpecToPHPUnitRec
}
$createMockCall = $this->createCreateMockCall($param, $param->type);
if ($createMockCall) {
if ($createMockCall !== null) {
$assigns[] = $createMockCall;
}
}
@ -163,7 +163,7 @@ final class PhpSpecMocksToPHPUnitMocksRector extends AbstractPhpSpecToPHPUnitRec
$methodCall->name = new Identifier('method');
$methodCall->args = [new Arg(new String_($mockMethodName))];
if ($expectedArg) {
if ($expectedArg !== null) {
return $this->appendWithMethodCall($methodCall, $expectedArg);
}

View File

@ -190,7 +190,7 @@ final class PhpSpecPromisesToPHPUnitAssertRector extends AbstractPhpSpecToPHPUni
/** @var Class_ $class */
$class = $node->getAttribute(Attribute::CLASS_NODE);
// it's a method call, skip
if ($class->getMethod($methodName)) {
if ($class->getMethod($methodName) !== null) {
return null;
}
@ -217,13 +217,13 @@ final class PhpSpecPromisesToPHPUnitAssertRector extends AbstractPhpSpecToPHPUni
$this->isBoolAssert = false;
// special case with bool!
if ($expected) {
if ($expected !== null) {
$name = $this->resolveBoolMethodName($name, $expected);
}
$assetMethodCall = new MethodCall(new Variable('this'), new Identifier($name));
if ($this->isBoolAssert === false && $expected) {
if (! $this->isBoolAssert && $expected) {
$assetMethodCall->args[] = new Arg($this->thisToTestedObjectPropertyFetch($expected));
}

View File

@ -142,3 +142,4 @@ parameters:
# false positive 0.11.5
- '#Unreachable statement \- code above always terminates#'
- '#Method Rector\\NodeTypeResolver\\NodeVisitor\\(.*?)\:\:enterNode\(\) should return int\|PhpParser\\Node\|void\|null but return statement is missing#'
- '#Negated boolean expression is always true#'

View File

@ -151,11 +151,7 @@ final class NameResolver
// is probably fnmatch
if (Strings::contains($name, '*')) {
if (fnmatch($name, $resolvedName, FNM_NOESCAPE)) {
return true;
}
return false;
return fnmatch($name, $resolvedName, FNM_NOESCAPE);
}
return $resolvedName === $name;