Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
montchr committed Nov 20, 2024
1 parent 942548e commit df757e4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ protected function skipProvider($provider, Throwable $e): ServiceProvider

if (! $e instanceof SkipProviderException) {
$error = $e::class;
// phpcs:disable SlevomatCodingStandard.Files.LineLength.LineTooLong
$message = [
BindingResolutionException::class => "Skipping provider [{$providerName}] because it requires a dependency that cannot be found.",
][$error] ?? "Skipping provider [{$providerName}] because it encountered an error [{$error}]: {$e->getMessage()}";
// phpcs:enable SlevomatCodingStandard.Files.LineLength.LineTooLong

$e = new SkipProviderException($message, 0, $e);
}
Expand Down
12 changes: 10 additions & 2 deletions src/Package/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ protected function copyServiceProviderInApp(): self

$namespace = Str::replaceLast('\\', '', $this->laravel->getNamespace());

if ((intval(app()->version()) < 11) || ! file_exists(base_path('bootstrap/providers.php'))) {
if (
(intval(app()->version()) < 11)
|| ! file_exists(base_path('bootstrap/providers.php'))
) {
$appConfig = file_get_contents(config_path('app.php'));
} else {
$appConfig = file_get_contents(base_path('bootstrap/providers.php'));
Expand All @@ -181,15 +184,20 @@ protected function copyServiceProviderInApp(): self
return $this;
}

if ((intval(app()->version()) < 11) || ! file_exists(base_path('bootstrap/providers.php'))) {
if (
(intval(app()->version()) < 11)
|| ! file_exists(base_path('bootstrap/providers.php'))
) {
file_put_contents(config_path('app.php'), str_replace(
"{$namespace}\\Providers\\BroadcastServiceProvider::class,",
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
"{$namespace}\\Providers\\BroadcastServiceProvider::class," . PHP_EOL . " {$namespace}{$class},",
$appConfig,
));
} else {
file_put_contents(base_path('bootstrap/providers.php'), str_replace(
"{$namespace}\\Providers\\AppServiceProvider::class,",
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
"{$namespace}\\Providers\\AppServiceProvider::class," . PHP_EOL . " {$namespace}{$class},",
$appConfig,
));
Expand Down
1 change: 1 addition & 0 deletions src/Package/Exceptions/InvalidPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class InvalidPackage extends Exception
{
public static function nameIsRequired(): self
{
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
return new static('This package does not have a name. You can set one with `$package->name("yourName")`');
}
}
10 changes: 8 additions & 2 deletions src/Package/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ public function hasCommand(string $commandClassName): Package
*/
public function hasCommands(...$commandClassNames): Package
{
$this->commands = array_merge($this->commands, collect($commandClassNames)->flatten()->toArray());
$this->commands = array_merge(
$this->commands,
collect($commandClassNames)->flatten()->toArray(),
);

return $this;
}
Expand Down Expand Up @@ -293,7 +296,10 @@ public function hasRoute(string $routeFileName): Package
*/
public function hasRoutes(...$routeFileNames): Package
{
$this->routeFileNames = array_merge($this->routeFileNames, collect($routeFileNames)->flatten()->toArray());
$this->routeFileNames = array_merge(
$this->routeFileNames,
collect($routeFileNames)->flatten()->toArray(),
);

return $this;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Package/PackageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types=1);

// phpcs:disable SlevomatCodingStandard.Files.LineLength.LineTooLong

namespace Kleinweb\Lib\Package;

use Carbon\Carbon;
Expand Down Expand Up @@ -46,7 +48,10 @@ public function register(): void
}

foreach ($this->package->configFileNames as $configFileName) {
$this->mergeConfigFrom($this->package->basePath("/../config/{$configFileName}.php"), $configFileName);
$this->mergeConfigFrom(
$this->package->basePath("/../config/{$configFileName}.php"),
$configFileName,
);
}

$this->packageRegistered();
Expand Down
2 changes: 2 additions & 0 deletions src/Support/CoreGlobals.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static function query(): WP_Query
Assert::isInstanceOf(
$globalQuery,
WP_Query::class,
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
'The WordPress global "$wp_the_query" is unusable. This request is beyond saving. Goodbye.',
);

Expand All @@ -75,6 +76,7 @@ public static function post(): ?WP_Post
$globalPost,
WP_Post::class,
sprintf(
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
'The WordPress global "$post" is not of the expected type. Expected "WP_Post", got "%s".',
gettype($globalPost),
),
Expand Down
3 changes: 2 additions & 1 deletion src/Support/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use League\Uri\Components\Host;
use League\Uri\Components\Path;
use League\Uri\Contracts\UriInterface;
use League\Uri\Exceptions\SyntaxError as UriSyntaxError;
use League\Uri\Uri;
use Webmozart\Assert\Assert;

Expand All @@ -39,7 +40,7 @@ public static function fromFilesystemPath(string $path): UriInterface

if (!$path->isAbsolute()) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
throw new \League\Uri\Exceptions\SyntaxError('Target path must be absolute: ' . $path->value());
throw new UriSyntaxError('Target path must be absolute: ' . $path->value());
}

Assert::stringNotEmpty($path->value());
Expand Down

0 comments on commit df757e4

Please sign in to comment.