Skip to content

Commit d340464

Browse files
committed
misc
1 parent a954fcd commit d340464

12 files changed

+53
-32
lines changed

composer.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"tomasvotruba/class-leak": "^2.0",
1818
"rector/rector": "^2.0",
1919
"phpstan/extension-installer": "^1.4",
20-
"symplify/phpstan-extensions": "^12.0"
20+
"symplify/phpstan-extensions": "^12.0",
21+
"tomasvotruba/unused-public": "^2.0"
2122
},
2223
"autoload": {
2324
"psr-4": {
@@ -30,17 +31,8 @@
3031
},
3132
"classmap": [
3233
"stubs"
33-
],
34-
"files": [
3534
]
3635
},
37-
"extra": {
38-
"phpstan": {
39-
"includes": [
40-
"config/services/services.neon"
41-
]
42-
}
43-
},
4436
"config": {
4537
"platform-check": false,
4638
"allow-plugins": {
@@ -52,5 +44,12 @@
5244
"fix-cs": "vendor/bin/ecs check --fix --ansi",
5345
"phpstan": "vendor/bin/phpstan analyse --ansi",
5446
"rector": "vendor/bin/rector process --dry-run --ansi"
47+
},
48+
"extra": {
49+
"phpstan": {
50+
"includes": [
51+
"config/services/services.neon"
52+
]
53+
}
5554
}
5655
}

phpstan.neon

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ parameters:
2323
- */Fixture/*
2424

2525
# https://github.com/TomasVotruba/unused-public
26-
# unused_public:
27-
# methods: true
28-
# properties: true
29-
# constants: true
26+
unused_public:
27+
methods: true
28+
properties: true
29+
constants: true
3030

3131
# type_coverage:
3232
# return: 99
@@ -70,3 +70,6 @@ parameters:
7070

7171
# handle next
7272
- '#Method Symplify\\PHPStanRules\\Rules\\AbstractSymplifyRule\:\:processNode\(\) should return list<PHPStan\\Rules\\IdentifierRuleError> but returns array<PHPStan\\Rules\\RuleError\|string>#'
73+
74+
# used in tests
75+
- '#Public constant "Symplify\\PHPStanRules\\(.*?)Rule\:\:ERROR_MESSAGE" is never used#'

src/Composer/Psr4PathValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function isClassNamespaceCorrect(
3030

3131
// @todo put into value object
3232
$namespaceSuffixByNamespaceBeforeClass = rtrim(
33-
Strings::substring(
33+
substr(
3434
$classNamespaceAndDirectory->getNamespaceBeforeClass(),
3535
strlen($classNamespaceAndDirectory->getNamespace())
3636
),

src/Enum/ClassName.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symplify\PHPStanRules\Enum;
6+
7+
final class ClassName
8+
{
9+
/**
10+
* @var string
11+
*/
12+
public const ROUTE_ATTRIBUTE = 'Symfony\Component\Routing\Annotation\Route';
13+
14+
/**
15+
* @var string
16+
*/
17+
public const NETTE_STRINGS = 'Nette\Utils\Strings';
18+
}

src/Enum/RuleIdentifier.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,9 @@ final class RuleIdentifier
170170
* @var string
171171
*/
172172
public const REQUIRED_INTERFACE_CONTRACT_NAMESPACE = 'symplify.requiredInterfaceContractNamespace';
173+
174+
/**
175+
* @var string
176+
*/
177+
public const SYMFONY_REQUIRE_INVOKABLE_CONTROLLER = 'symfony.requireInvokableController';
173178
}

src/Naming/ClassToSuffixResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public function resolveFromClass(string $parentClass): string
3232
private function removeAbstractInterfacePrefixSuffix(string $parentType): string
3333
{
3434
if (\str_ends_with($parentType, 'Interface')) {
35-
$parentType = Strings::substring($parentType, 0, -strlen('Interface'));
35+
$parentType = substr($parentType, 0, -strlen('Interface'));
3636
}
3737

3838
if (\str_ends_with($parentType, 'Abstract')) {
39-
$parentType = Strings::substring($parentType, 0, -strlen('Abstract'));
39+
$parentType = substr($parentType, 0, -strlen('Abstract'));
4040
}
4141

4242
if (\str_starts_with($parentType, 'Abstract')) {
43-
return Strings::substring($parentType, strlen('Abstract'));
43+
return substr($parentType, (int) strlen('Abstract'));
4444
}
4545

4646
return $parentType;

src/NodeAnalyzer/RegexStaticCallAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Symplify\PHPStanRules\NodeAnalyzer;
66

7-
use Nette\Utils\Strings;
87
use PhpParser\Node\Expr\StaticCall;
98
use PhpParser\Node\Identifier;
109
use PhpParser\Node\Name;
10+
use Symplify\PHPStanRules\Enum\ClassName;
1111

1212
final class RegexStaticCallAnalyzer
1313
{
@@ -22,7 +22,7 @@ public function isRegexStaticCall(StaticCall $staticCall): bool
2222
return false;
2323
}
2424

25-
if ($staticCall->class->toString() !== Strings::class) {
25+
if ($staticCall->class->toString() !== ClassName::NETTE_STRINGS) {
2626
return false;
2727
}
2828

src/Rules/AnnotateRegexClassConstWithRegexLinkRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array
7373
private function isNonSingleCharRegexPattern(string $value): bool
7474
{
7575
// skip 1-char regexs
76-
if (Strings::length($value) < 4) {
76+
if (strlen($value) < 4) {
7777
return false;
7878
}
7979

@@ -85,7 +85,7 @@ private function isNonSingleCharRegexPattern(string $value): bool
8585

8686
$patternWithoutModifiers = rtrim($value, self::ALL_MODIFIERS);
8787

88-
if (Strings::length($patternWithoutModifiers) < 1) {
88+
if (strlen($patternWithoutModifiers) < 1) {
8989
return false;
9090
}
9191

src/Rules/NoInlineStringRegexRule.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Symplify\PHPStanRules\Rules;
66

7-
use Nette\Utils\Strings;
87
use PhpParser\Node;
98
use PhpParser\Node\Expr\CallLike;
109
use PhpParser\Node\Expr\FuncCall;
@@ -96,7 +95,7 @@ private function processRegexStaticCall(StaticCall $staticCall): array
9695

9796
$regexValue = $secondArgValue->value;
9897

99-
if (Strings::length($regexValue) <= 7) {
98+
if (strlen($regexValue) <= 7) {
10099
return [];
101100
}
102101

src/Rules/UppercaseConstantRule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* @implements Rule<ClassConst>
16+
*
1617
* @see \Symplify\PHPStanRules\Tests\Rules\UppercaseConstantRule\UppercaseConstantRuleTest
1718
*/
1819
final class UppercaseConstantRule implements Rule

0 commit comments

Comments
 (0)