Skip to content

Commit

Permalink
Merge pull request #221 from facile-it/upgrade-cs
Browse files Browse the repository at this point in the history
Upgrade CS ruleset
  • Loading branch information
Jean85 authored Nov 6, 2023
2 parents 71463fa + a394e85 commit 17858d1
Show file tree
Hide file tree
Showing 45 changed files with 53 additions and 105 deletions.
2 changes: 0 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

$additionalRules = [
'declare_strict_types' => true,
'no_superfluous_phpdoc_tags' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'phpdoc_to_comment' => false,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'random_api_migration' => true,
'self_accessor' => true,
];
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"symfony/stopwatch": "^4.4||^5.0||^6.0"
},
"require-dev": {
"facile-it/facile-coding-standard": "^0.5.1",
"facile-it/facile-coding-standard": "^1.0",
"jangregor/phpstan-prophecy": "^1.0.0",
"phpspec/prophecy": "dev-master as 1.18",
"phpspec/prophecy-phpunit": "dev-master as 2.2.0",
Expand Down
4 changes: 1 addition & 3 deletions src/Configuration/TempFilenameFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

class TempFilenameFactory
{
public function __construct(private readonly TempDirectory $tempDirectory)
{
}
public function __construct(private readonly TempDirectory $tempDirectory) {}

/**
* @phpstan-return non-empty-string
Expand Down
3 changes: 1 addition & 2 deletions src/Coverage/CoverageFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class CoverageFetcher
public function __construct(
private readonly TempFilenameFactory $tempFilenameFactory,
private readonly TestResultContainer $testResultContainer,
) {
}
) {}

public function fetch(Process $process): CodeCoverage
{
Expand Down
4 changes: 1 addition & 3 deletions src/Coverage/CoverageMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class CoverageMerger implements EventSubscriberInterface
{
private ?CodeCoverage $coverageData = null;

public function __construct(private readonly CoverageFetcher $coverageFetcher)
{
}
public function __construct(private readonly CoverageFetcher $coverageFetcher) {}

/**
* @return array<string, string>
Expand Down
4 changes: 1 addition & 3 deletions src/Coverage/CoverageResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class CoverageResult implements EventSubscriberInterface
/** @var CoverageProcessorInterface[] */
private array $coverageProcessors = [];

public function __construct(private readonly CoverageMerger $coverageMerger)
{
}
public function __construct(private readonly CoverageMerger $coverageMerger) {}

/**
* @return array<string, string>
Expand Down
4 changes: 1 addition & 3 deletions src/File/Cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

class Cleaner implements EventSubscriberInterface
{
public function __construct(private readonly TempDirectory $tempDirectory)
{
}
public function __construct(private readonly TempDirectory $tempDirectory) {}

/**
* @return array<string, string>
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private function getDOMNodeAttribute(
private function filterByString(array $aggregatedFiles, ?string $stringFilter): array
{
if ($stringFilter !== null) {
$aggregatedFiles = array_filter($aggregatedFiles, fn ($value): bool => stripos($value, $stringFilter) !== false);
$aggregatedFiles = array_filter($aggregatedFiles, fn($value): bool => stripos($value, $stringFilter) !== false);
}

return array_values($aggregatedFiles);
Expand Down
4 changes: 1 addition & 3 deletions src/Filter/RandomizeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

class RandomizeList implements TestList
{
public function __construct(private readonly TestList $testList)
{
}
public function __construct(private readonly TestList $testList) {}

public function getTests(): array
{
Expand Down
4 changes: 1 addition & 3 deletions src/Lifecycle/AbstractProcessEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

abstract class AbstractProcessEvent
{
public function __construct(private readonly Process $process)
{
}
public function __construct(private readonly Process $process) {}

public function getProcess(): Process
{
Expand Down
4 changes: 1 addition & 3 deletions src/Lifecycle/BeforeEngineStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class BeforeEngineStart
{
}
class BeforeEngineStart {}
4 changes: 1 addition & 3 deletions src/Lifecycle/EngineEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class EngineEnd
{
}
class EngineEnd {}
4 changes: 1 addition & 3 deletions src/Lifecycle/EngineStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class EngineStart
{
}
class EngineStart {}
4 changes: 1 addition & 3 deletions src/Lifecycle/ProcessParsingCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class ProcessParsingCompleted extends AbstractProcessEvent
{
}
class ProcessParsingCompleted extends AbstractProcessEvent {}
4 changes: 1 addition & 3 deletions src/Lifecycle/ProcessStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class ProcessStarted extends AbstractProcessEvent
{
}
class ProcessStarted extends AbstractProcessEvent {}
4 changes: 1 addition & 3 deletions src/Lifecycle/ProcessTerminated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class ProcessTerminated extends AbstractProcessEvent
{
}
class ProcessTerminated extends AbstractProcessEvent {}
4 changes: 1 addition & 3 deletions src/Lifecycle/ProcessToBeRetried.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Paraunit\Lifecycle;

class ProcessToBeRetried extends AbstractProcessEvent
{
}
class ProcessToBeRetried extends AbstractProcessEvent {}
3 changes: 1 addition & 2 deletions src/Lifecycle/TestCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ class TestCompleted
public function __construct(
public readonly Test $test,
public readonly TestOutcome|TestIssue $outcome,
) {
}
) {}
}
4 changes: 1 addition & 3 deletions src/Logs/JSON/LogFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

class LogFetcher
{
public function __construct(private readonly TempFilenameFactory $fileName)
{
}
public function __construct(private readonly TempFilenameFactory $fileName) {}

/**
* @return list<LogData>
Expand Down
3 changes: 1 addition & 2 deletions src/Logs/JSON/LogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public function __construct(
private readonly LogHandler $logHandler,
private readonly RetryParser $retryParser,
private readonly EventDispatcherInterface $eventDispatcher,
) {
}
) {}

/**
* @return array<string, string>
Expand Down
2 changes: 1 addition & 1 deletion src/Logs/TestHook/AbstractTestHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final protected function write(LogStatus $status, Test $test, ?string $message):
private function getLogFilename(): string
{
$logDir = $this->getLogDirectory();
if (! @mkdir($logDir, 0777, true) && ! is_dir($logDir)) {
if (! @mkdir($logDir, 0o777, true) && ! is_dir($logDir)) {
throw new \RuntimeException('Cannot create folder for JSON logs');
}

Expand Down
5 changes: 2 additions & 3 deletions src/Logs/ValueObject/LogData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public function __construct(
public readonly LogStatus $status,
public readonly Test $test,
public readonly ?string $message
) {
}
) {}

/**
* @psalm-assert array{status: string, test: string, message?: string|null} $log
Expand Down Expand Up @@ -109,7 +108,7 @@ public static function parse(string $jsonLog): array
/**
* @param string $jsonString The dirty output
*
* @return non-empty-string The normalized log, as an array of JSON objects
* @return non-empty-string The normalized log, as an array of JSON objects
*/
private static function cleanLog(string $jsonString): string
{
Expand Down
4 changes: 1 addition & 3 deletions src/Logs/ValueObject/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

class Test implements \JsonSerializable
{
public function __construct(public readonly string $name)
{
}
public function __construct(public readonly string $name) {}

final public static function fromPHPUnitTest(PHPUnitTest $test): self
{
Expand Down
4 changes: 1 addition & 3 deletions src/Printer/ConsoleFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

class ConsoleFormatter implements EventSubscriberInterface
{
public function __construct(private readonly OutputFormatterInterface $outputFormatter)
{
}
public function __construct(private readonly OutputFormatterInterface $outputFormatter) {}

/**
* @return array<class-string, string|array{0: string, 1: int}>
Expand Down
3 changes: 1 addition & 2 deletions src/Printer/CoveragePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class CoveragePrinter implements EventSubscriberInterface
public function __construct(
private readonly CommandLineWithCoverage $commandLine,
private readonly OutputInterface $output
) {
}
) {}

/**
* @return array<class-string, string|array{0: string, 1: int}>
Expand Down
4 changes: 1 addition & 3 deletions src/Printer/DebugPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

class DebugPrinter implements EventSubscriberInterface
{
public function __construct(private readonly OutputInterface $output)
{
}
public function __construct(private readonly OutputInterface $output) {}

/**
* @return array<class-string, string|array{0: string, 1: int}>
Expand Down
3 changes: 1 addition & 2 deletions src/Printer/FailuresPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class FailuresPrinter implements EventSubscriberInterface
public function __construct(
private readonly OutputInterface $output,
private readonly TestResultContainer $testResultContainer
) {
}
) {}

/**
* @return array<class-string, string|array{0: string, 1: int}>
Expand Down
5 changes: 2 additions & 3 deletions src/Printer/FilesRecapPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function __construct(
private readonly OutputInterface $output,
private readonly TestResultContainer $testResultContainer,
private readonly ChunkSize $chunkSize,
) {
}
) {}

/**
* @return array<class-string, string|array{0: string, 1: int}>
Expand Down Expand Up @@ -65,7 +64,7 @@ private function printFileRecap(TestOutcome|TestIssue $status, OutputStyle $styl
$this->output->writeln('');
$this->output->writeln(
sprintf(
"<%s>%d $fileTitle with %s:</%s>",
"<%s>%d {$fileTitle} with %s:</%s>",
$style->value,
count($filenames),
strtoupper($status->getTitle()),
Expand Down
2 changes: 1 addition & 1 deletion src/Printer/FinalPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function printTestCounters(): void
$this->output->writeln('');
$executedTitle = $this->chunkSize->isChunked() ? 'chunks' : 'test classes';

$this->output->write(sprintf("Executed: %d $executedTitle", $this->processCompleted));
$this->output->write(sprintf("Executed: %d {$executedTitle}", $this->processCompleted));

if ($this->processRetried > 0) {
$this->output->write(sprintf(' (%d retried)', $this->processRetried));
Expand Down
4 changes: 1 addition & 3 deletions src/Printer/ProgressPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class ProgressPrinter implements EventSubscriberInterface

private int $singleRowCounter = 0;

public function __construct(private readonly OutputInterface $output)
{
}
public function __construct(private readonly OutputInterface $output) {}

/**
* @return array<class-string, string|array{0: string, 1: int}>
Expand Down
3 changes: 1 addition & 2 deletions src/Printer/SharkPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class SharkPrinter implements EventSubscriberInterface
public function __construct(
private readonly OutputInterface $output,
private readonly bool $showLogo
) {
}
) {}

/**
* @return array<class-string, array{0: string, 1: int}>
Expand Down
3 changes: 1 addition & 2 deletions src/Process/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class CommandLine
public function __construct(
protected PHPUnitBinFile $phpUnitBin,
protected ChunkSize $chunkSize
) {
}
) {}

/**
* @return string[]
Expand Down
2 changes: 1 addition & 1 deletion src/Runner/ChunkFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function createChunkFile(
}

$nameAttribute = $document->createAttribute('name');
$nameAttribute->value = "Tests Suite $chunkNumber";
$nameAttribute->value = "Tests Suite {$chunkNumber}";

$newTestSuiteNode = $document->createElement('testsuite');
$newTestSuiteNode->appendChild($nameAttribute);
Expand Down
3 changes: 1 addition & 2 deletions src/Runner/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public function __construct(
private readonly EventDispatcherInterface $dispatcher,
/** @var positive-int $number */
private readonly int $number
) {
}
) {}

public function execute(Process $process): void
{
Expand Down
4 changes: 1 addition & 3 deletions src/Runner/PipelineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

class PipelineFactory
{
public function __construct(private readonly EventDispatcherInterface $dispatcher)
{
}
public function __construct(private readonly EventDispatcherInterface $dispatcher) {}

/**
* @param positive-int $pipelineNumber
Expand Down
5 changes: 3 additions & 2 deletions src/Runner/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Paraunit\Runner;

use function function_exists;
use Paraunit\Configuration\ChunkSize;
use Paraunit\Filter\TestList;
use Paraunit\Lifecycle\BeforeEngineStart;
Expand All @@ -19,6 +18,8 @@
use RuntimeException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use function function_exists;

class Runner implements EventSubscriberInterface
{
/** @var \SplQueue<Process> */
Expand Down Expand Up @@ -144,7 +145,7 @@ public function onShutdown(): void
try {
$this->chunkFile->deleteChunkFile($this->queuedProcesses->dequeue());
} catch (RuntimeException) {
//pass
// pass
}
} while (! $this->queuedProcesses->isEmpty());
}
Expand Down
3 changes: 1 addition & 2 deletions src/TestResult/ValueObject/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class TestResult
public function __construct(
public readonly Test $test,
public readonly TestOutcome|TestIssue $status,
) {
}
) {}

public static function from(LogData $log): self
{
Expand Down
Loading

0 comments on commit 17858d1

Please sign in to comment.