Skip to content

Commit 9e18123

Browse files
authored
Remove deprecated dependency & bump coding standard package (#477)
1 parent f2c7c1f commit 9e18123

File tree

13 files changed

+35
-50
lines changed

13 files changed

+35
-50
lines changed

.phpcs.xml.dist

-22
Original file line numberDiff line numberDiff line change
@@ -196,26 +196,4 @@
196196

197197
<!-- Complexity -->
198198
<!-- -->
199-
200-
<!-- Object calisthenics -->
201-
<rule ref="vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/ruleset.xml">
202-
<exclude name="ObjectCalisthenics.ControlStructures.NoElse"/>
203-
<exclude name="ObjectCalisthenics.CodeAnalysis.OneObjectOperatorPerLine"/>
204-
205-
<!-- Code > Classes -->
206-
<exclude name="ObjectCalisthenics.Classes.ForbiddenPublicProperty"/>
207-
<exclude name="ObjectCalisthenics.NamingConventions.NoSetter"/>
208-
209-
<!-- Code > Code -->
210-
<exclude name="ObjectCalisthenics.Metrics.MaxNestingLevel"/>
211-
<exclude name="ObjectCalisthenics.NamingConventions.ElementNameMinimalLength"/>
212-
213-
<!-- Architecture > Classes -->
214-
<exclude name="ObjectCalisthenics.Files.ClassTraitAndInterfaceLength"/>
215-
<exclude name="ObjectCalisthenics.Metrics.MethodPerClassLimit"/>
216-
<exclude name="ObjectCalisthenics.Metrics.PropertyPerClassLimit"/>
217-
218-
<!-- Architecture > Functions -->
219-
<exclude name="ObjectCalisthenics.Files.FunctionLength"/>
220-
</rule>
221199
</ruleset>

composer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
"friendsofphp/php-cs-fixer": "^2.16.1",
2727
"justinrainbow/json-schema": "^5.1",
2828
"league/container": "^3.2",
29-
"object-calisthenics/phpcs-calisthenics-rules": "^3.7",
3029
"php-parallel-lint/php-parallel-lint": "^1.1",
3130
"phploc/phploc": "^5.0|^6.0|^7.0",
3231
"psr/container": "^1.0",
3332
"psr/simple-cache": "^1.0",
34-
"slevomat/coding-standard": "^6.0",
33+
"slevomat/coding-standard": "^7.0",
3534
"squizlabs/php_codesniffer": "^3.5",
3635
"symfony/cache": "^4.4|^5.0",
3736
"symfony/console": "^4.2|^5.0",
@@ -45,7 +44,7 @@
4544
"mockery/mockery": "^1.0",
4645
"phpstan/phpstan-strict-rules": "^0.12",
4746
"phpunit/phpunit": "^8.0|^9.0",
48-
"rector/rector-prefixed": "^0.9.19",
47+
"rector/rector": "^0.10.6",
4948
"symfony/var-dumper": "^4.2|^5.0",
5049
"symplify/easy-coding-standard": "^9.1",
5150
"thecodingmachine/phpstan-strict-rules": "^0.12.0"

docs/insights/architecture.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This sniff checks if the declaration of the class is correct
2929

3030
**Insight Class**: `PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff`
3131

32-
## Class trait and interface length <Badge text="^1.0"/> <Badge text="Architecture\Classes" type="warn"/> <Badge text="configurable"/>
32+
## Class trait and interface length <Badge text=">=1.0 <2.0"/> <Badge text="Architecture\Classes" type="warn"/> <Badge text="configurable"/>
3333

3434
This sniff checks the size of your classes/traits/interface
3535

@@ -45,7 +45,7 @@ This sniff checks the size of your classes/traits/interface
4545
```
4646
</details>
4747

48-
## Method per class limit <Badge text="^1.0"/> <Badge text="Architecture\Classes" type="warn"/> <Badge text="configurable"/>
48+
## Method per class limit <Badge text=">=1.0 <2.0"/> <Badge text="Architecture\Classes" type="warn"/> <Badge text="configurable"/>
4949

5050
This sniff checks if the number of methods per class is under a limit.
5151

@@ -61,8 +61,7 @@ This sniff checks if the number of methods per class is under a limit.
6161
```
6262
</details>
6363

64-
65-
## Property per class limit <Badge text="^1.0"/> <Badge text="Architecture\Classes" type="warn"/> <Badge text="configurable"/>
64+
## Property per class limit <Badge text=">=1.0 <2.0"/> <Badge text="Architecture\Classes" type="warn"/> <Badge text="configurable"/>
6665

6766
This sniff checks if the number of properties per class is under a limit.
6867

@@ -136,7 +135,7 @@ This sniff reports use of superfluous prefix or suffix "Exception" for exception
136135

137136
This sniff checks the size of functions
138137

139-
**Insight Class**: `ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff`
138+
**Insight Class v1.0**: `ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff`
140139

141140
<details>
142141
<summary>Configuration</summary>
@@ -148,6 +147,18 @@ This sniff checks the size of functions
148147
```
149148
</details>
150149

150+
**Insight Class v2.0**: `SlevomatCodingStandard\Sniffs\Files\FunctionLengthSniff`
151+
152+
<details>
153+
<summary>Configuration</summary>
154+
155+
```php
156+
\SlevomatCodingStandard\Sniffs\Files\FunctionLengthSniff::class => [
157+
'maxLength' => 20,
158+
]
159+
```
160+
</details>
161+
151162
## One interface per file <Badge text="^1.0"/> <Badge text="Architecture\Interfaces" type="warn"/>
152163

153164
This sniff checks that only one interface is declared per file.

docs/insights/code.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ The following insights are organised in different metrics :
1313

1414
This sniff disallows public properties.
1515

16-
**Insight Class**: `ObjectCalisthenics\Sniffs\Classes\ForbiddenPublicPropertySniff`
16+
**Insight Class v1.0**: `ObjectCalisthenics\Sniffs\Classes\ForbiddenPublicPropertySniff`
17+
**Insight Class v2.0**: `SlevomatCodingStandard\Sniffs\Classes\ForbiddenPublicPropertySniff`
1718

1819
## Unused private elements <Badge text="^1.0"/> <Badge text="Code\Classes" type="warn"/>
1920

@@ -93,7 +94,7 @@ This sniff ensures all language constructs contain a single space between themse
9394

9495
**Insight Class**: `PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff`
9596

96-
## Element name minimal length <Badge text="^1.0"/> <Badge text="Code\Code" type="warn"/> <Badge text="configurable"/>
97+
## Element name minimal length <Badge text=">=1.0 <2.0"/> <Badge text="Code\Code" type="warn"/> <Badge text="configurable"/>
9798

9899
**Insight Class**: `ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff`
99100

@@ -108,7 +109,7 @@ This sniff ensures all language constructs contain a single space between themse
108109
```
109110
</details>
110111

111-
## Max nesting level <Badge text="^1.0"/> <Badge text="Code\Code" type="warn"/> <Badge text="configurable"/>
112+
## Max nesting level <Badge text=">=1.0 <2.0"/> <Badge text="Code\Code" type="warn"/> <Badge text="configurable"/>
112113

113114
**Insight Class**: `ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff`
114115

@@ -783,7 +784,7 @@ There must be a comment when fall-through is intentional in a non-empty case bod
783784

784785
## Phpdoc scalar <Badge text="^1.10"/> <Badge text="Code\Comments" type="warn"/> <Badge text="configurable"/>
785786

786-
Scalar types should always be written in the same form.
787+
Scalar types should always be written in the same form.
787788
`int` not `integer`, `bool` not `boolean`, `float` not `real` or `double`.
788789

789790
**Insight Class**: `PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer`

src/Application/Adapters/Laravel/Commands/InsightsCommand.php

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function handle(): int
3636
}
3737

