Skip to content

Commit

Permalink
Remove CheckClassNamespaceFollowPsr4Rule as overly detailed, use comp…
Browse files Browse the repository at this point in the history
…oser-dependency-analyser instead (#150)

* Remove CheckClassNamespaceFollowPsr4Rule as overly detailed, use composer-dependency-analyser instead

* update rector config, bump to PHP 8.2
  • Loading branch information
TomasVotruba authored Dec 16, 2024
1 parent 77fd23a commit 58c2d43
Show file tree
Hide file tree
Showing 37 changed files with 53 additions and 614 deletions.
32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,38 +108,6 @@ class SomeClass

<br>

## CheckClassNamespaceFollowPsr4Rule

Class like namespace "%s" does not follow PSR-4 configuration in `composer.json`

- class: [`Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule`](../src/Rules/CheckClassNamespaceFollowPsr4Rule.php)

```php
// defined "Foo\Bar" namespace in composer.json > autoload > psr-4
namespace Foo;
class Baz
{
}
```

:x:

<br>

```php
// defined "Foo\Bar" namespace in composer.json > autoload > psr-4
namespace Foo\Bar;
class Baz
{
}
```

:+1:

<br>

## CheckRequiredInterfaceInContractNamespaceRule

Interface must be located in "Contract" or "Contracts" namespace
Expand Down
1 change: 0 additions & 1 deletion config/naming-rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ rules:
- Symplify\PHPStanRules\Rules\NoReturnSetterMethodRule
- Symplify\PHPStanRules\Rules\UppercaseConstantRule
- Symplify\PHPStanRules\Rules\ClassNameRespectsParentSuffixRule
- Symplify\PHPStanRules\Rules\CheckClassNamespaceFollowPsr4Rule
4 changes: 0 additions & 4 deletions config/services/services.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ services:
- Symplify\PHPStanRules\Matcher\ArrayStringAndFnMatcher
- Symplify\PHPStanRules\NodeFinder\TypeAwareNodeFinder
- Symplify\PHPStanRules\PhpDoc\SeePhpDocTagNodesFinder
- Symplify\PHPStanRules\Composer\ClassNamespaceMatcher
- Symplify\PHPStanRules\Composer\ComposerAutoloadResolver
- Symplify\PHPStanRules\Composer\Psr4PathValidator
- Symplify\PHPStanRules\Formatter\RequiredWithMessageFormatter
- Symplify\PHPStanRules\Location\DirectoryChecker
- Symplify\PHPStanRules\Naming\ClassToSuffixResolver
- Symplify\PHPStanRules\NodeAnalyzer\AttributeFinder
- Symplify\PHPStanRules\NodeAnalyzer\EnumAnalyzer
Expand Down
45 changes: 10 additions & 35 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,19 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
PHPUnitSetList::PHPUNIT_100,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
LevelSetList::UP_TO_PHP_81,
SetList::CODING_STYLE,
SetList::TYPE_DECLARATION,
SetList::NAMING,
SetList::PRIVATIZATION,
SetList::EARLY_RETURN,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);

$rectorConfig->paths([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->importNames();

$rectorConfig->skip([
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;

return RectorConfig::configure()
->withPhpSets()
->withPreparedSets(codeQuality: true, deadCode: true, codingStyle: true, typeDeclarations: true, naming: true, privatization: true, earlyReturn: true, phpunitCodeQuality: true)
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
->withRootFiles()
->withImportNames()
->withSkip([
'*/Source/*',
'*/Fixture/*',

\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [
StringClassNameToClassConstantRector::class => [
__DIR__ . '/tests/Naming/ClassToSuffixResolverTest.php',
__DIR__ . '/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/PhpUpgradeImplementsMinPhpVersionInterfaceRuleTest.php',
],
]);

$rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [
'Symfony\Component\Console\*',
'Rector\Contract\Rector\ConfigurableRectorInterface',
]);
};
65 changes: 0 additions & 65 deletions src/Composer/ClassNamespaceMatcher.php

This file was deleted.

33 changes: 0 additions & 33 deletions src/Composer/ComposerAutoloadResolver.php

This file was deleted.

47 changes: 0 additions & 47 deletions src/Composer/Psr4PathValidator.php

This file was deleted.

23 changes: 0 additions & 23 deletions src/Location/DirectoryChecker.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/NodeAnalyzer/EnumAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use PHPStan\Reflection\ClassReflection;
use Symplify\PHPStanRules\PhpDoc\BarePhpDocParser;

final class EnumAnalyzer
final readonly class EnumAnalyzer
{
public function __construct(
private readonly BarePhpDocParser $barePhpDocParser
private BarePhpDocParser $barePhpDocParser
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/NodeFinder/TypeAwareNodeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
/**
* @todo remove after https://github.com/nikic/PHP-Parser/pull/869 is released
*/
final class TypeAwareNodeFinder
final readonly class TypeAwareNodeFinder
{
private readonly NodeFinder $nodeFinder;
private NodeFinder $nodeFinder;

public function __construct()
{
Expand Down
6 changes: 3 additions & 3 deletions src/ParentClassMethodNodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
use PHPStan\Reflection\ReflectionProvider;
use Symplify\PHPStanRules\Reflection\ReflectionParser;

final class ParentClassMethodNodeResolver
final readonly class ParentClassMethodNodeResolver
{
public function __construct(
private readonly ReflectionParser $reflectionParser,
private readonly ReflectionProvider $reflectionProvider
private ReflectionParser $reflectionParser,
private ReflectionProvider $reflectionProvider
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/PhpDoc/BarePhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TokenIterator;

final class BarePhpDocParser
final readonly class BarePhpDocParser
{
public function __construct(
private readonly PhpDocParser $phpDocParser,
private readonly Lexer $lexer
private PhpDocParser $phpDocParser,
private Lexer $lexer
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/PhpDoc/PhpDocResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\FileTypeMapper;

final class PhpDocResolver
final readonly class PhpDocResolver
{
public function __construct(
private readonly FileTypeMapper $fileTypeMapper
private FileTypeMapper $fileTypeMapper
) {
}

Expand Down
Loading

0 comments on commit 58c2d43

Please sign in to comment.