Skip to content

Commit 58c2d43

Browse files
authored
Remove CheckClassNamespaceFollowPsr4Rule as overly detailed, use composer-dependency-analyser instead (#150)
* Remove CheckClassNamespaceFollowPsr4Rule as overly detailed, use composer-dependency-analyser instead * update rector config, bump to PHP 8.2
1 parent 77fd23a commit 58c2d43

37 files changed

+53
-614
lines changed

README.md

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -108,38 +108,6 @@ class SomeClass
108108

109109
<br>
110110

111-
## CheckClassNamespaceFollowPsr4Rule
112-
113-
Class like namespace "%s" does not follow PSR-4 configuration in `composer.json`
114-
115-
- class: [`Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule`](../src/Rules/CheckClassNamespaceFollowPsr4Rule.php)
116-
117-
```php
118-
// defined "Foo\Bar" namespace in composer.json > autoload > psr-4
119-
namespace Foo;
120-
121-
class Baz
122-
{
123-
}
124-
```
125-
126-
:x:
127-
128-
<br>
129-
130-
```php
131-
// defined "Foo\Bar" namespace in composer.json > autoload > psr-4
132-
namespace Foo\Bar;
133-
134-
class Baz
135-
{
136-
}
137-
```
138-
139-
:+1:
140-
141-
<br>
142-
143111
## CheckRequiredInterfaceInContractNamespaceRule
144112

145113
Interface must be located in "Contract" or "Contracts" namespace

config/naming-rules.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ rules:
33
- Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule
44
- Symplify\PHPStanRules\Rules\UppercaseConstantRule
55
- Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule
6-
- Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule

config/services/services.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ services:
55
- Symplify\PHPStanRules\Matcher\ArrayStringAndFnMatcher
66
- Symplify\PHPStanRules\NodeFinder\TypeAwareNodeFinder
77
- Symplify\PHPStanRules\PhpDoc\SeePhpDocTagNodesFinder
8-
- Symplify\PHPStanRules\Composer\ClassNamespaceMatcher
9-
- Symplify\PHPStanRules\Composer\ComposerAutoloadResolver
10-
- Symplify\PHPStanRules\Composer\Psr4PathValidator
118
- Symplify\PHPStanRules\Formatter\RequiredWithMessageFormatter
12-
- Symplify\PHPStanRules\Location\DirectoryChecker
139
- Symplify\PHPStanRules\Naming\ClassToSuffixResolver
1410
- Symplify\PHPStanRules\NodeAnalyzer\AttributeFinder
1511
- Symplify\PHPStanRules\NodeAnalyzer\EnumAnalyzer

rector.php

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,19 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\PHPUnit\Set\PHPUnitSetList;
7-
use Rector\Set\ValueObject\LevelSetList;
8-
use Rector\Set\ValueObject\SetList;
9-
10-
return static function (RectorConfig $rectorConfig): void {
11-
$rectorConfig->sets([
12-
PHPUnitSetList::PHPUNIT_100,
13-
SetList::CODE_QUALITY,
14-
SetList::DEAD_CODE,
15-
LevelSetList::UP_TO_PHP_81,
16-
SetList::CODING_STYLE,
17-
SetList::TYPE_DECLARATION,
18-
SetList::NAMING,
19-
SetList::PRIVATIZATION,
20-
SetList::EARLY_RETURN,
21-
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
22-
]);
23-
24-
$rectorConfig->paths([
25-
__DIR__ . '/config',
26-
__DIR__ . '/src',
27-
__DIR__ . '/tests',
28-
]);
29-
30-
$rectorConfig->importNames();
31-
32-
$rectorConfig->skip([
6+
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
7+
8+
return RectorConfig::configure()
9+
->withPhpSets()
10+
->withPreparedSets(codeQuality: true, deadCode: true, codingStyle: true, typeDeclarations: true, naming: true, privatization: true, earlyReturn: true, phpunitCodeQuality: true)
11+
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
12+
->withRootFiles()
13+
->withImportNames()
14+
->withSkip([
3315
'*/Source/*',
3416
'*/Fixture/*',
35-
36-
\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [
17+
StringClassNameToClassConstantRector::class => [
3718
__DIR__ . '/tests/Naming/ClassToSuffixResolverTest.php',
3819
__DIR__ . '/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/PhpUpgradeImplementsMinPhpVersionInterfaceRuleTest.php',
3920
],
4021
]);
41-
42-
$rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [
43-
'Symfony\Component\Console\*',
44-
'Rector\Contract\Rector\ConfigurableRectorInterface',
45-
]);
46-
};

src/Composer/ClassNamespaceMatcher.php

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

src/Composer/ComposerAutoloadResolver.php

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

src/Composer/Psr4PathValidator.php

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

src/Location/DirectoryChecker.php

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

src/NodeAnalyzer/EnumAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
use PHPStan\Reflection\ClassReflection;
1313
use Symplify\PHPStanRules\PhpDoc\BarePhpDocParser;
1414

15-
final class EnumAnalyzer
15+
final readonly class EnumAnalyzer
1616
{
1717
public function __construct(
18-
private readonly BarePhpDocParser $barePhpDocParser
18+
private BarePhpDocParser $barePhpDocParser
1919
) {
2020
}
2121

src/NodeFinder/TypeAwareNodeFinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
/**
1111
* @todo remove after https://github.com/nikic/PHP-Parser/pull/869 is released
1212
*/
13-
final class TypeAwareNodeFinder
13+
final readonly class TypeAwareNodeFinder
1414
{
15-
private readonly NodeFinder $nodeFinder;
15+
private NodeFinder $nodeFinder;
1616

1717
public function __construct()
1818
{

0 commit comments

Comments
 (0)