generated from spawnia/php-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon Bigelmayr
committed
Dec 9, 2024
1 parent
02f521b
commit 123d8b6
Showing
10 changed files
with
145 additions
and
67 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/PHPStan/NodeNameExtractor/ClassMethodNameExtractor.php
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,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\PHPStan\NodeNameExtractor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt\ClassMethod; | ||
|
||
class ClassMethodNameExtractor implements NodeNameExtractor | ||
{ | ||
public function extract(Node $node): ?string | ||
{ | ||
if ($node instanceof ClassMethod) { | ||
return $node->name->toString(); | ||
} | ||
|
||
return null; | ||
} | ||
} |
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,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\PHPStan\NodeNameExtractor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Identifier; | ||
use PhpParser\Node\Stmt\Class_; | ||
|
||
class ClassNameExtractor implements NodeNameExtractor | ||
{ | ||
public function extract(Node $node): ?string | ||
{ | ||
if ($node instanceof Class_ && $node->name instanceof Identifier) { | ||
return $node->name->toString(); | ||
} | ||
|
||
return null; | ||
} | ||
} |
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,10 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\PHPStan\NodeNameExtractor; | ||
|
||
use PhpParser\Node; | ||
|
||
interface NodeNameExtractor | ||
{ | ||
public function extract(Node $node): ?string; | ||
} |
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,22 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\PHPStan\NodeNameExtractor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Scalar\EncapsedStringPart; | ||
use PhpParser\Node\Scalar\String_; | ||
|
||
class StringNameExtractor implements NodeNameExtractor | ||
{ | ||
public function extract(Node $node): ?string | ||
{ | ||
if ($node instanceof String_) { | ||
return $node->value; | ||
} | ||
if ($node instanceof EncapsedStringPart) { | ||
return $node->value; | ||
} | ||
|
||
return null; | ||
} | ||
} |
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,25 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\PHPStan\NodeNameExtractor; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Expr\Variable; | ||
use PhpParser\Node\Param; | ||
|
||
class VariableNameExtractor implements NodeNameExtractor | ||
{ | ||
public function extract(Node $node): ?string | ||
{ | ||
if ($node instanceof Variable && is_string($node->name)) { | ||
return $node->name; | ||
} | ||
if ($node instanceof Param | ||
&& $node->var instanceof Variable | ||
&& is_string($node->var->name) | ||
) { | ||
return $node->var->name; | ||
} | ||
|
||
return null; | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...Stan/Rules/CapitalizationOfIDRuleTest.php → ...onOfIDRule/CapitalizationOfIDRuleTest.php
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