-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add no global const rule, entity in its namespace and no single imple…
…menter (#132) * Add no GlobalConstRule, no entity outside entity namespace, no single interface implementer * update docs * misc
- Loading branch information
1 parent
019cc50
commit 9f47728
Showing
20 changed files
with
664 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
rules: | ||
- Symplify\PHPStanRules\Rules\NoDynamicNameRule | ||
- Symplify\PHPStanRules\Rules\NoReturnArrayVariableListRule | ||
- Symplify\PHPStanRules\Rules\NoSingleInterfaceImplementerRule | ||
|
||
services: | ||
- | ||
class: Symplify\PHPStanRules\Collector\InterfaceCollector | ||
tags: | ||
- phpstan.collector | ||
|
||
- | ||
class: Symplify\PHPStanRules\Collector\ImplementedInterfaceCollector | ||
tags: | ||
- phpstan.collector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symplify\PHPStanRules\Collector; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt\Class_; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Collectors\Collector; | ||
|
||
final class ImplementedInterfaceCollector implements Collector | ||
{ | ||
public function getNodeType(): string | ||
{ | ||
return Class_::class; | ||
} | ||
|
||
/** | ||
* @param Class_ $node | ||
* @return string[] | ||
*/ | ||
public function processNode(Node $node, Scope $scope): array | ||
{ | ||
$implementedInterfaceNames = []; | ||
|
||
foreach ($node->implements as $implement) { | ||
$implementedInterfaceNames[] = $implement->toString(); | ||
} | ||
|
||
return $implementedInterfaceNames; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symplify\PHPStanRules\Collector; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Name; | ||
use PhpParser\Node\Stmt\Interface_; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Collectors\Collector; | ||
|
||
final class InterfaceCollector implements Collector | ||
{ | ||
public function getNodeType(): string | ||
{ | ||
return Interface_::class; | ||
} | ||
|
||
/** | ||
* @param Interface_ $node | ||
*/ | ||
public function processNode(Node $node, Scope $scope): ?string | ||
{ | ||
if (! $node->namespacedName instanceof Name) { | ||
return null; | ||
} | ||
|
||
return $node->namespacedName->toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.