Skip to content

Commit 7b9c561

Browse files
authored
Remove BoolishClassMethodPrefixRule as very limited and often ignored (#114)
* Remove BoolishClassMethodPrefixRule as very limited and often ignored * bump deps * static fixes * misc
1 parent ab872b8 commit 7b9c561

21 files changed

+20
-460
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"php": ">=8.1",
88
"nette/utils": "^3.2.9 || ^4.0",
99
"webmozart/assert": "^1.11",
10-
"phpstan/phpstan": "^1.10.30",
10+
"phpstan/phpstan": "^1.11",
1111
"symplify/rule-doc-generator-contracts": "^11.1.26"
1212
},
1313
"require-dev": {
14-
"nikic/php-parser": "^4.18",
14+
"nikic/php-parser": "^4.19",
1515
"symplify/phpstan-extensions": "^11.4",
1616
"symplify/rule-doc-generator": "^12.0",
1717
"phpunit/phpunit": "^10.5",
1818
"symfony/framework-bundle": "6.1.*",
19-
"rector/rector": "^0.19.0",
19+
"rector/rector": "^1.1",
2020
"symplify/easy-coding-standard": "^12.1",
2121
"phpstan/extension-installer": "^1.3",
2222
"tomasvotruba/class-leak": "^0.2"

config/services/services.neon

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ services:
1212
- Symplify\PHPStanRules\Composer\Psr4PathValidator
1313
- Symplify\PHPStanRules\Formatter\RequiredWithMessageFormatter
1414
- Symplify\PHPStanRules\Location\DirectoryChecker
15-
- Symplify\PHPStanRules\Naming\BoolishNameAnalyser
1615
- Symplify\PHPStanRules\Naming\ClassToSuffixResolver
1716
- Symplify\PHPStanRules\NodeAnalyzer\AttributeFinder
1817
- Symplify\PHPStanRules\NodeAnalyzer\EnumAnalyzer

config/static-rules.neon

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ rules:
1717
- Symplify\PHPStanRules\Rules\NoArrayAccessOnObjectRule
1818

1919
- Symplify\PHPStanRules\Rules\NoNullableArrayPropertyRule
20-
- Symplify\PHPStanRules\Rules\BoolishClassMethodPrefixRule
2120

2221
# dead-code
2322
- Symplify\PHPStanRules\Rules\NoIssetOnObjectRule

docs/rules_overview.md

+1-73
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 48 Rules Overview
1+
# 46 Rules Overview
22

33
## AnnotateRegexClassConstWithRegexLinkRule
44

@@ -31,40 +31,6 @@ class SomeClass
3131

3232
<br>
3333

34-
## BoolishClassMethodPrefixRule
35-
36-
Method `"%s()"` returns bool type, so the name should start with is/has/was...
37-
38-
- class: [`Symplify\PHPStanRules\Rules\BoolishClassMethodPrefixRule`](../src/Rules/BoolishClassMethodPrefixRule.php)
39-
40-
```php
41-
class SomeClass
42-
{
43-
public function old(): bool
44-
{
45-
return $this->age > 100;
46-
}
47-
}
48-
```
49-
50-
:x:
51-
52-
<br>
53-
54-
```php
55-
class SomeClass
56-
{
57-
public function isOld(): bool
58-
{
59-
return $this->age > 100;
60-
}
61-
}
62-
```
63-
64-
:+1:
65-
66-
<br>
67-
6834
## CheckClassNamespaceFollowPsr4Rule
6935

7036
Class like namespace "%s" does not follow PSR-4 configuration in `composer.json`
@@ -616,44 +582,6 @@ interface RunnableInterface
616582

617583
<br>
618584

619-
## NoAbstractRule
620-
621-
Instead of abstract class, use specific service with composition
622-
623-
- class: [`Symplify\PHPStanRules\Rules\Complexity\NoAbstractRule`](../src/Rules/Complexity/NoAbstractRule.php)
624-
625-
```php
626-
final class NormalHelper extends AbstractHelper
627-
{
628-
}
629-
630-
abstract class AbstractHelper
631-
{
632-
}
633-
```
634-
635-
:x:
636-
637-
<br>
638-
639-
```php
640-
final class NormalHelper
641-
{
642-
public function __construct(
643-
private SpecificHelper $specificHelper
644-
) {
645-
}
646-
}
647-
648-
final class SpecificHelper
649-
{
650-
}
651-
```
652-
653-
:+1:
654-
655-
<br>
656-
657585
## NoArrayAccessOnObjectRule
658586

659587
Use explicit methods over array access on object

phpstan.neon

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ parameters:
1010
- config
1111
- tests
1212

13-
reportUnmatchedIgnoredErrors: false
13+
# reportUnmatchedIgnoredErrors: false
1414

1515
excludePaths:
1616
# parallel
@@ -52,5 +52,4 @@ parameters:
5252
- '#Method Symplify\\PHPStanRules\\(.*?)\:\:getRule\(\) return type with generic interface PHPStan\\Rules\\Rule does not specify its types\: TNodeType#'
5353

5454
# part of public contract
55-
- '#Public constant "Symplify\\PHPStanRules\\(.*?)\:\:ERROR_MESSAGE" is never used#'
5655
- '#Method Symplify\\PHPStanRules\\Tests\\Rules\\PHPUnit\\(.*?)\\(.*?)Test\:\:testRule\(\) has parameter \$expectedErrorMessagesWithLines with no value type specified in iterable type array#'

src/Naming/BoolishNameAnalyser.php

-49
This file was deleted.

src/ReturnTypeExtension/NodeGetAttributeTypeExtension.php

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Rector\NodeTypeResolver\Node\AttributeKey;
2323

2424
/**
25+
* @api used in rector rules
2526
* @see \Symplify\PHPStanRules\Tests\ReturnTypeExtension\NodeGetAttributeTypeExtension\NodeGetAttributeTypeExtensionTest
2627
*/
2728
final class NodeGetAttributeTypeExtension implements DynamicMethodReturnTypeExtension

src/Rules/BoolishClassMethodPrefixRule.php

-154
This file was deleted.

src/Rules/ClassNameRespectsParentSuffixRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Rector\Rector\AbstractRector;
1717
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
18-
use Symfony\Component\Console\Command\Command;
1918
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2019
use Symplify\PHPStanRules\Naming\ClassToSuffixResolver;
2120
use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
@@ -37,7 +36,7 @@ final class ClassNameRespectsParentSuffixRule implements Rule, DocumentedRuleInt
3736
* @var string[]
3837
*/
3938
private const DEFAULT_PARENT_CLASSES = [
40-
Command::class,
39+
'Symfony\Component\Console\Command\Command',
4140
EventSubscriberInterface::class,
4241
AbstractController::class,
4342
Sniff::class,
@@ -111,7 +110,7 @@ class SomeCommand extends Command
111110
CODE_SAMPLE
112111
,
113112
[
114-
'parentClasses' => [Command::class],
113+
'parentClasses' => ['Symfony\Component\Console\Command\Command'],
115114
]
116115
),
117116
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Symfony\Component\Console\Command;
4+
5+
if (class_exists('Symfony\Component\Console\Command\Command')) {
6+
return;
7+
}
8+
9+
class Command
10+
{
11+
}

0 commit comments

Comments
 (0)