Skip to content

Commit

Permalink
[chore] Make use of symplify/phpstan-rules (#5455)
Browse files Browse the repository at this point in the history
* bump

* apply cs

* tidy up phpstan
  • Loading branch information
TomasVotruba committed Jan 10, 2024
1 parent d2818f6 commit 54a11ee
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 21 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@
"phpstan/phpstan-strict-rules": "^1.5",
"phpstan/phpstan-webmozart-assert": "^1.2.2",
"phpunit/phpunit": "^10.5",
"rector/phpstan-rules": "^0.7.4",
"rector/rector-generator": "^0.7",
"spatie/enum": "^3.13",
"symplify/easy-ci": "^11.3",
"symplify/easy-coding-standard": "^12.1",
"symplify/phpstan-extensions": "^11.4",
"symplify/phpstan-rules": "^12.2",
"symplify/phpstan-rules": "^12.4.5",
"symplify/rule-doc-generator": "^12.1",
"symplify/vendor-patches": "^11.2",
"rector/release-notes-generator": "dev-main",
Expand Down
11 changes: 2 additions & 9 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includes:
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
- vendor/symplify/phpstan-rules/config/rector-rules.neon

parameters:
level: 8
Expand Down Expand Up @@ -118,9 +119,6 @@ parameters:
- src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
- src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php

# known types
- '#Call to an undefined method PHPStan\\Type\\ConstantType\:\:getValue\(\)#'

- '#(.*?) class\-string, string given#'

-
Expand Down Expand Up @@ -463,9 +461,7 @@ parameters:
# collectors
- '#Creating new PHPStan\\Node\\CollectedDataNode is not covered by backward compatibility promise\. The class might change in a minor PHPStan version#'

- '#Access to an undefined property (.*?)\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#'
- '#Property Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts \(array<PhpParser\\Node\\Stmt>\|null\) does not accept array<PhpParser\\Node\\Stmt\|null>#'
- '#Class "Rector\\Utils\\PHPStan\\Rule\\LongAndDependentComplexRectorRule" is missing @see annotation with test case class reference#'
- '#(.*?)\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#'

# dev rule
- '#Class "Rector\\Utils\\Rector\\MoveAbstractRectorToChildrenRector" is missing @see annotation with test case class reference#'
Expand All @@ -487,6 +483,3 @@ parameters:

# closure detailed
- '#Method Rector\\Config\\RectorConfig\:\:singleton\(\) has parameter \$concrete with no signature specified for Closure#'

# skip for now
- '#Class with base "AutoImportTest" name is already used in "Rector\\Tests\\Issues\\AutoImport\\AutoImportTest", "Rector\\Tests\\TypeDeclaration\\Rector\\StmtsAwareInterface\\DeclareStrictTypesRector\\AutoImportTest"\. Use unique name to make classes easy to recognize#'
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class AutoImportTest extends AbstractRectorTestCase
final class AutoImportDeclareStrictTypesRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
Expand Down
6 changes: 5 additions & 1 deletion src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ public function parseTagValue(TokenIterator $tokenIterator, string $tag): PhpDoc
$phpDocTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);

if ($phpDocTagValueNode instanceof GenericTagValueNode) {
$phpDocTagValueNode->value = Strings::replace($phpDocTagValueNode->value, self::MULTI_NEW_LINES_REGEX, "\n");
$phpDocTagValueNode->value = Strings::replace(
$phpDocTagValueNode->value,
self::MULTI_NEW_LINES_REGEX,
"\n"
);
}

return $phpDocTagValueNode;
Expand Down
5 changes: 4 additions & 1 deletion src/FileSystem/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public function findInDirectoriesAndFiles(array $source, array $suffixes = [], b
$filesAndDirectories = $this->filesystemTweaker->resolveWithFnmatch($source);

$filePaths = $this->fileAndDirectoryFilter->filterFiles($filesAndDirectories);
$filePaths = array_filter($filePaths, fn (string $filePath): bool => ! $this->pathSkipper->shouldSkip($filePath));
$filePaths = array_filter(
$filePaths,
fn (string $filePath): bool => ! $this->pathSkipper->shouldSkip($filePath)
);

$currentAndDependentFilePaths = $this->unchangedFilesFilter->filterFileInfos($filePaths);

Expand Down
5 changes: 1 addition & 4 deletions src/Skipper/Skipper/PathSkipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function shouldSkip(string $filePath): bool
{
$filePath = str_replace('\\', '/', $filePath);
$skippedPaths = $this->skippedPathsResolver->resolve();
return $this->fileInfoMatcher->doesFileInfoMatchPatterns(
$filePath,
$skippedPaths
);
return $this->fileInfoMatcher->doesFileInfoMatchPatterns($filePath, $skippedPaths);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
use Rector\Doctrine\Set\DoctrineSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
]);
$rectorConfig->sets([DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES]);
};

0 comments on commit 54a11ee

Please sign in to comment.