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: Require ergebnis/php-cs-fixer-config with version ^6.11 #1564

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
-
  • Loading branch information
OskarStark committed Nov 14, 2023
commit 1536ff9f3abcb9292bf2db4c19ae1d195680808f
21 changes: 17 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php

declare(strict_types=1);
use Ergebnis\PhpCsFixer\Config\Factory;
use Ergebnis\PhpCsFixer\Config\RuleSet\Php82;

/**
* This file is part of DOCtor-RST.
*
* (c) Oskar Stark <oskarstark@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Ergebnis\PhpCsFixer;
use Ergebnis\PhpCsFixer\Config\Factory;
use Ergebnis\PhpCsFixer\Config\RuleSet\Php82;

$header = <<<'HEADER'
This file is part of DOCtor-RST.
Expand All @@ -15,7 +24,11 @@
file that was distributed with this source code.
HEADER;

$ruleSet = Php82::create()->withHeader($header)->withRules(PhpCsFixer\Config\Rules::fromArray([
$customRules = [
'no_trailing_whitespace_in_string' => false,
];

$ruleSet = Php82::create()->withHeader($header)->withRules(PhpCsFixer\Config\Rules::fromArray(array_merge([
'blank_line_before_statement' => [
'statements' => [
'break',
Expand Down Expand Up @@ -71,7 +84,7 @@
],
],
'final_public_method_for_abstract_class' => false,
]));
], $customRules)));

$config = Factory::fromRuleSet($ruleSet);

Expand Down
12 changes: 10 additions & 2 deletions composer-unused.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

declare(strict_types=1);

/**
* This file is part of DOCtor-RST.
*
* (c) Oskar Stark <oskarstark@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use ComposerUnused\ComposerUnused\Configuration\Configuration;
use ComposerUnused\ComposerUnused\Configuration\NamedFilter;
use ComposerUnused\ComposerUnused\Configuration\PatternFilter;
use Webmozart\Glob\Glob;

return static fn(Configuration $config): Configuration => $config
return static fn (Configuration $config): Configuration => $config
->addNamedFilter(NamedFilter::fromString('ext-iconv'))
->setAdditionalFilesFor('oskarstark/doctor-rst', [
__FILE__,
Expand Down
2 changes: 2 additions & 0 deletions src/Command/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($output->isVeryVerbose()) {
$output->writeln('Analyze '.$file->getRealPath());
}

$rules = $this->rulesConfiguration->getRulesForFilePath($file->getRelativePathname());
$fileResults[] = new FileResult(
$file,
Expand All @@ -178,6 +179,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
),
);
}

$analyzerResult = new AnalyzerResult($fileResults, $whitelistConfig);

$this->analyzer->write();
Expand Down
2 changes: 2 additions & 0 deletions src/Command/RulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ private function rule(Rule $rule): void
if (\is_array($defaultValue)) {
$defaultValue = '[]';
}

$default = sprintf('`%s`', $defaultValue);
}

Expand Down Expand Up @@ -190,6 +191,7 @@ private function rule(Rule $rule): void
foreach ($rule::getList() as $pattern => $message) {
$this->io->writeln(sprintf('`%s` | %s', str_replace('|', '\|', (string) $pattern), $message ?: $rule->getDefaultMessage()));
}

$this->io->newLine();
}

Expand Down
1 change: 1 addition & 0 deletions src/Rule/NoDirectiveAfterShorthand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function check(Lines $lines, int $number, string $filename): ViolationInt
if (!$lines->current()->isDirective()) {
return NullViolation::create();
}

$line = $lines->current();

$message = sprintf(
Expand Down