From dce6d72c0f9eb1000cc0bc73e22cc2958cb08271 Mon Sep 17 00:00:00 2001 From: Brandon <brandon@tendency.me> Date: Mon, 12 Aug 2024 08:33:47 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Run=20Pint=20(#392)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roots/Acorn/Application.php | 6 ++--- .../Acorn/Application/Concerns/Bootable.php | 6 ++--- src/Roots/Acorn/Assets/Asset/Asset.php | 2 +- .../Acorn/Assets/AssetsServiceProvider.php | 2 +- src/Roots/Acorn/Assets/Manager.php | 2 +- src/Roots/Acorn/Bootstrap/RegisterConsole.php | 2 +- src/Roots/Acorn/ComposerScripts.php | 2 +- .../Concerns/GracefullyCallsCommands.php | 2 +- .../Whoops/WhoopsExceptionRenderer.php | 2 +- .../Acorn/Exceptions/Whoops/WhoopsHandler.php | 2 +- .../Filesystem/FilesystemServiceProvider.php | 2 +- .../Acorn/Providers/AcornServiceProvider.php | 2 +- src/Roots/Acorn/ServiceProvider.php | 2 +- src/Roots/Acorn/View/ViewServiceProvider.php | 2 +- tests/Application/ApplicationTest.php | 20 ++++++++--------- tests/Assets/AssetsHelpersTest.php | 8 +++---- tests/Assets/AssetsServiceProviderTest.php | 6 ++--- tests/Assets/BladeDirectiveTest.php | 2 +- tests/Assets/LaravelMixMiddlewareTest.php | 4 ++-- tests/Assets/ManagerTest.php | 4 ++-- .../HandleExceptionsRegistrationTest.php | 2 +- tests/Bootstrap/HandleExceptionsTest.php | 6 ++--- tests/Filesystem/FilesystemTest.php | 22 +++++++++---------- tests/Helpers.php | 2 +- 24 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index 9f61dc56..ce1c7778 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -231,7 +231,7 @@ protected function registerBaseBindings() protected function registerPackageManifest() { $this->singleton(FoundationPackageManifest::class, function () { - $files = new Filesystem(); + $files = new Filesystem; $composerPaths = collect(get_option('active_plugins')) ->map(fn ($plugin) => WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.dirname($plugin)) @@ -307,7 +307,7 @@ public function registerConfiguredProviders() $providers->splice(1, 0, [$this->make(PackageManifest::class)->providers()]); - (new ProviderRepository($this, new Filesystem(), $this->getCachedServicesPath())) + (new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath())) ->load($providers->collapse()->toArray()); } @@ -402,7 +402,7 @@ public function getNamespace() */ protected function getAppComposer(): string { - return (new Filesystem())->closest($this->path(), 'composer.json') ?? $this->basePath('composer.json'); + return (new Filesystem)->closest($this->path(), 'composer.json') ?? $this->basePath('composer.json'); } /** diff --git a/src/Roots/Acorn/Application/Concerns/Bootable.php b/src/Roots/Acorn/Application/Concerns/Bootable.php index f8b21660..d3e90512 100644 --- a/src/Roots/Acorn/Application/Concerns/Bootable.php +++ b/src/Roots/Acorn/Application/Concerns/Bootable.php @@ -50,8 +50,8 @@ protected function bootConsole(): void $kernel = $this->make(ConsoleKernelContract::class); $status = $kernel->handle( - $input = new \Symfony\Component\Console\Input\ArgvInput(), - new \Symfony\Component\Console\Output\ConsoleOutput() + $input = new \Symfony\Component\Console\Input\ArgvInput, + new \Symfony\Component\Console\Output\ConsoleOutput ); $kernel->terminate($input, $status); @@ -90,7 +90,7 @@ protected function bootWpCli(): void $status = $kernel->handle( $input = new \Symfony\Component\Console\Input\StringInput($command), - new \Symfony\Component\Console\Output\ConsoleOutput() + new \Symfony\Component\Console\Output\ConsoleOutput ); $kernel->terminate($input, $status); diff --git a/src/Roots/Acorn/Assets/Asset/Asset.php b/src/Roots/Acorn/Assets/Asset/Asset.php index 5c5d73d8..24173d9a 100644 --- a/src/Roots/Acorn/Assets/Asset/Asset.php +++ b/src/Roots/Acorn/Assets/Asset/Asset.php @@ -92,7 +92,7 @@ public function relativePath(string $basePath): string { $basePath = rtrim($basePath, '/\\').'/'; - return (new Filesystem())->getRelativePath($basePath, $this->path()); + return (new Filesystem)->getRelativePath($basePath, $this->path()); } /** diff --git a/src/Roots/Acorn/Assets/AssetsServiceProvider.php b/src/Roots/Acorn/Assets/AssetsServiceProvider.php index 749df77b..960ef97e 100644 --- a/src/Roots/Acorn/Assets/AssetsServiceProvider.php +++ b/src/Roots/Acorn/Assets/AssetsServiceProvider.php @@ -37,7 +37,7 @@ public function boot() if ($this->app->bound('view')) { $this->app->make('view') ->getEngineResolver()->resolve('blade')->getCompiler() - ->directive('asset', new BladeDirective()); + ->directive('asset', new BladeDirective); } } diff --git a/src/Roots/Acorn/Assets/Manager.php b/src/Roots/Acorn/Assets/Manager.php index a1eabcd9..d26327ab 100644 --- a/src/Roots/Acorn/Assets/Manager.php +++ b/src/Roots/Acorn/Assets/Manager.php @@ -104,7 +104,7 @@ protected function pipeline(array $config): array { return array_reduce($this->middleware, function (array $config, $middleware): array { if (is_string($middleware) && class_exists($middleware)) { - $middleware = new $middleware(); + $middleware = new $middleware; } return is_callable($middleware) ? $middleware($config) : $middleware->handle($config); diff --git a/src/Roots/Acorn/Bootstrap/RegisterConsole.php b/src/Roots/Acorn/Bootstrap/RegisterConsole.php index ac20763e..35c2e9b3 100644 --- a/src/Roots/Acorn/Bootstrap/RegisterConsole.php +++ b/src/Roots/Acorn/Bootstrap/RegisterConsole.php @@ -44,7 +44,7 @@ public function bootstrap(Application $app) $command = str_replace('\\', '\\\\', $command); - $status = $kernel->handle($input = new StringInput($command), new ConsoleOutput()); + $status = $kernel->handle($input = new StringInput($command), new ConsoleOutput); $kernel->terminate($input, $status); diff --git a/src/Roots/Acorn/ComposerScripts.php b/src/Roots/Acorn/ComposerScripts.php index 479706fd..92fd419d 100644 --- a/src/Roots/Acorn/ComposerScripts.php +++ b/src/Roots/Acorn/ComposerScripts.php @@ -15,7 +15,7 @@ class ComposerScripts extends FoundationComposerScripts */ protected static function clearCompiled() { - $console = new Console(new Filesystem(), getcwd()); + $console = new Console(new Filesystem, getcwd()); $console->configClear(); $console->clearCompiled(); diff --git a/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php b/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php index 2ce786e9..2e692800 100644 --- a/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php +++ b/src/Roots/Acorn/Console/Concerns/GracefullyCallsCommands.php @@ -59,7 +59,7 @@ public function gracefulCall($command, array $arguments = []) public function gracefulCallSilent($command, array $arguments = []) { if ($this->commandExists($command)) { - return $this->runCommand($command, $arguments, new NullOutput()); + return $this->runCommand($command, $arguments, new NullOutput); } return 0; diff --git a/src/Roots/Acorn/Exceptions/Whoops/WhoopsExceptionRenderer.php b/src/Roots/Acorn/Exceptions/Whoops/WhoopsExceptionRenderer.php index 5f230c73..e6b8c2e3 100644 --- a/src/Roots/Acorn/Exceptions/Whoops/WhoopsExceptionRenderer.php +++ b/src/Roots/Acorn/Exceptions/Whoops/WhoopsExceptionRenderer.php @@ -13,6 +13,6 @@ class WhoopsExceptionRenderer extends FoundationWhoopsExceptionRenderer */ protected function whoopsHandler() { - return (new WhoopsHandler())->forDebug(); + return (new WhoopsHandler)->forDebug(); } } diff --git a/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php b/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php index 4d789d9e..72364e52 100644 --- a/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php +++ b/src/Roots/Acorn/Exceptions/Whoops/WhoopsHandler.php @@ -36,7 +36,7 @@ class WhoopsHandler extends FoundationWhoopsHandler */ public function forDebug() { - return tap(new PrettyPageHandler(), function ($handler) { + return tap(new PrettyPageHandler, function ($handler) { $handler->handleUnconditionally(true); $this->registerApplicationPaths($handler) diff --git a/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php b/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php index e5674d9c..a334e2e7 100644 --- a/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php +++ b/src/Roots/Acorn/Filesystem/FilesystemServiceProvider.php @@ -13,7 +13,7 @@ class FilesystemServiceProvider extends FilesystemServiceProviderBase */ protected function registerNativeFilesystem() { - $this->app->singleton('files', fn () => new Filesystem()); + $this->app->singleton('files', fn () => new Filesystem); $this->app->alias('files', \Roots\Acorn\Filesystem\Filesystem::class); } diff --git a/src/Roots/Acorn/Providers/AcornServiceProvider.php b/src/Roots/Acorn/Providers/AcornServiceProvider.php index 7b45f4a5..36d6034d 100644 --- a/src/Roots/Acorn/Providers/AcornServiceProvider.php +++ b/src/Roots/Acorn/Providers/AcornServiceProvider.php @@ -120,7 +120,7 @@ protected function registerPostInitEvent() return; } - $files = new Filesystem(); + $files = new Filesystem; $files->deleteDirectory(WP_CONTENT_DIR.'/cache/acorn'); }); diff --git a/src/Roots/Acorn/ServiceProvider.php b/src/Roots/Acorn/ServiceProvider.php index 354ea564..99180cd5 100644 --- a/src/Roots/Acorn/ServiceProvider.php +++ b/src/Roots/Acorn/ServiceProvider.php @@ -13,6 +13,6 @@ final class ServiceProvider extends ServiceProviderBase */ public static function defaultProviders() { - return new DefaultProviders(); + return new DefaultProviders; } } diff --git a/src/Roots/Acorn/View/ViewServiceProvider.php b/src/Roots/Acorn/View/ViewServiceProvider.php index 880ed122..fd5120b4 100644 --- a/src/Roots/Acorn/View/ViewServiceProvider.php +++ b/src/Roots/Acorn/View/ViewServiceProvider.php @@ -184,7 +184,7 @@ public function attachComposers() $namespace = $this->app->getNamespace(); // TODO: This should be cacheable, perhaps via `wp acorn` command - foreach ((new Finder())->in($path)->files() as $composer) { + foreach ((new Finder)->in($path)->files() as $composer) { $composer = $namespace.str_replace( ['/', '.php'], ['\\', ''], diff --git a/tests/Application/ApplicationTest.php b/tests/Application/ApplicationTest.php index 83cb1816..a0d8565b 100644 --- a/tests/Application/ApplicationTest.php +++ b/tests/Application/ApplicationTest.php @@ -21,7 +21,7 @@ }); it('rejects invalid custom path types', function () { - $app = new Application(); + $app = new Application; $app->usePaths([ 'app' => $this->fixture('use_paths/app'), @@ -83,7 +83,7 @@ }); it('goes down for maintenance when acorn maintenance file exists', function () { - $app = new Application(); + $app = new Application; expect($app->isDownForMaintenance())->toBeFalse(); @@ -93,7 +93,7 @@ }); it('goes down for maintenance when wordpress maintenance file exists', function () { - $app = new Application(); + $app = new Application; expect($app->isDownForMaintenance())->toBeFalse(); @@ -129,16 +129,16 @@ }); it('makes a thing', function () { - $app = new Application(); + $app = new Application; - $app->bind('config', fn () => new ConfigRepository()); + $app->bind('config', fn () => new ConfigRepository); expect($app->make('config'))->toBeInstanceOf(ConfigRepository::class); }); it('boots a provider', function () { $provider = mock(BootableServiceProvider::class)->makePartial(); - $app = new Application(); + $app = new Application; $provider->shouldReceive('register', 'boot')->once(); @@ -150,7 +150,7 @@ it('gracefully skips a provider that fails to boot', function () { $handler = mock(\Illuminate\Contracts\Debug\ExceptionHandler::class); $manifest = mock(\Roots\Acorn\PackageManifest::class); - $app = new Application(); + $app = new Application; $app['env'] = 'not-local-dev'; @@ -163,7 +163,7 @@ { public function boot() { - new \kjo(); + new \kjo; } }; @@ -184,7 +184,7 @@ public function boot() it('gracefully skips a provider that does not exist', function () { $handler = mock(\Illuminate\Contracts\Debug\ExceptionHandler::class); $manifest = mock(\Roots\Acorn\PackageManifest::class); - $app = new Application(); + $app = new Application; $app['env'] = 'not-local-dev'; @@ -206,7 +206,7 @@ public function boot() }); it('uses custom aliases', function () { - $app = new Application(); + $app = new Application; expect($app->getAlias(\Roots\Acorn\Application::class))->toBe('app'); expect($app->getAlias(\Roots\Acorn\PackageManifest::class))->toBe(\Illuminate\Foundation\PackageManifest::class); diff --git a/tests/Assets/AssetsHelpersTest.php b/tests/Assets/AssetsHelpersTest.php index bf85bba7..a86d4829 100644 --- a/tests/Assets/AssetsHelpersTest.php +++ b/tests/Assets/AssetsHelpersTest.php @@ -9,7 +9,7 @@ uses(TestCase::class); it('asset() can access the default manifest', function () { - $app = new \Roots\Acorn\Application(); + $app = new \Roots\Acorn\Application; $app->singleton('config', fn () => new \Illuminate\Config\Repository([ 'assets' => [ 'default' => 'app', @@ -35,7 +35,7 @@ }); it('asset() can access a specified manifest', function () { - $app = new \Roots\Acorn\Application(); + $app = new \Roots\Acorn\Application; $app->singleton('config', fn () => new \Illuminate\Config\Repository([ 'assets' => [ 'default' => 'app', @@ -61,7 +61,7 @@ }); it('bundle() can access the default manifest', function () { - $app = new \Roots\Acorn\Application(); + $app = new \Roots\Acorn\Application; $app->singleton('config', fn () => new \Illuminate\Config\Repository([ 'assets' => [ 'default' => 'app', @@ -87,7 +87,7 @@ }); it('bundle() can access a specified manifest', function () { - $app = new \Roots\Acorn\Application(); + $app = new \Roots\Acorn\Application; $app->singleton('config', fn () => new \Illuminate\Config\Repository([ 'assets' => [ 'default' => 'app', diff --git a/tests/Assets/AssetsServiceProviderTest.php b/tests/Assets/AssetsServiceProviderTest.php index 12292ca1..8bb104bf 100644 --- a/tests/Assets/AssetsServiceProviderTest.php +++ b/tests/Assets/AssetsServiceProviderTest.php @@ -9,15 +9,15 @@ uses(TestCase::class); it('registers an asset manager', function () { - $app = new \Roots\Acorn\Application(); - $app->singleton('config', fn () => new \Illuminate\Config\Repository()); + $app = new \Roots\Acorn\Application; + $app->singleton('config', fn () => new \Illuminate\Config\Repository); $app->register(\Roots\Acorn\Assets\AssetsServiceProvider::class); expect($app->make('assets'))->toBeInstanceOf(Manager::class); }); it('registers a default manifest', function () { - $app = new \Roots\Acorn\Application(); + $app = new \Roots\Acorn\Application; $app->singleton('config', fn () => new \Illuminate\Config\Repository([ 'assets' => [ 'default' => 'app', diff --git a/tests/Assets/BladeDirectiveTest.php b/tests/Assets/BladeDirectiveTest.php index 2309af50..2f4c7fa8 100644 --- a/tests/Assets/BladeDirectiveTest.php +++ b/tests/Assets/BladeDirectiveTest.php @@ -8,6 +8,6 @@ uses(TestCase::class); it('loads an asset', function () { - $directive = new BladeDirective(); + $directive = new BladeDirective; assertMatchesSnapshot($directive("'kjo'")); }); diff --git a/tests/Assets/LaravelMixMiddlewareTest.php b/tests/Assets/LaravelMixMiddlewareTest.php index 0baaf9f4..64e38462 100644 --- a/tests/Assets/LaravelMixMiddlewareTest.php +++ b/tests/Assets/LaravelMixMiddlewareTest.php @@ -8,7 +8,7 @@ uses(TestCase::class); it('skips url modification if hot file is absent', function () { - $middleware = new LaravelMixMiddleware(); + $middleware = new LaravelMixMiddleware; $config = $middleware->handle([ 'path' => $this->fixture('mix_no_bundle/public'), @@ -19,7 +19,7 @@ }); it('modifies url when hot file is present', function () { - $middleware = new LaravelMixMiddleware(); + $middleware = new LaravelMixMiddleware; $config = $middleware->handle([ 'path' => $this->fixture('mix_no_bundle_hmr/public'), diff --git a/tests/Assets/ManagerTest.php b/tests/Assets/ManagerTest.php index 60fbd707..93451029 100644 --- a/tests/Assets/ManagerTest.php +++ b/tests/Assets/ManagerTest.php @@ -11,7 +11,7 @@ uses(TestCase::class); it('creates a manifest', function () { - $assets = new Manager(); + $assets = new Manager; $manifest = $assets->manifest('theme', [ 'path' => $this->fixture('bud_single_runtime'), @@ -23,7 +23,7 @@ }); it('registers a manifest', function () { - $assets = new Manager(); + $assets = new Manager; $assets->register('theme', new Manifest( $this->fixture('bud_single_runtime'), diff --git a/tests/Bootstrap/HandleExceptionsRegistrationTest.php b/tests/Bootstrap/HandleExceptionsRegistrationTest.php index f5165c7e..cd459b35 100644 --- a/tests/Bootstrap/HandleExceptionsRegistrationTest.php +++ b/tests/Bootstrap/HandleExceptionsRegistrationTest.php @@ -23,7 +23,7 @@ ->shouldreceive('runningInConsole') ->andReturn(false); $this->application->config = new Config(['app' => ['debug' => true]]); - $this->handleExceptions = new HandleExceptions(); + $this->handleExceptions = new HandleExceptions; }); it('registers error handler', function () { diff --git a/tests/Bootstrap/HandleExceptionsTest.php b/tests/Bootstrap/HandleExceptionsTest.php index 6d42920c..568bb1a7 100644 --- a/tests/Bootstrap/HandleExceptionsTest.php +++ b/tests/Bootstrap/HandleExceptionsTest.php @@ -11,8 +11,8 @@ uses(TestCase::class); beforeEach(function () { - $this->container = Application::setInstance(new Application()); - $this->config = new Config(); + $this->container = Application::setInstance(new Application); + $this->config = new Config; $this->config->set('app.debug', true); @@ -20,7 +20,7 @@ $this->container->bootstrapWith([]); - $this->handleExceptions = new HandleExceptions(); + $this->handleExceptions = new HandleExceptions; with(new ReflectionClass($this->handleExceptions), function ($reflection) { $property = tap($reflection->getProperty('app'))->setAccessible(true); diff --git a/tests/Filesystem/FilesystemTest.php b/tests/Filesystem/FilesystemTest.php index 600d3cdf..dfd09f31 100644 --- a/tests/Filesystem/FilesystemTest.php +++ b/tests/Filesystem/FilesystemTest.php @@ -6,46 +6,46 @@ uses(TestCase::class); it('should support basic globs', function () { - expect((new Filesystem())->glob($this->fixture('closest/*.txt'))) + expect((new Filesystem)->glob($this->fixture('closest/*.txt'))) ->toEqual([$this->fixture('closest/kjo.txt')]); }); it('should normalize paths with multiple separators', function () { - expect((new Filesystem())->normalizePath('/a//b///c/d//e')) + expect((new Filesystem)->normalizePath('/a//b///c/d//e')) ->toEqual('/a/b/c/d/e'); }); it('should normalize paths separated by backslashes', function () { - expect((new Filesystem())->normalizePath('/a\\\\b\\\\c/d//e')) + expect((new Filesystem)->normalizePath('/a\\\\b\\\\c/d//e')) ->toEqual('/a/b/c/d/e'); }); it('should normalize paths to arbitrary separator', function () { - expect((new Filesystem())->normalizePath('/a\\\\b\\\\c/d//e', '|')) + expect((new Filesystem)->normalizePath('/a\\\\b\\\\c/d//e', '|')) ->toEqual('|a|b|c|d|e'); }); it('should find the closest path within the filesystem', function () { - expect((new Filesystem())->closest($this->fixture('closest/a/b'), 'kjo.txt')) + expect((new Filesystem)->closest($this->fixture('closest/a/b'), 'kjo.txt')) ->toEqual($this->fixture('closest/kjo.txt')); - expect((new Filesystem())->closest($this->fixture('closest/a/b'), 'bdubs.txt')) + expect((new Filesystem)->closest($this->fixture('closest/a/b'), 'bdubs.txt')) ->toEqual($this->fixture('closest/a/b/bdubs.txt')); - expect((new Filesystem())->closest($this->fixture('closest/a/b'), 'apray.txt')) + expect((new Filesystem)->closest($this->fixture('closest/a/b'), 'apray.txt')) ->toBeNull(); }); it('should determine the relative path between two absolute paths', function () { - expect((new Filesystem())->getRelativePath('/dir_a/dir_b/', '/dir_a/dir_b/dir_c/file_d')) + expect((new Filesystem)->getRelativePath('/dir_a/dir_b/', '/dir_a/dir_b/dir_c/file_d')) ->toEqual('dir_c/file_d'); - expect((new Filesystem())->getRelativePath('/dir_a/dir_b/dir_c/dir_d/', '/dir_a/dir_b/')) + expect((new Filesystem)->getRelativePath('/dir_a/dir_b/dir_c/dir_d/', '/dir_a/dir_b/')) ->toEqual('../../'); - expect((new Filesystem())->getRelativePath('/dir_a/dir_b/', '/dir_a/file_kjo')) + expect((new Filesystem)->getRelativePath('/dir_a/dir_b/', '/dir_a/file_kjo')) ->toEqual('../file_kjo'); - expect((new Filesystem())->getRelativePath('/dir_a/dir_b/', '/dir_a/dir_b/')) + expect((new Filesystem)->getRelativePath('/dir_a/dir_b/', '/dir_a/dir_b/')) ->toEqual(''); }); diff --git a/tests/Helpers.php b/tests/Helpers.php index c1c344e1..e1bf8d2d 100644 --- a/tests/Helpers.php +++ b/tests/Helpers.php @@ -26,7 +26,7 @@ function temp(?string $path = null) static $temp; if (! $temp) { - $temp = (new TemporaryDirectory())->create(); + $temp = (new TemporaryDirectory)->create(); register_shutdown_function(fn () => $temp->delete()); }