Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Oct 15, 2024
1 parent fc5c47d commit 68fc8ea
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/Adapters/Laravel/CollisionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function register(): void

$solutionsRepository = new IgnitionSolutionsRepository($solutionProviderRepository);
} else {
$solutionsRepository = new NullSolutionsRepository();
$solutionsRepository = new NullSolutionsRepository;
}

$writer = new Writer($solutionsRepository);
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/Laravel/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}

Expand Down
4 changes: 1 addition & 3 deletions src/Adapters/Laravel/Exceptions/NotSupportedYetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
/**
* @internal
*/
final class NotSupportedYetException extends RuntimeException implements RenderlessEditor, RenderlessTrace
{
}
final class NotSupportedYetException extends RuntimeException implements RenderlessEditor, RenderlessTrace {}
4 changes: 1 addition & 3 deletions src/Adapters/Laravel/Exceptions/RequirementsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
/**
* @internal
*/
final class RequirementsException extends RuntimeException implements RenderlessEditor, RenderlessTrace
{
}
final class RequirementsException extends RuntimeException implements RenderlessEditor, RenderlessTrace {}
2 changes: 1 addition & 1 deletion src/Adapters/Phpunit/ConfigureIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/Adapters/Phpunit/Printers/DefaultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Adapters/Phpunit/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static function register(): void
if ($shouldRegister) {
self::$registered = true;

Facade::instance()->registerSubscriber(new self());
Facade::instance()->registerSubscriber(new self);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/Phpunit/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ConsoleColor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/Contracts/RenderlessEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
/**
* @internal
*/
interface RenderlessEditor
{
}
interface RenderlessEditor {}
4 changes: 1 addition & 3 deletions src/Contracts/RenderlessTrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
/**
* @internal
*/
interface RenderlessTrace
{
}
interface RenderlessTrace {}
4 changes: 2 additions & 2 deletions src/Coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -60,7 +60,7 @@ public static function isAvailable(): bool
*/
public static function usingXdebug(): bool
{
return (new Runtime())->hasXdebug();
return (new Runtime)->hasXdebug();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Highlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions tests/FakeProgram/FakeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@

use Exception;

class FakeException extends Exception
{
}
class FakeException extends Exception {}
4 changes: 1 addition & 3 deletions tests/FakeProgram/FakeRenderlessException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
10 changes: 5 additions & 5 deletions tests/Unit/Adapters/LaravelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/ArgumentFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ArgumentFormatterTest extends TestCase
/** @test */
public function itFormatsAString(): void
{
$argumentFormatter = new ArgumentFormatter();
$argumentFormatter = new ArgumentFormatter;

$args = ['string' => 'foo'];

Expand All @@ -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.'];

Expand All @@ -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']];

Expand All @@ -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]);

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ProviderTest extends TestCase
/** @test */
public function itRegistersTheErrorHandler(): void
{
$handler = new Handler();
$handler = new Handler;

$runMock = $this->createMock(RunInterface::class);

Expand All @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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);
}

/** @test */
public function itSetsTheOutput(): void
{
$writer = (new Writer())->setOutput($output = new ConsoleOutput());
$writer = (new Writer)->setOutput($output = new ConsoleOutput);

$this->assertEquals($writer->getOutput(), $output);
}
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 68fc8ea

Please sign in to comment.