Skip to content

Commit

Permalink
enable rule fully_qualified_strict_types.phpdoc_tags = \[] to prevent…
Browse files Browse the repository at this point in the history
… php-cs-fixer stripping Namespaces out of comments (#30)
  • Loading branch information
WengerK authored Oct 1, 2024
1 parent e97ae4d commit 008774f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- add running tests on PHP 8.3
- add rule declare_equal_normalize to support declare(strict_types=1) without spaces around equal for Drupal8
- enable ordered_imports.case_sensitive by default since Drupal Coder (8.3.25) is now enforcing it
- enable rule fully_qualified_strict_types.phpdoc_tags = \[] to prevent php-cs-fixer stripping Namespaces out of comments

## [2.1.0] - 2023-10-23
### Added
Expand Down
1 change: 1 addition & 0 deletions config/drupal8/phpcsfixer.rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ parameters:
blank_lines_before_namespace: false
fully_qualified_strict_types:
leading_backslash_in_global_namespace: false
phpdoc_tags: []
42 changes: 42 additions & 0 deletions tests/Integration/Scenario8Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace drupol\PhpCsFixerConfigsDrupal\Tests\Integration;

use drupol\PhpCsFixerConfigsDrupal\Config\Drupal8;
use drupol\PhpCsFixerConfigsDrupal\Tests\IntegrationTestCase;
use PhpCsFixer\FixerFactory;
use PhpCsFixer\RuleSet\RuleSet;

/**
* @author Kevin Wenger <[email protected]>
*
* Covers the PHP-CS-Fixer rules fully_qualified_strict_types.phpdoc_tags
*
* @internal
*/
final class Scenario8Test extends IntegrationTestCase
{
protected function getScenarioPath(): string
{
return __DIR__ . '/fixtures/scenario8';
}

public function testDrupal8Config(): void
{
$drupal8 = new Drupal8();
$rules = $drupal8->getRules();
$ruleset = new RuleSet($rules);

$factory = (new FixerFactory())
->registerBuiltInFixers()
->registerCustomFixers($drupal8->getCustomFixers())
->useRuleSet($ruleset);

$fixers = [];
foreach ($factory->getFixers() as $fixer) {
$fixers[$fixer->getName()] = $fixer;
}

$this->doTest($fixers);
}
}
17 changes: 17 additions & 0 deletions tests/Integration/fixtures/scenario8/bad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Foo;

class Bar {

}

class Baz {

/**
* @var \Foo\Bar $bar
* The Bar class.
*/
private Bar $bar;

}
17 changes: 17 additions & 0 deletions tests/Integration/fixtures/scenario8/good.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Foo;

class Bar {

}

class Baz {

/**
* @var \Foo\Bar
* The Bar class.
*/
private Bar $bar;

}
1 change: 1 addition & 0 deletions tests/Unit/Config/Drupal8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public function testConfigDefault(): void
'full_opening_tag' => true,
'fully_qualified_strict_types' => [
'leading_backslash_in_global_namespace' => false,
'phpdoc_tags' => [],
],
'function_declaration' => [
'closure_function_spacing' => 'one',
Expand Down

0 comments on commit 008774f

Please sign in to comment.