Skip to content

Commit

Permalink
Merge pull request #136 from facile-it/small-cs-improvements
Browse files Browse the repository at this point in the history
Small CS improvements
  • Loading branch information
Jean85 committed Apr 8, 2019
2 parents c9e31ee + 97dfba6 commit bb3ca74
Show file tree
Hide file tree
Showing 92 changed files with 238 additions and 338 deletions.
6 changes: 2 additions & 4 deletions src/Paraunit/Command/CoverageCommand.php
Expand Up @@ -35,7 +35,7 @@ public function __construct(CoverageConfiguration $configuration)
];
}

protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -53,10 +53,8 @@ protected function configure()
/**
* @throws \Exception
* @throws \InvalidArgumentException
*
* @return int|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): ?int
{
if (! $this->hasChosenCoverageMethod($input)) {
$coverageMethods = implode($this->coverageMethods, ', ');
Expand Down
9 changes: 2 additions & 7 deletions src/Paraunit/Command/ParallelCommand.php
Expand Up @@ -22,9 +22,6 @@ class ParallelCommand extends Command
/** @var PHPUnitOption[] */
private $phpunitOptions;

/**
* @throws \Symfony\Component\Console\Exception\LogicException
*/
public function __construct(ParallelConfiguration $configuration)
{
$this->phpunitOptions = [
Expand Down Expand Up @@ -61,7 +58,7 @@ public function __construct(ParallelConfiguration $configuration)
$this->configuration = $configuration;
}

protected function configure()
protected function configure(): void
{
$this->setName('run');
$this->setDescription('Run all the requested tests in parallel');
Expand All @@ -83,10 +80,8 @@ protected function configure()

/**
* @throws \Exception
*
* @return int|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): ?int
{
$container = $this->configuration->buildContainer($input, $output);

Expand Down
Expand Up @@ -22,7 +22,7 @@

class ParserDefinition
{
public function configure(ContainerBuilder $container)
public function configure(ContainerBuilder $container): void
{
$logParser = new Definition(LogParser::class, [
new Reference(LogFetcher::class),
Expand Down
6 changes: 3 additions & 3 deletions src/Paraunit/Configuration/EnvVariables.php
Expand Up @@ -6,9 +6,9 @@

class EnvVariables
{
const LOG_DIR = 'PARAUNIT_LOG_DIR';
public const LOG_DIR = 'PARAUNIT_LOG_DIR';

const PIPELINE_NUMBER = 'PARAUNIT_PIPELINE_NUMBER';
public const PIPELINE_NUMBER = 'PARAUNIT_PIPELINE_NUMBER';

const PROCESS_UNIQUE_ID = 'PARAUNIT_PROCESS_UNIQUE_ID';
public const PROCESS_UNIQUE_ID = 'PARAUNIT_PROCESS_UNIQUE_ID';
}
3 changes: 0 additions & 3 deletions src/Paraunit/Configuration/PHPUnitOption.php
Expand Up @@ -18,9 +18,6 @@ class PHPUnitOption
/** @var bool */
private $hasValue;

/**
* @param string | null $shortName
*/
public function __construct(string $name, bool $hasValue = true, string $shortName = null)
{
$this->name = $name;
Expand Down
4 changes: 2 additions & 2 deletions src/Paraunit/Configuration/ParallelConfiguration.php
Expand Up @@ -16,9 +16,9 @@

class ParallelConfiguration
{
const TAG_EVENT_SUBSCRIBER = 'paraunit.event_subscriber';
public const TAG_EVENT_SUBSCRIBER = 'paraunit.event_subscriber';

const PUBLIC_ALIAS_FORMAT = '%s_public_alias';
public const PUBLIC_ALIAS_FORMAT = '%s_public_alias';

/** @var ParallelContainerDefinition */
protected $containerDefinition;
Expand Down
6 changes: 3 additions & 3 deletions src/Paraunit/Lifecycle/EngineEvent.php
Expand Up @@ -8,9 +8,9 @@

class EngineEvent extends Event
{
const BEFORE_START = 'engine_event.before_start';
public const BEFORE_START = 'engine_event.before_start';

const START = 'engine_event.start';
public const START = 'engine_event.start';

const END = 'engine_event.end';
public const END = 'engine_event.end';
}
8 changes: 4 additions & 4 deletions src/Paraunit/Lifecycle/ProcessEvent.php
Expand Up @@ -9,13 +9,13 @@

class ProcessEvent extends Event
{
const PROCESS_STARTED = 'process_event.process_started';
public const PROCESS_STARTED = 'process_event.process_started';

const PROCESS_TERMINATED = 'process_event.process_terminated';
public const PROCESS_TERMINATED = 'process_event.process_terminated';

const PROCESS_TO_BE_RETRIED = 'process_event.process_to_be_retried';
public const PROCESS_TO_BE_RETRIED = 'process_event.process_to_be_retried';

const PROCESS_PARSING_COMPLETED = 'process_event.process_parsing_completed';
public const PROCESS_PARSING_COMPLETED = 'process_event.process_parsing_completed';

/** @var AbstractParaunitProcess */
private $process;
Expand Down
2 changes: 1 addition & 1 deletion src/Paraunit/Parser/JSON/LogFetcher.php
Expand Up @@ -9,7 +9,7 @@

class LogFetcher
{
const LOG_ENDING_STATUS = 'paraunitEnd';
public const LOG_ENDING_STATUS = 'paraunitEnd';

/** @var TempFilenameFactory */
private $fileName;
Expand Down
14 changes: 7 additions & 7 deletions src/Paraunit/Parser/JSON/LogPrinter.php
Expand Up @@ -23,19 +23,19 @@
*/
class LogPrinter extends Util\Printer implements TestListener
{
const STATUS_ERROR = 'error';
public const STATUS_ERROR = 'error';

const STATUS_WARNING = 'warning';
public const STATUS_WARNING = 'warning';

const STATUS_FAIL = 'fail';
public const STATUS_FAIL = 'fail';

const STATUS_PASS = 'pass';
public const STATUS_PASS = 'pass';

const MESSAGE_INCOMPLETE_TEST = 'Incomplete Test: ';
public const MESSAGE_INCOMPLETE_TEST = 'Incomplete Test: ';

const MESSAGE_RISKY_TEST = 'Risky Test: ';
public const MESSAGE_RISKY_TEST = 'Risky Test: ';

const MESSAGE_SKIPPED_TEST = 'Skipped Test: ';
public const MESSAGE_SKIPPED_TEST = 'Skipped Test: ';

/** @var resource */
private $logFile;
Expand Down
13 changes: 5 additions & 8 deletions src/Paraunit/Parser/JSON/TestStartParser.php
Expand Up @@ -10,7 +10,7 @@

class TestStartParser implements ParserChainElementInterface
{
const UNKNOWN_FUNCTION = 'UNKNOWN -- log not found';
private const UNKNOWN_FUNCTION = 'UNKNOWN -- log not found';

/** @var AbstractParaunitProcess */
private $lastProcess;
Expand All @@ -37,10 +37,7 @@ public function handleLogItem(AbstractParaunitProcess $process, \stdClass $logIt
return null;
}

/**
* @return null|NullTestResult
*/
private function handleLogTermination(AbstractParaunitProcess $process, \stdClass $logItem)
private function handleLogTermination(AbstractParaunitProcess $process, \stdClass $logItem): ?NullTestResult
{
if ($process->isWaitingForTestResult()) {
$this->injectLastFunctionInEndingLog($process, $logItem);
Expand All @@ -51,13 +48,13 @@ private function handleLogTermination(AbstractParaunitProcess $process, \stdClas
return new NullTestResult();
}

private function saveProcessFunction(AbstractParaunitProcess $process, \stdClass $logItem)
private function saveProcessFunction(AbstractParaunitProcess $process, \stdClass $logItem): void
{
$this->lastProcess = $process;
$this->lastFunction = property_exists($logItem, 'test') ? $logItem->test : self::UNKNOWN_FUNCTION;
}

private function injectLastFunctionInEndingLog(AbstractParaunitProcess $process, \stdClass $logItem)
private function injectLastFunctionInEndingLog(AbstractParaunitProcess $process, \stdClass $logItem): void
{
$logItem->test = $this->lastFunction;

Expand All @@ -66,7 +63,7 @@ private function injectLastFunctionInEndingLog(AbstractParaunitProcess $process,
}
}

private function saveTestFQCN(AbstractParaunitProcess $process, \stdClass $logItem)
private function saveTestFQCN(AbstractParaunitProcess $process, \stdClass $logItem): void
{
if ($process->getTestClassName()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Paraunit/Printer/FinalPrinter.php
Expand Up @@ -15,7 +15,7 @@

class FinalPrinter extends AbstractFinalPrinter implements EventSubscriberInterface
{
const STOPWATCH_NAME = 'engine';
private const STOPWATCH_NAME = 'engine';

/** @var Stopwatch */
private $stopWatch;
Expand Down
7 changes: 2 additions & 5 deletions src/Paraunit/Printer/ProcessPrinter.php
Expand Up @@ -12,9 +12,9 @@

class ProcessPrinter implements EventSubscriberInterface
{
const MAX_CHAR_LENGTH = 80;
public const MAX_CHAR_LENGTH = 80;

const COUNTER_CHAR_LENGTH = 5;
private const COUNTER_CHAR_LENGTH = 5;

/** @var SingleResultFormatter */
private $singleResultFormatter;
Expand Down Expand Up @@ -45,9 +45,6 @@ public static function getSubscribedEvents(): array
];
}

/**
* @throws \BadMethodCallException
*/
public function onProcessCompleted(ProcessEvent $processEvent): void
{
$process = $processEvent->getProcess();
Expand Down
5 changes: 1 addition & 4 deletions src/Paraunit/Process/AbstractParaunitProcess.php
Expand Up @@ -30,9 +30,6 @@ abstract class AbstractParaunitProcess
/** @var bool */
private $waitingForTestResult;

/**
* @throws \InvalidArgumentException
*/
public function __construct(string $filename)
{
$this->filename = $filename;
Expand All @@ -50,7 +47,7 @@ abstract public function getCommandLine(): string;

abstract public function getExitCode(): ?int;

abstract public function start(int $pipelineNumber);
abstract public function start(int $pipelineNumber): void;

public function getUniqueId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Paraunit/Process/SymfonyProcessWrapper.php
Expand Up @@ -29,7 +29,7 @@ public function isTerminated(): bool
return $this->process->isTerminated();
}

public function start(int $pipelineNumber)
public function start(int $pipelineNumber): void
{
$this->reset();
$env = $this->process->getEnv();
Expand Down
2 changes: 1 addition & 1 deletion tests/BaseFunctionalTestCase.php
Expand Up @@ -8,7 +8,7 @@ abstract class BaseFunctionalTestCase extends BaseIntegrationTestCase
{
protected function setup(): void
{
parent::setUp();
parent::setup();

$this->loadContainer();
}
Expand Down
16 changes: 8 additions & 8 deletions tests/Functional/Command/ParallelCommandTest.php
Expand Up @@ -16,7 +16,7 @@

class ParallelCommandTest extends BaseTestCase
{
public function testExecutionAllGreen()
public function testExecutionAllGreen(): void
{
$configurationPath = $this->getConfigForStubs();
$application = new Application();
Expand All @@ -37,7 +37,7 @@ public function testExecutionAllGreen()
$this->assertEquals(0, $exitCode);
}

public function testExecutionAllGreenWithRepeatOption()
public function testExecutionAllGreenWithRepeatOption(): void
{
$configurationPath = $this->getConfigForStubs();
$application = new Application();
Expand All @@ -59,7 +59,7 @@ public function testExecutionAllGreenWithRepeatOption()
$this->assertEquals(0, $exitCode);
}

public function testExecution()
public function testExecution(): void
{
$configurationPath = $this->getConfigForStubs();
$application = new Application();
Expand All @@ -86,7 +86,7 @@ public function testExecution()
$this->assertContains('Executed: 13 test classes (18 retried), 23 tests', $output);
}

public function testExecutionWithLogo()
public function testExecutionWithLogo(): void
{
$configurationPath = $this->getConfigForStubs();
$application = new Application();
Expand All @@ -104,7 +104,7 @@ public function testExecutionWithLogo()
$this->assertContains('BBBBbBBBBBBB', $output, 'Shark logo missing');
}

public function testExecutionWithDebugEnabled()
public function testExecutionWithDebugEnabled(): void
{
$configurationPath = $this->getConfigForStubs();
$application = new Application();
Expand Down Expand Up @@ -135,7 +135,7 @@ public function testExecutionWithDebugEnabled()
$this->assertSame($processRetried, substr_count($output, 'PROCESS TO BE RETRIED'));
}

public function testExecutionWithParametersWithoutValue()
public function testExecutionWithParametersWithoutValue(): void
{
$configurationPath = $this->getConfigForStubs();
$application = new Application();
Expand All @@ -153,7 +153,7 @@ public function testExecutionWithParametersWithoutValue()
$this->assertSame(0, $exitCode);
}

public function testExecutionWithoutConfiguration()
public function testExecutionWithoutConfiguration(): void
{
$application = new Application();
$application->add(new ParallelCommand(new ParallelConfiguration()));
Expand All @@ -171,7 +171,7 @@ public function testExecutionWithoutConfiguration()
$this->assertSame(0, $exitCode);
}

public function testExecutionWithDeprecationListener()
public function testExecutionWithDeprecationListener(): void
{
$application = new Application();
$application->add(new ParallelCommand(new ParallelConfiguration()));
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Configuration/PHPDbgBinFileTest.php
Expand Up @@ -9,14 +9,14 @@

class PHPDbgBinFileTest extends BaseFunctionalTestCase
{
public function testIsAvailable()
public function testIsAvailable(): void
{
$bin = new PHPDbgBinFile();

$this->assertTrue($bin->isAvailable());
}

public function testGetPhpDbgBin()
public function testGetPhpDbgBin(): void
{
$bin = new PHPDbgBinFile();

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Filter/FilterTest.php
Expand Up @@ -14,7 +14,7 @@ protected function setup(): void
$this->setOption('configuration', $this->getStubPath() . DIRECTORY_SEPARATOR . 'phpunit_with_2_testsuites.xml');
$this->setOption('testsuite', 'suite1,suite2');

parent::setUp(); // TODO: Change the autogenerated stub
parent::setup();
}

public function testFilterTestFiles(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Parser/JSON/AbnormalTerminatedParserTest.php
Expand Up @@ -12,7 +12,7 @@

class AbnormalTerminatedParserTest extends BaseFunctionalTestCase
{
public function testHandleLogItemWithAbnormalTermination()
public function testHandleLogItemWithAbnormalTermination(): void
{
$process = new StubbedParaunitProcess();
$log = new \stdClass();
Expand All @@ -29,7 +29,7 @@ public function testHandleLogItemWithAbnormalTermination()
/**
* @dataProvider otherStatusesProvider
*/
public function testHandleLogItemWithUncatchedLog($otherStatuses)
public function testHandleLogItemWithUncaughtLog(string $otherStatuses): void
{
$process = new StubbedParaunitProcess();
$log = new \stdClass();
Expand Down

0 comments on commit bb3ca74

Please sign in to comment.