From 0601261f0c354d758cf5467790e2d5c106617982 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 25 Jun 2024 21:59:54 +0000 Subject: [PATCH] Format 1) src/Exceptions/Handler.php (new_with_parentheses, fully_qualified_strict_types, unary_operator_spaces, not_operator_with_successor_space) 2) src/Container.php (new_with_parentheses) 3) src/Bootstrap/HandleExceptions.php (new_with_parentheses, fully_qualified_strict_types, unary_operator_spaces, not_operator_with_successor_space) 4) src/Support/helpers.php (fully_qualified_strict_types, nullable_type_declaration_for_default_null_value, unary_operator_spaces, not_operator_with_successor_space) 5) src/View/DynamicComponent.php (trailing_comma_in_multiline, unary_operator_spaces, not_operator_with_successor_space) 6) src/Providers/FilesystemServiceProvider.php (new_with_parentheses) 7) src/Providers/CollectionServiceProvider.php (new_with_parentheses) 8) src/Providers/CompatibilityServiceProvider.php (new_with_parentheses) 9) src/Providers/MarkdownServiceProvider.php (new_with_parentheses) 10) src/Providers/EventServiceProvider.php (new_with_parentheses) 11) src/Providers/ViewServiceProvider.php (new_with_parentheses) 12) src/Parsers/MarkdownParser.php (new_with_parentheses, nullable_type_declaration_for_default_null_value) 13) src/Parsers/CommonMarkParser.php (new_with_parentheses, trailing_comma_in_multiline) 14) src/Console/Command.php (type_declaration_spaces) 15) tests/EventsTest.php (new_with_parentheses) 16) tests/CollectionItemTest.php (array_indentation) 17) tests/Haiku.php (no_unused_imports) 18) tests/TestCase.php (new_with_parentheses, fully_qualified_strict_types, nullable_type_declaration_for_default_null_value, no_trailing_whitespace, braces_position, single_line_empty_body) 19) tests/JigsawMacroTest.php (new_with_parentheses) 20) tests/BladeComponentTest.php (array_indentation) 21) tests/FilePathTest.php (no_unused_imports) 22) tests/CommonMarkTest.php (new_with_parentheses) 23) tests/SnapshotsTest.php (new_with_parentheses, unary_operator_spaces, not_operator_with_successor_space) 24) stubs/site/bootstrap.php (fully_qualified_strict_types) --- src/Bootstrap/HandleExceptions.php | 6 ++--- src/Console/Command.php | 2 +- src/Container.php | 2 +- src/Exceptions/Handler.php | 4 ++-- src/Parsers/CommonMarkParser.php | 12 +++++----- src/Parsers/MarkdownParser.php | 4 ++-- src/Providers/CollectionServiceProvider.php | 4 ++-- .../CompatibilityServiceProvider.php | 2 +- src/Providers/EventServiceProvider.php | 2 +- src/Providers/FilesystemServiceProvider.php | 2 +- src/Providers/MarkdownServiceProvider.php | 2 +- src/Providers/ViewServiceProvider.php | 4 ++-- src/Support/helpers.php | 6 ++--- src/View/DynamicComponent.php | 2 +- stubs/site/bootstrap.php | 4 ++-- tests/BladeComponentTest.php | 10 ++++---- tests/CollectionItemTest.php | 24 +++++++++---------- tests/CommonMarkTest.php | 4 ++-- tests/EventsTest.php | 2 +- tests/FilePathTest.php | 1 - tests/Haiku.php | 1 - tests/JigsawMacroTest.php | 2 +- tests/SnapshotsTest.php | 2 +- tests/TestCase.php | 10 ++++---- 24 files changed, 56 insertions(+), 58 deletions(-) diff --git a/src/Bootstrap/HandleExceptions.php b/src/Bootstrap/HandleExceptions.php index 96285fe8..aafcd5b6 100644 --- a/src/Bootstrap/HandleExceptions.php +++ b/src/Bootstrap/HandleExceptions.php @@ -108,7 +108,7 @@ private function handleError($level, $message, $file = '', $line = 0, $context = /** * Handle a deprecation. * - * @throws \TightenCo\Jigsaw\Exceptions\DeprecationException + * @throws DeprecationException */ private function handleDeprecation(Throwable $e): void { @@ -123,7 +123,7 @@ private function handleDeprecation(Throwable $e): void // } - static::$app->make(ExceptionHandler::class)->renderForConsole(new ConsoleOutput, $e); + static::$app->make(ExceptionHandler::class)->renderForConsole(new ConsoleOutput(), $e); } /** @@ -143,7 +143,7 @@ private function handleException(Throwable $e): void // } - static::$app->make(ExceptionHandler::class)->renderForConsole(new ConsoleOutput, $e); + static::$app->make(ExceptionHandler::class)->renderForConsole(new ConsoleOutput(), $e); } /** diff --git a/src/Console/Command.php b/src/Console/Command.php index 12236e24..985be593 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -8,7 +8,7 @@ abstract class Command extends SymfonyCommand { - protected InputInterface $input; + protected InputInterface $input; protected OutputInterface $output; protected $console; diff --git a/src/Container.php b/src/Container.php index 77b46d87..5c59265c 100644 --- a/src/Container.php +++ b/src/Container.php @@ -84,7 +84,7 @@ private function loadEnvironmentVariables(): void try { Dotenv::create(Env::getRepository(), $this->path)->safeLoad(); } catch (InvalidFileException $e) { - $output = (new ConsoleOutput)->getErrorOutput(); + $output = (new ConsoleOutput())->getErrorOutput(); $output->writeln('The environment file is invalid!'); $output->writeln($e->getMessage()); diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 94ebb5a0..7ee06af2 100644 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -58,7 +58,7 @@ public function renderForConsole($output, Throwable $e): void } if ($e instanceof SymfonyConsoleExceptionInterface) { - (new ConsoleApplication)->renderThrowable($e, $output); + (new ConsoleApplication())->renderThrowable($e, $output); return; } @@ -79,7 +79,7 @@ public function renderForConsole($output, Throwable $e): void $e = $this->mapException($e); - /** @var \NunoMaduro\Collision\Provider $provider */ + /** @var Provider $provider */ $provider = app(Provider::class); $handler = $provider->register()->getHandler()->setOutput($output); diff --git a/src/Parsers/CommonMarkParser.php b/src/Parsers/CommonMarkParser.php index 48095a4c..116a5945 100644 --- a/src/Parsers/CommonMarkParser.php +++ b/src/Parsers/CommonMarkParser.php @@ -19,17 +19,17 @@ public function __construct() { $environment = new Environment(Arr::get(app('config'), 'commonmark.config', [])); - $environment->addExtension(new CommonMarkCoreExtension); + $environment->addExtension(new CommonMarkCoreExtension()); collect(Arr::get(app('config'), 'commonmark.extensions', [ - new AttributesExtension, - new SmartPunctExtension, - new StrikethroughExtension, - new TableExtension, + new AttributesExtension(), + new SmartPunctExtension(), + new StrikethroughExtension(), + new TableExtension(), ]))->map(fn ($extension) => $environment->addExtension($extension)); collect( - Arr::get(app('config'), 'commonmark.renderers') + Arr::get(app('config'), 'commonmark.renderers'), )->map(fn ($renderer, $nodeClass) => $environment->addRenderer($nodeClass, $renderer)); $this->converter = new MarkdownConverter($environment); diff --git a/src/Parsers/MarkdownParser.php b/src/Parsers/MarkdownParser.php index 1fef8fd0..3c9d012e 100644 --- a/src/Parsers/MarkdownParser.php +++ b/src/Parsers/MarkdownParser.php @@ -8,9 +8,9 @@ class MarkdownParser implements FrontYAMLMarkdownParserInterface { public $parser; - public function __construct(MarkdownParserContract $parser = null) + public function __construct(?MarkdownParserContract $parser = null) { - $this->parser = $parser ?? new JigsawMarkdownParser; + $this->parser = $parser ?? new JigsawMarkdownParser(); } public function __get($property) diff --git a/src/Providers/CollectionServiceProvider.php b/src/Providers/CollectionServiceProvider.php index 9be29d79..b2cb6df8 100644 --- a/src/Providers/CollectionServiceProvider.php +++ b/src/Providers/CollectionServiceProvider.php @@ -28,7 +28,7 @@ class CollectionServiceProvider extends ServiceProvider { public function register(): void { - $this->app->bind('outputPathResolver', fn () => new BasicOutputPathResolver); + $this->app->bind('outputPathResolver', fn () => new BasicOutputPathResolver()); $this->registerHandlers(); $this->registerPathResolver(); @@ -100,7 +100,7 @@ private function registerSiteBuilder(): void $this->app->bind(SiteBuilder::class, function (Container $app) { return new SiteBuilder($app['files'], $app->cachePath(), $app['outputPathResolver'], $app['consoleOutput'], [ $app[CollectionItemHandler::class], - new IgnoredHandler, + new IgnoredHandler(), $app[PaginatedPageHandler::class], $app[MarkdownHandler::class], $app[BladeHandler::class], diff --git a/src/Providers/CompatibilityServiceProvider.php b/src/Providers/CompatibilityServiceProvider.php index 7983500a..7fa8687c 100644 --- a/src/Providers/CompatibilityServiceProvider.php +++ b/src/Providers/CompatibilityServiceProvider.php @@ -11,6 +11,6 @@ public function register(): void { $this->app->instance('cwd', $this->app->path()); - $this->app->singleton('consoleOutput', fn () => new ConsoleOutput); + $this->app->singleton('consoleOutput', fn () => new ConsoleOutput()); } } diff --git a/src/Providers/EventServiceProvider.php b/src/Providers/EventServiceProvider.php index b2fbc252..1f59c6a5 100644 --- a/src/Providers/EventServiceProvider.php +++ b/src/Providers/EventServiceProvider.php @@ -13,6 +13,6 @@ public function register(): void { $this->app->singleton('dispatcher', fn (Container $app) => new Dispatcher($app)); - $this->app->singleton('events', fn (Container $app) => new EventBus); + $this->app->singleton('events', fn (Container $app) => new EventBus()); } } diff --git a/src/Providers/FilesystemServiceProvider.php b/src/Providers/FilesystemServiceProvider.php index 2048d1bc..000eeb91 100644 --- a/src/Providers/FilesystemServiceProvider.php +++ b/src/Providers/FilesystemServiceProvider.php @@ -9,6 +9,6 @@ class FilesystemServiceProvider extends ServiceProvider { public function register(): void { - $this->app->singleton('files', fn () => new Filesystem); + $this->app->singleton('files', fn () => new Filesystem()); } } diff --git a/src/Providers/MarkdownServiceProvider.php b/src/Providers/MarkdownServiceProvider.php index c3edd433..989bc47b 100644 --- a/src/Providers/MarkdownServiceProvider.php +++ b/src/Providers/MarkdownServiceProvider.php @@ -21,7 +21,7 @@ public function register(): void $this->app->bind(YAMLParser::class, SymfonyYAMLParser::class); $this->app->bind(MarkdownParserContract::class, function (Container $app) { - return $app['config']->get('commonmark') ? new CommonMarkParser : new JigsawMarkdownParser; + return $app['config']->get('commonmark') ? new CommonMarkParser() : new JigsawMarkdownParser(); }); $this->app->singleton('markdownParser', fn (Container $app) => new MarkdownParser($app[MarkdownParserContract::class])); diff --git a/src/Providers/ViewServiceProvider.php b/src/Providers/ViewServiceProvider.php index 6d834e94..876f7f65 100644 --- a/src/Providers/ViewServiceProvider.php +++ b/src/Providers/ViewServiceProvider.php @@ -29,7 +29,7 @@ public function register(): void $this->registerEngineResolvers(); (new BladeDirectivesFile($this->app->path('blade.php'), $this->app['blade.compiler']))->register(); - $this->app->bind(ViewRenderer::class, fn () => new ViewRenderer); + $this->app->bind(ViewRenderer::class, fn () => new ViewRenderer()); $this->app->bind(TemporaryFilesystem::class, fn (Container $app) => new TemporaryFilesystem($app->cachePath())); // TODO @@ -74,7 +74,7 @@ private function registerBladeCompiler(): void private function registerEngineResolvers(): void { $this->app->singleton('view.engine.resolver', function (Container $app) { - $resolver = new EngineResolver; + $resolver = new EngineResolver(); $compilerEngine = new CompilerEngine($app['blade.compiler'], $app['files']); // Same as Laravel diff --git a/src/Support/helpers.php b/src/Support/helpers.php index c655bb66..a9f498e6 100644 --- a/src/Support/helpers.php +++ b/src/Support/helpers.php @@ -7,13 +7,13 @@ use Symfony\Component\VarDumper\VarDumper; if (! function_exists('app')) { - function app(string $abstract = null, array $parameters = []): mixed + function app(?string $abstract = null, array $parameters = []): mixed { if (is_null($abstract)) { - return \TightenCo\Jigsaw\Container::getInstance(); + return TightenCo\Jigsaw\Container::getInstance(); } - return \TightenCo\Jigsaw\Container::getInstance()->make($abstract, $parameters); + return TightenCo\Jigsaw\Container::getInstance()->make($abstract, $parameters); } } diff --git a/src/View/DynamicComponent.php b/src/View/DynamicComponent.php index 6a84338a..bea19e41 100644 --- a/src/View/DynamicComponent.php +++ b/src/View/DynamicComponent.php @@ -13,7 +13,7 @@ protected function compiler() static::$compiler = new ComponentTagCompiler( Container::getInstance()->make('blade.compiler')->getClassComponentAliases(), Container::getInstance()->make('blade.compiler')->getClassComponentNamespaces(), - Container::getInstance()->make('blade.compiler') + Container::getInstance()->make('blade.compiler'), ); } diff --git a/stubs/site/bootstrap.php b/stubs/site/bootstrap.php index f603d4e2..8e3a0213 100644 --- a/stubs/site/bootstrap.php +++ b/stubs/site/bootstrap.php @@ -2,8 +2,8 @@ use TightenCo\Jigsaw\Jigsaw; -/** @var \Illuminate\Container\Container $container */ -/** @var \TightenCo\Jigsaw\Events\EventBus $events */ +/** @var Illuminate\Container\Container $container */ +/** @var TightenCo\Jigsaw\Events\EventBus $events */ /* * You can run custom code at different stages of the build process by diff --git a/tests/BladeComponentTest.php b/tests/BladeComponentTest.php index 925595f1..b6c155bc 100644 --- a/tests/BladeComponentTest.php +++ b/tests/BladeComponentTest.php @@ -20,11 +20,11 @@ public function can_include_blade_component_with_at_syntax() ]), '_components' => [ 'alert.blade.php' => implode("\n", [ - '
', - '

This is the component

', - '

Named title slot: {{ $title }}

', - '{{ $slot }}', - '
', + '
', + '

This is the component

', + '

Named title slot: {{ $title }}

', + '{{ $slot }}', + '
', ]), ], ]); diff --git a/tests/CollectionItemTest.php b/tests/CollectionItemTest.php index 82e8495e..a17a5bd9 100644 --- a/tests/CollectionItemTest.php +++ b/tests/CollectionItemTest.php @@ -36,13 +36,13 @@ public function collection_item_contents_are_returned_when_item_is_referenced_as public function collection_item_can_be_filtered() { $config = collect(['collections' => [ - 'collection' => [ - 'path' => 'collection/{filename}', - 'filter' => function ($item) { - return $item->published; - }, - ], + 'collection' => [ + 'path' => 'collection/{filename}', + 'filter' => function ($item) { + return $item->published; + }, ], + ], ]); $builtHeader = implode("\n", [ '---', @@ -81,13 +81,13 @@ public function collection_item_can_be_filtered() public function collection_item_can_be_mapped() { $config = collect(['collections' => [ - 'collection' => [ - 'path' => 'collection/{filename}', - 'map' => function ($item) { - return MappedItem::fromItem($item); - }, - ], + 'collection' => [ + 'path' => 'collection/{filename}', + 'map' => function ($item) { + return MappedItem::fromItem($item); + }, ], + ], ]); $itemHeader = implode("\n", [ '---', diff --git a/tests/CommonMarkTest.php b/tests/CommonMarkTest.php index 90e9bdfe..fe2d63f5 100644 --- a/tests/CommonMarkTest.php +++ b/tests/CommonMarkTest.php @@ -58,7 +58,7 @@ public function replace_commonmark_extensions() $this->buildSite($files, [ 'commonmark' => [ 'extensions' => [ - new DescriptionListExtension, + new DescriptionListExtension(), ], ], ]); @@ -75,7 +75,7 @@ public function override_parser_with_custom_class() $files = $this->withContent('### Heading {.class}'); $this->app->bind(MarkdownParserContract::class, function () { - return new class implements MarkdownParserContract { + return new class() implements MarkdownParserContract { public function parse(string $text) { return <<app['events']->beforeBuild(new class { + $this->app['events']->beforeBuild(new class() { private $object; public function __construct() diff --git a/tests/FilePathTest.php b/tests/FilePathTest.php index db36bea3..1b867d73 100644 --- a/tests/FilePathTest.php +++ b/tests/FilePathTest.php @@ -2,7 +2,6 @@ namespace Tests; -use PHPUnit\Framework\Attributes\Test; use TightenCo\Jigsaw\IterableObject; use TightenCo\Jigsaw\PageVariable; use TightenCo\Jigsaw\PathResolvers\CollectionPathResolver; diff --git a/tests/Haiku.php b/tests/Haiku.php index 50a6e778..54f97d45 100644 --- a/tests/Haiku.php +++ b/tests/Haiku.php @@ -4,7 +4,6 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; -use PHPUnit\Framework\Attributes\Test; trait Haiku { diff --git a/tests/JigsawMacroTest.php b/tests/JigsawMacroTest.php index b4198077..dc49fe8f 100644 --- a/tests/JigsawMacroTest.php +++ b/tests/JigsawMacroTest.php @@ -20,7 +20,7 @@ public function jigsaw_macro_function_calls_successfully() #[Test] public function jigsaw_mixin_function_calls_successfully() { - Jigsaw::mixin(new JigsawMixinTestClass); + Jigsaw::mixin(new JigsawMixinTestClass()); $this->assertSame('Reed', Jigsaw::getNameMixin()); } diff --git a/tests/SnapshotsTest.php b/tests/SnapshotsTest.php index e485b5d6..b95d743a 100644 --- a/tests/SnapshotsTest.php +++ b/tests/SnapshotsTest.php @@ -25,7 +25,7 @@ protected function setUp(): void { parent::setUp(); - $this->filesystem = new Filesystem; + $this->filesystem = new Filesystem(); } public static function snapshots(): array diff --git a/tests/TestCase.php b/tests/TestCase.php index 8f8258f3..c43a5312 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -26,11 +26,11 @@ class TestCase extends PHPUnit protected Filesystem $filesystem; protected string $tmp; - public function __construct($name = null, array $data = [], $dataName = '') + public function __construct($name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); - $this->filesystem = new Filesystem; + $this->filesystem = new Filesystem(); } protected function setUp(): void @@ -39,7 +39,7 @@ protected function setUp(): void $this->createTmp(); - $this->app = new Container; + $this->app = new Container(); /* @internal The '__testing' binding is for Jigsaw development only and may be removed. */ $this->app->instance('__testing', true); $this->app->singleton( @@ -47,7 +47,7 @@ protected function setUp(): void \TightenCo\Jigsaw\Exceptions\Handler::class, ); $this->app->bootstrapWith([ - \TightenCo\Jigsaw\Bootstrap\HandleExceptions::class, + HandleExceptions::class, ]); $this->app->buildPath = [ @@ -209,7 +209,7 @@ protected function fixDirectorySlashes(string $path): string return str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path); } - protected function assertOutputFile(string $path, string $contents, string $message = null): void + protected function assertOutputFile(string $path, string $contents, ?string $message = null): void { static::assertStringEqualsFile( $this->tmpPath($path),