Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit b825485

Browse files
committed
Add new ecs_7.4 coding standards for php 7.4+
1 parent 965c911 commit b825485

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

CHANGELOG.md

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

77
## Unreleased
88
- Fix SpecifyArgSeparatorFixer not compatible with php-cs-fixer 3.0.
9+
- Add new `ecs-7.4.php` coding standard declaration file for PHP 7.4+.
910

1011
## 3.1.0 - 2021-05-13
1112
- Use php-cs-fixer 3.0.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
2626

2727
return static function (ContainerConfigurator $containerConfigurator): void {
2828
$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs.php');
29+
30+
// If you only need PHP 7.4+ in your project, uncomment this to import additional checks:
31+
//$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs-7.4.php');
2932
};
3033
```
3134

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@
4949
"@test"
5050
],
5151
"analyze": [
52-
"vendor/bin/ecs check src/ tests/ ecs.php --ansi",
52+
"vendor/bin/ecs check src/ tests/ ecs.php ecs-7.4.php --ansi",
5353
"vendor/bin/ecs check-markdown README.md --ansi",
5454
"vendor/bin/phpstan analyze -c phpstan.neon --ansi"
5555
],
5656
"fix": [
5757
"@composer normalize",
58-
"vendor/bin/ecs check ./src/ ./tests/ ecs.php --ansi --fix"
58+
"vendor/bin/ecs check ./src/ ./tests/ ecs.php ecs-7.4.php --ansi --fix"
5959
],
6060
"lint": [
61-
"vendor/bin/parallel-lint -j 10 -e php ./src ./tests ecs.php",
61+
"vendor/bin/parallel-lint -j 10 -e php ./src ./tests ecs.php ecs-7.4.php",
6262
"@composer validate",
6363
"@composer normalize --dry-run"
6464
],

ecs-7.4.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php declare(strict_types=1);
2+
3+
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToParamTypeFixer;
4+
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToPropertyTypeFixer;
5+
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer;
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7+
8+
return static function (ContainerConfigurator $containerConfigurator): void {
9+
$services = $containerConfigurator->services();
10+
11+
// Takes `@var` annotation of non-mixed types and adjusts accordingly the property signature.
12+
$services->set(PhpdocToPropertyTypeFixer::class);
13+
// Takes `@param` annotations of non-mixed types and adjusts accordingly the function signature.
14+
$services->set(PhpdocToParamTypeFixer::class);
15+
// Takes `@return` annotation of non-mixed types and adjusts accordingly the function signature.
16+
$services->set(PhpdocToReturnTypeFixer::class);
17+
};

0 commit comments

Comments
 (0)