Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README in preparation of version 4.0.0 #103

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->

## Unreleased
- Require PHP ^8.0
- Update to slevomat/coding-standard ^8.0
- Update to squizlabs/php_codesniffer ^3.9
- Update to symplify/easy-coding-standard ^12.1
- Move coding standard declarations from `ecs-7.4.php` and `ecs-8.0.php` to `ecs.php` and remove the former files
- Change deprecated rules to new ones
- Add new `ecs-8.2.php` coding standard declaration file for PHP 8.2+
- Add new `ecs-8.3.php` coding standard declaration file for PHP 8.3+

## 4.0.0 - unreleased
- BC: Update to symplify/easy-coding-standard ^12.1 and change configuration format in `ecs.php`. See [UPGRADE-4.0.md](UPGRADE-4.0.md) for step-by-step upgrade howto.
- BC: Move coding standard declarations from `ecs-7.4.php`, `ecs-8.0.php` and `ecs-8.1.php` to `ecs.php` and remove the former files.
- BC: Change base coding standard from [PSR-2](https://www.php-fig.org/psr/psr-2/) to [PSR-12](https://www.php-fig.org/psr/psr-12/).
- BC: Change deprecated `php-cs-fixer` sniffs to new ones.
- Rebrand to Alma Career in documentation and meta information.
- Require PHP ^8.0.
- Update to slevomat/coding-standard ^8.0.
- Update to squizlabs/php_codesniffer ^3.9.
- Refactor: Remove nette/utils dependency.
- Add tests to ensure the code style defined by this library is being properly checked and fixed.

## 3.3.1 - 2022-05-23
- Lock `symplify/easy-coding-standard` to <10.2.4 because of backward incompatibilities introduced in its bugfix releases.
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ Now you will be able to run the fix using `composer analyze` and execute automat
### Add custom checks or override default settings

On top of the default code-style rules, you are free to add any rules from [PHP-CS-Fixer] or [PHP_CodeSniffer].
If needed, you can also override some default settings.
If needed, you can also override any default settings.

Below find examples of some more opinionated checks you may want to add depending on your needs:

```php
<?php declare(strict_types=1);
Expand All @@ -76,10 +78,20 @@ return ECSConfig::configure()
__DIR__ . '/vendor/lmc/coding-standard/ecs.php',
]
)
// Enforce line-length to 120 characters
->withRules(
[
// PHPUnit attributes must be used over their respective PHPDoc-based annotations. (Use with PHPUnit 10+.)
PhpUnitAttributesFixer::class,
// Single-line comments must have proper spacing.
SingleLineCommentSpacingFixer::class,
]
)
// Enforce line-length to 120 characters.
->withConfiguredRule(LineLengthSniff::class, ['absoluteLineLimit' => 120])
// Tests must have @test annotation
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation']);
// Tests must have @test annotation.
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation'])
// Specify elements separation.
->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['const' => 'none', 'method' => 'one', 'property' => 'none']])
/* (...) */
```

Expand Down
5 changes: 5 additions & 0 deletions ecs-internal.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php declare(strict_types=1);

use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
Expand All @@ -21,6 +22,10 @@
LineLengthFixer::class,
['line_length' => 120, 'break_long_lines' => true, 'inline_short_lines' => false],
)
->withConfiguredRule(
ClassAttributesSeparationFixer::class,
['elements' => ['const' => 'none', 'method' => 'one', 'property' => 'none']],
)
->withSkip(
[
ForbiddenFunctionsSniff::class => ['tests/Integration/CodingStandardTest.php'],
Expand Down
12 changes: 3 additions & 9 deletions src/Sniffs/Naming/ClassNameSuffixByParentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@

final class ClassNameSuffixByParentSniff implements Sniff
{
/**
* @var string
*/
/** @var string */
private const ERROR_MESSAGE = 'Class "%s" should have suffix "%s" by parent class/interface';

/**
* @var string[]
*/
/** @var string[] */
public array $defaultParentClassToSuffixMap = [
'Command',
'Controller',
Expand All @@ -56,9 +52,7 @@ final class ClassNameSuffixByParentSniff implements Sniff
'Handler',
];

/**
* @var string[]
*/
/** @var string[] */
public array $extraParentTypesToSuffixes = [];

/**
Expand Down
1 change: 0 additions & 1 deletion src/Sniffs/Naming/InterfaceNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ final class InterfaceNameSniff implements Sniff
private const ERROR_MESSAGE = 'Interface should have suffix "Interface".';

private int $position;

private File $file;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Sniffs/Naming/TraitNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ final class TraitNameSniff implements Sniff
private const ERROR_MESSAGE = 'Trait should have suffix "Trait".';

private int $position;

private File $file;

/**
Expand Down