-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure rules for PHP 7.4, 8.0 and 8.1
- Loading branch information
1 parent
c817f0c
commit f006cb0
Showing
16 changed files
with
193 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
/vendor/ | ||
|
||
/.php-cs-fixer.cache | ||
/.phpunit.result.cache | ||
|
||
/composer.lock | ||
/phpstan.neon | ||
/phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Beste\PhpCsFixer\Config; | ||
use Ergebnis\PhpCsFixer\Config\Factory; | ||
|
||
$config = Factory::fromRuleSet(new Config\RuleSet\Php81()); | ||
|
||
$config | ||
->getFinder() | ||
->in(__DIR__) | ||
->ignoreDotFiles(false); | ||
|
||
return $config; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# CHANGELOG | ||
|
||
## [Unreleased] | ||
|
||
## [1.0.0] - 2022-08-25 | ||
|
||
* Rules extend the Ergebnis rules with the following modifications: | ||
* `blank_line_between_import_groups`: Blank lines are put between import groups | ||
* `global_namespace_import`: classes and functions are imported | ||
* `phpdoc_align`: PHPDoc items are left-aligned | ||
* `phpdoc_types_order`: types are not sorted, `null` is always last | ||
* `php_unit_test_class_requires_covers`: Tests don't require `@covers` annotations | ||
* `yoda_style`: Condition styles are not enforced | ||
|
||
[Unreleased]: https://github.com/beste/php-cs-fixer-config/compare/1.0.0...main | ||
[1.0.0]: https://github.com/beste/php-cs-fixer-config/tree/1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
# PHP CS Fixer Config | ||
# BESTE PHP CS Fixer Config | ||
|
||
PHP CS Fixer Config used in BESTE projects | ||
PHP CS Fixer Config used in BESTE projects, based on | ||
[`ergebnis/php-cs-fixer-config`](https://github.com/ergebnis/php-cs-fixer-config). | ||
|
||
## Installation | ||
|
||
```shell | ||
composer require beste/php-cs-fixer-config | ||
composer require --dev beste/php-cs-fixer-config | ||
``` | ||
|
||
## Running tests | ||
## Usage | ||
|
||
```shell | ||
composer run tests | ||
``` | ||
Detailed usage instructions can be found in the | ||
[README of `ergebnis/php-cs-fixer-config`](https://github.com/ergebnis/php-cs-fixer-config/blob/main/README.md). | ||
|
||
### Available configurations | ||
|
||
* [`Beste\PhpCsFixer\Config\RuleSet\Php74`](src/Config/RuleSet/Php74.php) | ||
* [`Beste\PhpCsFixer\Config\RuleSet\Php80`](src/Config/RuleSet/Php80.php) | ||
* [`Beste\PhpCsFixer\Config\RuleSet\Php81`](src/Config/RuleSet/Php81.php) | ||
|
||
## Changelog | ||
|
||
Please have a look at [`CHANGELOG.md`](CHANGELOG.md). | ||
|
||
## Credits | ||
|
||
This project extends [`ergebnis/php-cs-fixer-config`](https://github.com/ergebnis/php-cs-fixer-config). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Beste\PhpCsFixer\Config\RuleSet; | ||
|
||
use Ergebnis\PhpCsFixer\Config\RuleSet; | ||
use Ergebnis\PhpCsFixer\Config\RuleSet\Php74 as ErgebnisPhp74; | ||
|
||
use function array_merge; | ||
|
||
final class Php74 implements RuleSet | ||
{ | ||
use RuleOverrides; | ||
private ErgebnisPhp74 $base; | ||
|
||
public function __construct(private readonly ?string $header = null) | ||
{ | ||
$this->base = new ErgebnisPhp74($this->header); | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'BESTE (PHP 7.4)'; | ||
} | ||
|
||
public function targetPhpVersion(): int | ||
{ | ||
return $this->base->targetPhpVersion(); | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return array_merge($this->base->rules(), $this->ruleOverrides()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Beste\PhpCsFixer\Config\RuleSet; | ||
|
||
use Ergebnis\PhpCsFixer\Config\RuleSet; | ||
use Ergebnis\PhpCsFixer\Config\RuleSet\Php80 as ErgebnisPhp80; | ||
|
||
use function array_merge; | ||
|
||
final class Php80 implements RuleSet | ||
{ | ||
use RuleOverrides; | ||
private ErgebnisPhp80 $base; | ||
|
||
public function __construct(private readonly ?string $header = null) | ||
{ | ||
$this->base = new ErgebnisPhp80($this->header); | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'BESTE (PHP 8.0)'; | ||
} | ||
|
||
public function targetPhpVersion(): int | ||
{ | ||
return $this->base->targetPhpVersion(); | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return array_merge($this->base->rules(), $this->ruleOverrides()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Beste\PhpCsFixer\Config\RuleSet; | ||
|
||
use Ergebnis\PhpCsFixer\Config\RuleSet; | ||
use Ergebnis\PhpCsFixer\Config\RuleSet\Php81 as ErgebnisPhp81; | ||
|
||
use function array_merge; | ||
|
||
final class Php81 implements RuleSet | ||
{ | ||
use RuleOverrides; | ||
private ErgebnisPhp81 $base; | ||
|
||
public function __construct(private readonly ?string $header = null) | ||
{ | ||
$this->base = new ErgebnisPhp81($this->header); | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return 'BESTE (PHP 8.1)'; | ||
} | ||
|
||
public function targetPhpVersion(): int | ||
{ | ||
return $this->base->targetPhpVersion(); | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return array_merge($this->base->rules(), $this->ruleOverrides()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Beste\PhpCsFixer\Config\RuleSet; | ||
|
||
trait RuleOverrides | ||
{ | ||
protected function ruleOverrides(): array | ||
{ | ||
return [ | ||
'blank_line_between_import_groups' => true, | ||
'global_namespace_import' => [ | ||
'import_classes' => true, | ||
'import_constants' => false, | ||
'import_functions' => true, | ||
], | ||
'phpdoc_align' => [ | ||
'align' => 'left', | ||
], | ||
'phpdoc_types_order' => [ | ||
'null_adjustment' => 'always_last', | ||
'sort_algorithm' => 'none', | ||
], | ||
'php_unit_test_class_requires_covers' => false, | ||
'yoda_style' => false, | ||
]; | ||
} | ||
} |
Oops, something went wrong.