From 68fc8ea494d22cdc31879b059b107396b79d5227 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 15 Oct 2024 16:07:22 +0100 Subject: [PATCH] style --- src/Adapters/Laravel/CollisionServiceProvider.php | 2 +- src/Adapters/Laravel/Commands/TestCommand.php | 4 ++-- .../Laravel/Exceptions/NotSupportedYetException.php | 4 +--- .../Laravel/Exceptions/RequirementsException.php | 4 +--- src/Adapters/Phpunit/ConfigureIO.php | 2 +- src/Adapters/Phpunit/Printers/DefaultPrinter.php | 8 ++++---- src/Adapters/Phpunit/Style.php | 6 +++--- .../EnsurePrinterIsRegisteredSubscriber.php | 2 +- src/Adapters/Phpunit/TestResult.php | 4 ++-- src/ConsoleColor.php | 2 +- src/Contracts/RenderlessEditor.php | 4 +--- src/Contracts/RenderlessTrace.php | 4 +--- src/Coverage.php | 4 ++-- src/Handler.php | 2 +- src/Highlighter.php | 2 +- src/Provider.php | 4 ++-- src/Writer.php | 8 ++++---- tests/FakeProgram/FakeException.php | 4 +--- tests/FakeProgram/FakeRenderlessException.php | 4 +--- tests/Unit/Adapters/LaravelTest.php | 10 +++++----- tests/Unit/ArgumentFormatterTest.php | 10 +++++----- tests/Unit/HandlerTest.php | 6 +++--- tests/Unit/ProviderTest.php | 6 +++--- tests/Unit/WriterTest.php | 8 ++++---- 24 files changed, 51 insertions(+), 63 deletions(-) diff --git a/src/Adapters/Laravel/CollisionServiceProvider.php b/src/Adapters/Laravel/CollisionServiceProvider.php index 87c73bd2..cacd8698 100644 --- a/src/Adapters/Laravel/CollisionServiceProvider.php +++ b/src/Adapters/Laravel/CollisionServiceProvider.php @@ -48,7 +48,7 @@ public function register(): void $solutionsRepository = new IgnitionSolutionsRepository($solutionProviderRepository); } else { - $solutionsRepository = new NullSolutionsRepository(); + $solutionsRepository = new NullSolutionsRepository; } $writer = new Writer($solutionsRepository); diff --git a/src/Adapters/Laravel/Commands/TestCommand.php b/src/Adapters/Laravel/Commands/TestCommand.php index 1309714f..41ae80c0 100644 --- a/src/Adapters/Laravel/Commands/TestCommand.php +++ b/src/Adapters/Laravel/Commands/TestCommand.php @@ -281,7 +281,7 @@ protected function paratestArguments($options) "--runner=\Illuminate\Testing\ParallelRunner", ], $options); - $inputDefinition = new InputDefinition(); + $inputDefinition = new InputDefinition; Options::setInputDefinition($inputDefinition); $input = new ArgvInput($options, $inputDefinition); @@ -379,7 +379,7 @@ protected static function getEnvironmentVariables($path, $file) $vars = []; - foreach ((new Parser())->parse($content) as $entry) { + foreach ((new Parser)->parse($content) as $entry) { $vars[] = $entry->getName(); } diff --git a/src/Adapters/Laravel/Exceptions/NotSupportedYetException.php b/src/Adapters/Laravel/Exceptions/NotSupportedYetException.php index 18989a19..d73530ba 100644 --- a/src/Adapters/Laravel/Exceptions/NotSupportedYetException.php +++ b/src/Adapters/Laravel/Exceptions/NotSupportedYetException.php @@ -11,6 +11,4 @@ /** * @internal */ -final class NotSupportedYetException extends RuntimeException implements RenderlessEditor, RenderlessTrace -{ -} +final class NotSupportedYetException extends RuntimeException implements RenderlessEditor, RenderlessTrace {} diff --git a/src/Adapters/Laravel/Exceptions/RequirementsException.php b/src/Adapters/Laravel/Exceptions/RequirementsException.php index b13b9c29..3827e711 100644 --- a/src/Adapters/Laravel/Exceptions/RequirementsException.php +++ b/src/Adapters/Laravel/Exceptions/RequirementsException.php @@ -11,6 +11,4 @@ /** * @internal */ -final class RequirementsException extends RuntimeException implements RenderlessEditor, RenderlessTrace -{ -} +final class RequirementsException extends RuntimeException implements RenderlessEditor, RenderlessTrace {} diff --git a/src/Adapters/Phpunit/ConfigureIO.php b/src/Adapters/Phpunit/ConfigureIO.php index 6ced9814..d382302b 100644 --- a/src/Adapters/Phpunit/ConfigureIO.php +++ b/src/Adapters/Phpunit/ConfigureIO.php @@ -31,7 +31,7 @@ final class ConfigureIO */ public static function of(InputInterface $input, Output $output): void { - $application = new Application(); + $application = new Application; $reflector = new ReflectionObject($application); $method = $reflector->getMethod('configureIO'); $method->setAccessible(true); diff --git a/src/Adapters/Phpunit/Printers/DefaultPrinter.php b/src/Adapters/Phpunit/Printers/DefaultPrinter.php index 675325f9..85678d25 100644 --- a/src/Adapters/Phpunit/Printers/DefaultPrinter.php +++ b/src/Adapters/Phpunit/Printers/DefaultPrinter.php @@ -98,13 +98,13 @@ public function __construct(bool $colors) { $this->output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, $colors); - ConfigureIO::of(new ArgvInput(), $this->output); + ConfigureIO::of(new ArgvInput, $this->output); self::$verbose = $this->output->isVerbose(); $this->style = new Style($this->output); - $this->state = new State(); + $this->state = new State; } /** @@ -165,7 +165,7 @@ public function testFinished(Finished $event): void $test = $event->test(); if (! $test instanceof TestMethod) { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } if (! $this->state->existsInTestCase($event->test())) { @@ -196,7 +196,7 @@ public function testPreparationStarted(PreparationStarted $event): void $test = $event->test(); if (! $test instanceof TestMethod) { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } if ($this->state->testCaseHasChanged($test)) { diff --git a/src/Adapters/Phpunit/Style.php b/src/Adapters/Phpunit/Style.php index c78ca812..5b58a12d 100644 --- a/src/Adapters/Phpunit/Style.php +++ b/src/Adapters/Phpunit/Style.php @@ -55,7 +55,7 @@ final class Style public function __construct(ConsoleOutputInterface $output) { if (! $output instanceof ConsoleOutput) { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } $this->terminal = terminal(); @@ -173,7 +173,7 @@ public function writeErrorsSummary(State $state): void array_map(function (TestResult $testResult): void { if (! $testResult->throwable instanceof Throwable) { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } renderUsing($this->output); @@ -327,7 +327,7 @@ public function writeSlowTests(array $slowTests, Info $telemetry): void */ public function writeError(Throwable $throwable): void { - $writer = (new Writer())->setOutput($this->output); + $writer = (new Writer)->setOutput($this->output); $throwable = new TestException($throwable, $this->output->isVerbose()); diff --git a/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php b/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php index 97adf303..e51c7116 100644 --- a/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php +++ b/src/Adapters/Phpunit/Subscribers/EnsurePrinterIsRegisteredSubscriber.php @@ -303,7 +303,7 @@ public static function register(): void if ($shouldRegister) { self::$registered = true; - Facade::instance()->registerSubscriber(new self()); + Facade::instance()->registerSubscriber(new self); } } } diff --git a/src/Adapters/Phpunit/TestResult.php b/src/Adapters/Phpunit/TestResult.php index 9a1a22c8..c02e27fc 100644 --- a/src/Adapters/Phpunit/TestResult.php +++ b/src/Adapters/Phpunit/TestResult.php @@ -117,7 +117,7 @@ public function setDuration(float $duration): void public static function fromTestCase(Test $test, string $type, ?Throwable $throwable = null): self { if (! $test instanceof TestMethod) { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } if (is_subclass_of($test->className(), HasPrintableTestCaseName::class)) { @@ -145,7 +145,7 @@ public static function fromTestCase(Test $test, string $type, ?Throwable $throwa public static function fromPestParallelTestCase(Test $test, string $type, ?Throwable $throwable = null): self { if (! $test instanceof TestMethod) { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } if (is_subclass_of($test->className(), HasPrintableTestCaseName::class)) { diff --git a/src/ConsoleColor.php b/src/ConsoleColor.php index c7736db0..7102dee1 100644 --- a/src/ConsoleColor.php +++ b/src/ConsoleColor.php @@ -102,7 +102,7 @@ public function apply(array|string $style, string $text): string } elseif ($this->isValidStyle($s)) { $sequences[] = $this->styleSequence($s); } else { - throw new ShouldNotHappen(); + throw new ShouldNotHappen; } } diff --git a/src/Contracts/RenderlessEditor.php b/src/Contracts/RenderlessEditor.php index abc50df0..00882433 100644 --- a/src/Contracts/RenderlessEditor.php +++ b/src/Contracts/RenderlessEditor.php @@ -7,6 +7,4 @@ /** * @internal */ -interface RenderlessEditor -{ -} +interface RenderlessEditor {} diff --git a/src/Contracts/RenderlessTrace.php b/src/Contracts/RenderlessTrace.php index dc3e69f8..cae0c239 100644 --- a/src/Contracts/RenderlessTrace.php +++ b/src/Contracts/RenderlessTrace.php @@ -7,6 +7,4 @@ /** * @internal */ -interface RenderlessTrace -{ -} +interface RenderlessTrace {} diff --git a/src/Coverage.php b/src/Coverage.php index 9a9fe00a..9eba3df9 100644 --- a/src/Coverage.php +++ b/src/Coverage.php @@ -36,7 +36,7 @@ public static function getPath(): string */ public static function isAvailable(): bool { - $runtime = new Runtime(); + $runtime = new Runtime; if (! $runtime->canCollectCodeCoverage()) { return false; @@ -60,7 +60,7 @@ public static function isAvailable(): bool */ public static function usingXdebug(): bool { - return (new Runtime())->hasXdebug(); + return (new Runtime)->hasXdebug(); } /** diff --git a/src/Handler.php b/src/Handler.php index bb1834aa..f50faba6 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -24,7 +24,7 @@ final class Handler extends AbstractHandler */ public function __construct(?Writer $writer = null) { - $this->writer = $writer ?: new Writer(); + $this->writer = $writer ?: new Writer; } /** diff --git a/src/Highlighter.php b/src/Highlighter.php index c967e63f..a51062f1 100644 --- a/src/Highlighter.php +++ b/src/Highlighter.php @@ -79,7 +79,7 @@ final class Highlighter */ public function __construct(?ConsoleColor $color = null, bool $UTF8 = true) { - $this->color = $color ?: new ConsoleColor(); + $this->color = $color ?: new ConsoleColor; foreach (self::DEFAULT_THEME as $name => $styles) { if (! $this->color->hasTheme($name)) { diff --git a/src/Provider.php b/src/Provider.php index d1fdd8d9..2d5e2935 100644 --- a/src/Provider.php +++ b/src/Provider.php @@ -29,8 +29,8 @@ final class Provider */ public function __construct(?RunInterface $run = null, ?Handler $handler = null) { - $this->run = $run ?: new Run(); - $this->handler = $handler ?: new Handler(); + $this->run = $run ?: new Run; + $this->handler = $handler ?: new Handler; } /** diff --git a/src/Writer.php b/src/Writer.php index 7ef6972e..9ed8a6e8 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -81,10 +81,10 @@ public function __construct( ?ArgumentFormatter $argumentFormatter = null, ?Highlighter $highlighter = null ) { - $this->solutionsRepository = $solutionsRepository ?: new NullSolutionsRepository(); - $this->output = $output ?: new ConsoleOutput(); - $this->argumentFormatter = $argumentFormatter ?: new ArgumentFormatter(); - $this->highlighter = $highlighter ?: new Highlighter(); + $this->solutionsRepository = $solutionsRepository ?: new NullSolutionsRepository; + $this->output = $output ?: new ConsoleOutput; + $this->argumentFormatter = $argumentFormatter ?: new ArgumentFormatter; + $this->highlighter = $highlighter ?: new Highlighter; } public function write(Inspector $inspector): void diff --git a/tests/FakeProgram/FakeException.php b/tests/FakeProgram/FakeException.php index 1d5c0661..02a5ab36 100755 --- a/tests/FakeProgram/FakeException.php +++ b/tests/FakeProgram/FakeException.php @@ -6,6 +6,4 @@ use Exception; -class FakeException extends Exception -{ -} +class FakeException extends Exception {} diff --git a/tests/FakeProgram/FakeRenderlessException.php b/tests/FakeProgram/FakeRenderlessException.php index ecc4d657..787de5f8 100644 --- a/tests/FakeProgram/FakeRenderlessException.php +++ b/tests/FakeProgram/FakeRenderlessException.php @@ -8,6 +8,4 @@ use NunoMaduro\Collision\Contracts\RenderlessEditor; use NunoMaduro\Collision\Contracts\RenderlessTrace; -class FakeRenderlessException extends Exception implements RenderlessEditor, RenderlessTrace -{ -} +class FakeRenderlessException extends Exception implements RenderlessEditor, RenderlessTrace {} diff --git a/tests/Unit/Adapters/LaravelTest.php b/tests/Unit/Adapters/LaravelTest.php index 106cb0da..0d187ce7 100755 --- a/tests/Unit/Adapters/LaravelTest.php +++ b/tests/Unit/Adapters/LaravelTest.php @@ -77,7 +77,7 @@ public function exceptionHandlerRespectsIsContract(): void public function itReportsToTheOriginalExceptionHandler(): void { $app = $this->createApplication(); - $exception = new Exception(); + $exception = new Exception; $originalExceptionHandlerMock = $this->createMock(ExceptionHandlerContract::class); $originalExceptionHandlerMock->expects($this->once())->method('report')->with($exception); @@ -89,8 +89,8 @@ public function itReportsToTheOriginalExceptionHandler(): void public function itRendersToTheOriginalExceptionHandler(): void { $app = $this->createApplication(); - $exception = new Exception(); - $request = new \stdClass(); + $exception = new Exception; + $request = new \stdClass; $originalExceptionHandlerMock = $this->createMock(ExceptionHandlerContract::class); $originalExceptionHandlerMock->expects($this->once())->method('render')->with($request, $exception); @@ -102,8 +102,8 @@ public function itRendersToTheOriginalExceptionHandler(): void public function itRendersNonSymfonyConsoleExceptionsWithSymfony(): void { $app = $this->createApplication(); - $exception = new InvalidArgumentException(); - $output = new BufferedOutput(); + $exception = new InvalidArgumentException; + $output = new BufferedOutput; $originalExceptionHandlerMock = $this->createMock(ExceptionHandlerContract::class); $originalExceptionHandlerMock->expects($this->once())->method('renderForConsole')->with($output, $exception); diff --git a/tests/Unit/ArgumentFormatterTest.php b/tests/Unit/ArgumentFormatterTest.php index 774b24fa..09b5fe75 100755 --- a/tests/Unit/ArgumentFormatterTest.php +++ b/tests/Unit/ArgumentFormatterTest.php @@ -12,7 +12,7 @@ class ArgumentFormatterTest extends TestCase /** @test */ public function itFormatsAString(): void { - $argumentFormatter = new ArgumentFormatter(); + $argumentFormatter = new ArgumentFormatter; $args = ['string' => 'foo']; @@ -24,7 +24,7 @@ public function itFormatsAString(): void /** @test */ public function itFormatsALongString(): void { - $argumentFormatter = new ArgumentFormatter(); + $argumentFormatter = new ArgumentFormatter; $args = ['string' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque volutpat, enim ut ultrices efficitur, sapien justo viverra tellus, a auctor lacus risus quis neque. Proin dictum tincidunt placerat. Suspendisse vehicula arcu elit, a lobortis sem luctus sed. Nullam vehicula, leo sit amet malesuada imperdiet, felis orci tempus risus, non tincidunt lorem massa id ipsum. Nulla sem justo, feugiat et egestas eu, posuere ut dui. Cras quis bibendum justo. Cras finibus consequat mattis. Vivamus eu pretium odio. Suspendisse quis lacus molestie, tempus neque a, sagittis nunc. Etiam posuere quam sed metus volutpat facilisis. Maecenas vel dolor in neque maximus eleifend at in turpis. Nullam a tellus eget tortor volutpat ultricies aliquam sit amet felis. Phasellus efficitur massa consectetur, pharetra lacus eu, ultricies nunc. In sed sapien dignissim, convallis diam id, condimentum elit. Aenean feugiat euismod arcu, et mollis lacus vehicula eget. Aenean bibendum varius lorem vitae efficitur. Duis eget vel.']; @@ -36,7 +36,7 @@ public function itFormatsALongString(): void /** @test */ public function itFormatsAArray(): void { - $argumentFormatter = new ArgumentFormatter(); + $argumentFormatter = new ArgumentFormatter; $args = ['array' => ['foo' => 'bar', 'key' => 'value']]; @@ -48,9 +48,9 @@ public function itFormatsAArray(): void /** @test */ public function itFormatsAObject(): void { - $argumentFormatter = new ArgumentFormatter(); + $argumentFormatter = new ArgumentFormatter; - $object = new \stdClass(); + $object = new \stdClass; $result = $argumentFormatter->format([$object]); diff --git a/tests/Unit/HandlerTest.php b/tests/Unit/HandlerTest.php index 681a4b4e..f9af5735 100755 --- a/tests/Unit/HandlerTest.php +++ b/tests/Unit/HandlerTest.php @@ -14,8 +14,8 @@ class HandlerTest extends TestCase /** @test */ public function itSetsTheOutput(): void { - $output = new ConsoleOutput(); - $handler = new Handler(); + $output = new ConsoleOutput; + $handler = new Handler; $handler->setOutput($output); $this->assertSame($output, $handler->getWriter()->getOutput()); @@ -24,7 +24,7 @@ public function itSetsTheOutput(): void /** @test */ public function itGetsTheWriter(): void { - $writer = new Writer(); + $writer = new Writer; $handler = new Handler($writer); $this->assertEquals($handler->getWriter(), $writer); diff --git a/tests/Unit/ProviderTest.php b/tests/Unit/ProviderTest.php index 62692e73..46ee9f5d 100755 --- a/tests/Unit/ProviderTest.php +++ b/tests/Unit/ProviderTest.php @@ -15,7 +15,7 @@ class ProviderTest extends TestCase /** @test */ public function itRegistersTheErrorHandler(): void { - $handler = new Handler(); + $handler = new Handler; $runMock = $this->createMock(RunInterface::class); @@ -33,8 +33,8 @@ public function itRegistersTheErrorHandler(): void /** @test */ public function itGetsTheHandler(): void { - $handler = new Handler(); - $provider = new Provider(new Run(), $handler); + $handler = new Handler; + $provider = new Provider(new Run, $handler); $this->assertEquals($provider->getHandler(), $handler); } diff --git a/tests/Unit/WriterTest.php b/tests/Unit/WriterTest.php index d127fe32..60748f5c 100755 --- a/tests/Unit/WriterTest.php +++ b/tests/Unit/WriterTest.php @@ -23,7 +23,7 @@ class WriterTest extends TestCase /** @test */ public function itGetsTheOutput(): void { - $writer = new Writer(new NullSolutionsRepository(), $output = new ConsoleOutput()); + $writer = new Writer(new NullSolutionsRepository, $output = new ConsoleOutput); $this->assertEquals($writer->getOutput(), $output); } @@ -31,7 +31,7 @@ public function itGetsTheOutput(): void /** @test */ public function itSetsTheOutput(): void { - $writer = (new Writer())->setOutput($output = new ConsoleOutput()); + $writer = (new Writer)->setOutput($output = new ConsoleOutput); $this->assertEquals($writer->getOutput(), $output); } @@ -295,10 +295,10 @@ public function itSupportsCustomEditorContracts(): void protected function createWriter() { - $output = new BufferedOutput(); + $output = new BufferedOutput; $colorMock = $this->createPartialMock(ConsoleColor::class, ['isSupported']); - return new Writer(new NullSolutionsRepository(), $output, null, new Highlighter($colorMock)); + return new Writer(new NullSolutionsRepository, $output, null, new Highlighter($colorMock)); } }