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

Enhancement: Add ExplicitRuleSet marker interface #311

Merged
merged 1 commit into from
Dec 25, 2020
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

For a full diff see [`2.9.0...main`][2.9.0...main].

### Changed

* Added `Config\RuleSet\ExplicitRuleSet` marker interface for rule-sets that should be configured explicitly ([#311]), by [@localheinz]

## [`2.9.0`][2.9.0]

For a full diff see [`2.8.0...2.9.0`][2.8.0...2.9.0].
Expand Down Expand Up @@ -294,6 +298,7 @@ For a full diff see [`d899e77...1.0.0`][d899e77...1.0.0].
[#306]: https://github.com/ergebnis/php-cs-fixer-config/pull/306
[#309]: https://github.com/ergebnis/php-cs-fixer-config/pull/309
[#310]: https://github.com/ergebnis/php-cs-fixer-config/pull/310
[#311]: https://github.com/ergebnis/php-cs-fixer-config/pull/311

[@dependabot]: https://github.com/apps/dependabot
[@linuxjuggler]: https://github.com/linuxjuggler
Expand Down
15 changes: 15 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ parameters:
count: 1
path: test/Unit/RuleSet/AbstractRuleSetTestCase.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Ergebnis\\\\\\\\PhpCsFixer\\\\\\\\Config\\\\\\\\RuleSet\\\\\\\\ExplicitRuleSet' and Ergebnis\\\\PhpCsFixer\\\\Config\\\\RuleSet\\\\Php71 will always evaluate to true\\.$#"
count: 1
path: test/Unit/RuleSet/Php71Test.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Ergebnis\\\\\\\\PhpCsFixer\\\\\\\\Config\\\\\\\\RuleSet\\\\\\\\ExplicitRuleSet' and Ergebnis\\\\PhpCsFixer\\\\Config\\\\RuleSet\\\\Php73 will always evaluate to true\\.$#"
count: 1
path: test/Unit/RuleSet/Php73Test.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Ergebnis\\\\\\\\PhpCsFixer\\\\\\\\Config\\\\\\\\RuleSet\\\\\\\\ExplicitRuleSet' and Ergebnis\\\\PhpCsFixer\\\\Config\\\\RuleSet\\\\Php74 will always evaluate to true\\.$#"
count: 1
path: test/Unit/RuleSet/Php74Test.php

21 changes: 21 additions & 0 deletions src/RuleSet/ExplicitRuleSet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2019-2020 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\RuleSet;

/**
* Marker interface for explicit rule sets.
*/
interface ExplicitRuleSet
{
}
2 changes: 1 addition & 1 deletion src/RuleSet/Php71.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use PhpCsFixer\Fixer;

final class Php71 extends AbstractRuleSet
final class Php71 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 7.1)';

Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/Php73.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use PhpCsFixer\Fixer;

final class Php73 extends AbstractRuleSet
final class Php73 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 7.3)';

Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/Php74.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use PhpCsFixer\Fixer;

final class Php74 extends AbstractRuleSet
final class Php74 extends AbstractRuleSet implements ExplicitRuleSet
{
protected $name = 'ergebnis (PHP 7.4)';

Expand Down
8 changes: 8 additions & 0 deletions test/Unit/RuleSet/Php71Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet;

use Ergebnis\PhpCsFixer\Config;
use PhpCsFixer\Fixer;

/**
Expand Down Expand Up @@ -499,4 +500,11 @@ final class Php71Test extends AbstractRuleSetTestCase
];

protected $targetPhpVersion = 70100;

public function testIsExplicitRuleSet(): void
{
$ruleSet = new Config\RuleSet\Php71();

self::assertInstanceOf(Config\RuleSet\ExplicitRuleSet::class, $ruleSet);
}
}
8 changes: 8 additions & 0 deletions test/Unit/RuleSet/Php73Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet;

use Ergebnis\PhpCsFixer\Config;
use PhpCsFixer\Fixer;

/**
Expand Down Expand Up @@ -499,4 +500,11 @@ final class Php73Test extends AbstractRuleSetTestCase
];

protected $targetPhpVersion = 70300;

public function testIsExplicitRuleSet(): void
{
$ruleSet = new Config\RuleSet\Php73();

self::assertInstanceOf(Config\RuleSet\ExplicitRuleSet::class, $ruleSet);
}
}
8 changes: 8 additions & 0 deletions test/Unit/RuleSet/Php74Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet;

use Ergebnis\PhpCsFixer\Config;
use PhpCsFixer\Fixer;

/**
Expand Down Expand Up @@ -499,4 +500,11 @@ final class Php74Test extends AbstractRuleSetTestCase
];

protected $targetPhpVersion = 70400;

public function testIsExplicitRuleSet(): void
{
$ruleSet = new Config\RuleSet\Php74();

self::assertInstanceOf(Config\RuleSet\ExplicitRuleSet::class, $ruleSet);
}
}