Skip to content

Commit 3e05e00

Browse files
committed
fix rector rule test
1 parent d340464 commit 3e05e00

File tree

12 files changed

+42
-43
lines changed

12 files changed

+42
-43
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"rector/rector": "^2.0",
1919
"phpstan/extension-installer": "^1.4",
2020
"symplify/phpstan-extensions": "^12.0",
21-
"tomasvotruba/unused-public": "^2.0"
21+
"tomasvotruba/unused-public": "^2.0",
22+
"tomasvotruba/type-coverage": "^2.0"
2223
},
2324
"autoload": {
2425
"psr-4": {

phpstan.neon

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ parameters:
2828
properties: true
2929
constants: true
3030

31-
# type_coverage:
32-
# return: 99
33-
# param: 99
34-
# property: 99
31+
type_coverage:
32+
return: 99
33+
param: 99
34+
property: 99
3535

3636
ignoreErrors:
3737
# needless generics

phpunit.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" cacheDirectory=".phpunit.cache">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
7+
displayDetailsOnIncompleteTests="true"
8+
cacheDirectory=".phpunit.cache">
39
<testsuite name="all">
410
<directory>tests</directory>
511
<exclude>tests/Rules/ClassNameRespectsParentSuffixRule/Fixture/</exclude>

phpunit.xml.bak

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Composer/ComposerAutoloadResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Symplify\PHPStanRules\Composer;
66

7+
use Symplify\PHPStanRules\FileSystem\FileSystem;
8+
79
final class ComposerAutoloadResolver
810
{
911
/**
@@ -20,7 +22,7 @@ public function getPsr4Autoload(): array
2022
return [];
2123
}
2224

23-
$fileContent = \Symplify\PHPStanRules\FileSystem\FileSystem::read(self::COMPOSER_JSON_FILE);
25+
$fileContent = FileSystem::read(self::COMPOSER_JSON_FILE);
2426
$composerJsonContent = json_decode($fileContent, true, 512, JSON_THROW_ON_ERROR);
2527

2628
$autoloadPsr4 = $composerJsonContent['autoload']['psr-4'] ?? [];

src/Naming/ClassToSuffixResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function removeAbstractInterfacePrefixSuffix(string $parentType): string
4040
}
4141

4242
if (\str_starts_with($parentType, 'Abstract')) {
43-
return substr($parentType, (int) strlen('Abstract'));
43+
return substr($parentType, strlen('Abstract'));
4444
}
4545

4646
return $parentType;

src/Reflection/ReflectionParser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPStan\Reflection\MethodReflection;
1515
use ReflectionClass;
1616
use ReflectionMethod;
17+
use Symplify\PHPStanRules\FileSystem\FileSystem;
1718
use Symplify\PHPStanRules\NodeFinder\TypeAwareNodeFinder;
1819
use Throwable;
1920

@@ -77,7 +78,7 @@ private function parseFilenameToClass(string $fileName): ClassLike|null
7778
}
7879

7980
try {
80-
$stmts = $this->parser->parse(\Symplify\PHPStanRules\FileSystem\FileSystem::read($fileName));
81+
$stmts = $this->parser->parse(FileSystem::read($fileName));
8182
if (! is_array($stmts)) {
8283
return null;
8384
}

src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Symplify\PHPStanRules\Rules;
66

7-
use Nette\Utils\Strings;
87
use PhpParser\Comment\Doc;
98
use PhpParser\Node;
109
use PhpParser\Node\Scalar\String_;
@@ -89,7 +88,8 @@ private function isNonSingleCharRegexPattern(string $value): bool
8988
return false;
9089
}
9190

92-
$lastChar = Strings::substring($patternWithoutModifiers, -1, 1);
91+
$lastChar = substr($patternWithoutModifiers, -1, 1);
92+
9393
// this is probably a regex
9494
return $firstChar === $lastChar;
9595
}

src/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use SplFileInfo;
1919
use Symplify\PHPStanRules\Enum\RuleIdentifier;
2020
use Symplify\PHPStanRules\Exception\ShouldNotHappenException;
21+
use Symplify\PHPStanRules\FileSystem\FileSystem;
2122

2223
/**
2324
* @see \Symplify\PHPStanRules\Tests\Rules\Rector\PhpUpgradeDowngradeRegisteredInSetRule\PhpUpgradeDowngradeRegisteredInSetRuleTest
@@ -57,7 +58,7 @@ public function processNode(Node $node, Scope $scope): array
5758
return [];
5859
}
5960

60-
$configContent = \Symplify\PHPStanRules\FileSystem\FileSystem::read($configFilePath);
61+
$configContent = FileSystem::read($configFilePath);
6162

6263
// is rule registered?
6364
if (str_contains($configContent, $className)) {

tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/Fixture/DowngradePhp80/SomePhpFeature2Rector.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
namespace Symplify\PHPStanRules\Tests\Rules\Rector\PhpUpgradeDowngradeRegisteredInSetRule\Fixture\DowngradePhp80;
66

77
use PhpParser\Node;
8-
use Rector\Contract\Rector\RectorInterface;
98
use Rector\Rector\AbstractRector;
10-
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
119

12-
final class SomePhpFeature2Rector extends AbstractRector implements RectorInterface
10+
final class SomePhpFeature2Rector extends AbstractRector
1311
{
14-
public function getRuleDefinition(): RuleDefinition
15-
{
16-
}
17-
1812
public function getNodeTypes(): array
1913
{
2014
return [];

0 commit comments

Comments
 (0)