3838
$configuration = require $configPath;
39+
/**
40+
* @noRector Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector
41+
*/
3942
$configuration['fix'] = $this->hasOption('fix') && (bool) $this->option('fix') === true;
4043
$configuration = ConfigResolver::resolve($configuration, $this->input);
4144

src/Application/Adapters/Laravel/InsightsServiceProvider.php

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public function register(): void
2323

2424
public function boot(): void
2525
{
26+
/**
27+
* @noRector Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector
28+
*/
2629
if ($this->app instanceof Application) {
2730
$this->publishes([
2831
__DIR__ . '/../../../../stubs/laravel.php' => $this->app->configPath('insights.php'),

src/Application/Injectors/Configuration.php

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function __invoke(): array
4545
$config = require $configPath;
4646
}
4747

48+
/**
49+
* @noRector Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector
50+
*/
4851
$fixOption = $input->hasOption('fix') && (bool) $input->getOption('fix') === true;
4952

5053
$config['fix'] = $fixOption || $input->getFirstArgument() === 'fix';

src/Domain/Metrics/Architecture/Classes.php

-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
use NunoMaduro\PhpInsights\Domain\Contracts\HasInsights;
99
use NunoMaduro\PhpInsights\Domain\Contracts\HasValue;
1010
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenNormalClasses;
11-
use ObjectCalisthenics\Sniffs\Files\ClassTraitAndInterfaceLengthSniff;
12-
use ObjectCalisthenics\Sniffs\Metrics\MethodPerClassLimitSniff;
13-
use ObjectCalisthenics\Sniffs\Metrics\PropertyPerClassLimitSniff;
1411
use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneClassPerFileSniff;
1512
use PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff;
1613
use PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff;
@@ -36,9 +33,6 @@ public function getInsights(): array
3633
ForbiddenNormalClasses::class,
3734
ValidClassNameSniff::class,
3835
ClassDeclarationSniff::class,
39-
ClassTraitAndInterfaceLengthSniff::class,
40-
MethodPerClassLimitSniff::class,
41-
PropertyPerClassLimitSniff::class,
4236
OneClassPerFileSniff::class,
4337
SuperfluousInterfaceNamingSniff::class,
4438
SuperfluousAbstractClassNamingSniff::class,

src/Domain/Metrics/Architecture/Functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use NunoMaduro\PhpInsights\Domain\Collector;
88
use NunoMaduro\PhpInsights\Domain\Contracts\HasInsights;
99
use NunoMaduro\PhpInsights\Domain\Contracts\HasValue;
10-
use ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff;
1110
use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer;
11+
use SlevomatCodingStandard\Sniffs\Files\FunctionLengthSniff;
1212

1313
final class Functions implements HasValue, HasInsights
1414
{

src/Domain/Metrics/Code/Classes.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
use NunoMaduro\PhpInsights\Domain\Contracts\HasPercentage;
1212
use NunoMaduro\PhpInsights\Domain\Contracts\HasValue;
1313
use NunoMaduro\PhpInsights\Domain\Sniffs\ForbiddenSetterSniff;
14-
use ObjectCalisthenics\Sniffs\Classes\ForbiddenPublicPropertySniff;
1514
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff;
1615
use PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff;
1716
use PhpCsFixer\Fixer\ClassNotation\ProtectedToPrivateFixer;
1817
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
1918
use SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff;
2019
use SlevomatCodingStandard\Sniffs\Classes\DisallowLateStaticBindingForConstantsSniff;
20+
use SlevomatCodingStandard\Sniffs\Classes\ForbiddenPublicPropertySniff;
2121
use SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff;
22-
use SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff;
2322
use SlevomatCodingStandard\Sniffs\Classes\UselessLateStaticBindingSniff;
2423

2524
/**
@@ -55,7 +54,6 @@ public function getInsights(): array
5554
return [
5655
//FullyQualifiedClassNameAfterKeywordSniff::class,
5756
ForbiddenPublicPropertySniff::class,
58-
UnusedPrivateElementsSniff::class,
5957
ForbiddenSetterSniff::class,
6058
UnnecessaryFinalModifierSniff::class,
6159
PropertyDeclarationSniff::class,

src/Domain/Metrics/Code/Code.php

-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use NunoMaduro\PhpInsights\Domain\Collector;
88
use NunoMaduro\PhpInsights\Domain\Contracts\HasInsights;
99
use NunoMaduro\PhpInsights\Domain\Contracts\HasValue;
10-
use ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff;
11-
use ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff;
1210
use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff;
1311
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyPHPStatementSniff;
1412
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff;
@@ -85,8 +83,6 @@ public function getInsights(): array
8583
CodeAnalyzerSniff::class,
8684
SwitchDeclarationSniff::class,
8785
LanguageConstructSpacingSniff::class,
88-
ElementNameMinimalLengthSniff::class,
89-
MaxNestingLevelSniff::class,
9086
UselessVariableSniff::class,
9187
EvalSniff::class,
9288
ArrayIndentSniff::class,

tests/Application/ConfigResolverTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Classes;
1414
use PHPUnit\Framework\TestCase;
1515
use SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff;
16-
use SlevomatCodingStandard\Sniffs\Functions\StaticClosureSniff;
1716
use Symfony\Component\Console\Input\ArrayInput;
1817
use Symfony\Component\Console\Input\InputArgument;
1918
use Symfony\Component\Console\Input\InputDefinition;

tests/Domain/Insights/InsightFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use NunoMaduro\PhpInsights\Domain\Insights\InsightFactory;
1111
use NunoMaduro\PhpInsights\Domain\Insights\SniffDecorator;
1212
use NunoMaduro\PhpInsights\Domain\Reflection;
13-
use ObjectCalisthenics\Sniffs\Classes\ForbiddenPublicPropertySniff;
1413
use PHP_CodeSniffer\Sniffs\Sniff as SniffContract;
1514
use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff;
1615
use PhpCsFixer\Fixer\Alias\BacktickToShellExecFixer;
1716
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
1817
use PhpCsFixer\Fixer\FixerInterface;
1918
use PHPUnit\Framework\TestCase;
2019
use RuntimeException;
20+
use SlevomatCodingStandard\Sniffs\Classes\ForbiddenPublicPropertySniff;
2121
use Symfony\Component\Console\Output\NullOutput;
2222
use Tests\Fakes\FakeFileRepository;
2323
use Tests\Fakes\FakeInput;

0 commit comments

Comments
 (0)