From b824866c640a37c0d7316b04e30c68e23ecfafb5 Mon Sep 17 00:00:00 2001 From: binaryk Date: Thu, 7 Sep 2023 07:23:07 +0000 Subject: [PATCH] Fix styling --- src/Actions/Action.php | 2 +- src/Commands/ActionCommand.php | 4 ++-- src/Commands/FilterCommand.php | 4 ++-- src/Commands/GetterCommand.php | 4 ++-- src/Commands/PolicyCommand.php | 2 +- src/Commands/RepositoryCommand.php | 8 +++---- src/Commands/StoreCommand.php | 4 ++-- src/Eager/Related.php | 2 +- src/Fields/Field.php | 2 +- src/Fields/File.php | 4 ++-- src/Fields/HasMany.php | 1 - src/Fields/OrganicField.php | 4 ++-- src/Filters/Filter.php | 2 +- src/Getters/Getter.php | 7 +++--- src/Http/Controllers/RestController.php | 2 +- src/Http/Controllers/RestResponse.php | 2 +- src/Repositories/Repository.php | 22 +++++++++---------- src/Repositories/ValidatingTrait.php | 2 -- src/Restify.php | 1 - src/Traits/AuthorizableModels.php | 6 ++--- src/Traits/Visibility.php | 4 ++-- tests/Assertables/AssertableModel.php | 9 ++++---- .../RepositoryAttachControllerTest.php | 1 + tests/Fields/FieldTest.php | 1 + tests/Fixtures/User/User.php | 4 ++-- 25 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Actions/Action.php b/src/Actions/Action.php index f207bddb..b39d4eec 100644 --- a/src/Actions/Action.php +++ b/src/Actions/Action.php @@ -29,8 +29,8 @@ abstract class Action implements JsonSerializable { use AuthorizedToSee; - use ProxiesCanSeeToGate; use Make; + use ProxiesCanSeeToGate; use Visibility; /** diff --git a/src/Commands/ActionCommand.php b/src/Commands/ActionCommand.php index 4413e0ee..88f92f4f 100644 --- a/src/Commands/ActionCommand.php +++ b/src/Commands/ActionCommand.php @@ -34,7 +34,7 @@ public function handle() */ protected function buildClass($name) { - if (false === Str::endsWith($name, 'Action')) { + if (Str::endsWith($name, 'Action') === false) { $name .= 'Action'; } @@ -48,7 +48,7 @@ protected function getStub() protected function getPath($name) { - if (false === Str::endsWith($name, 'Action')) { + if (Str::endsWith($name, 'Action') === false) { $name .= 'Action'; } diff --git a/src/Commands/FilterCommand.php b/src/Commands/FilterCommand.php index 6908196d..95026d94 100644 --- a/src/Commands/FilterCommand.php +++ b/src/Commands/FilterCommand.php @@ -26,7 +26,7 @@ public function handle() protected function buildClass($name) { - if (false === Str::endsWith($name, 'Filter')) { + if (Str::endsWith($name, 'Filter') === false) { $name .= 'Filter'; } @@ -107,7 +107,7 @@ protected function getStub() protected function getPath($name) { - if (false === Str::endsWith($name, 'Filter')) { + if (Str::endsWith($name, 'Filter') === false) { $name .= 'Filter'; } diff --git a/src/Commands/GetterCommand.php b/src/Commands/GetterCommand.php index b2e4c383..57e468a7 100644 --- a/src/Commands/GetterCommand.php +++ b/src/Commands/GetterCommand.php @@ -34,7 +34,7 @@ public function handle() */ protected function buildClass($name) { - if (false === Str::endsWith($name, 'Getter')) { + if (Str::endsWith($name, 'Getter') === false) { $name .= 'Getter'; } @@ -48,7 +48,7 @@ protected function getStub() protected function getPath($name) { - if (false === Str::endsWith($name, 'Getter')) { + if (Str::endsWith($name, 'Getter') === false) { $name .= 'Getter'; } diff --git a/src/Commands/PolicyCommand.php b/src/Commands/PolicyCommand.php index fd941a75..e8e4bacd 100644 --- a/src/Commands/PolicyCommand.php +++ b/src/Commands/PolicyCommand.php @@ -56,7 +56,7 @@ protected function guessPolicyName() { $name = $this->getNameInput(); - if (false === Str::endsWith($name, 'Policy')) { + if (Str::endsWith($name, 'Policy') === false) { $name .= 'Policy'; } diff --git a/src/Commands/RepositoryCommand.php b/src/Commands/RepositoryCommand.php index e05bdbf8..2a2fbc85 100644 --- a/src/Commands/RepositoryCommand.php +++ b/src/Commands/RepositoryCommand.php @@ -62,7 +62,7 @@ public function handle() */ protected function buildClass($name) { - if (false === Str::endsWith($name, 'Repository')) { + if (Str::endsWith($name, 'Repository') === false) { $name .= 'Repository'; } @@ -94,7 +94,7 @@ protected function buildMigration() $guessMigration = 'Create'.Str::studly($table).'Table'; - if (false === class_exists($guessMigration)) { + if (class_exists($guessMigration) === false) { $migration = Str::snake($guessMigration); $yes = $this->confirm("Do you want to generate the migration [{$migration}]?"); @@ -120,7 +120,7 @@ protected function buildModel() { $model = $this->guessQualifiedModelName(); - if (false === class_exists($model)) { + if (class_exists($model) === false) { $yes = $this->confirm("Do you want to generate the model [{$model}]?"); if ($yes) { @@ -146,7 +146,7 @@ protected function getStub() protected function getPath($name) { - if (false === Str::endsWith($name, 'Repository')) { + if (Str::endsWith($name, 'Repository') === false) { $name .= 'Repository'; } diff --git a/src/Commands/StoreCommand.php b/src/Commands/StoreCommand.php index f560e0f5..67ee69a8 100644 --- a/src/Commands/StoreCommand.php +++ b/src/Commands/StoreCommand.php @@ -34,7 +34,7 @@ public function handle() */ protected function buildClass($name) { - if (false === Str::endsWith($name, 'Store')) { + if (Str::endsWith($name, 'Store') === false) { $name .= 'Store'; } @@ -52,7 +52,7 @@ protected function getStub() protected function getPath($name) { - if (false === Str::endsWith($name, 'Store')) { + if (Str::endsWith($name, 'Store') === false) { $name .= 'Store'; } diff --git a/src/Eager/Related.php b/src/Eager/Related.php index 42b045a0..6b78311f 100644 --- a/src/Eager/Related.php +++ b/src/Eager/Related.php @@ -18,8 +18,8 @@ class Related implements JsonSerializable { - use Make; use HasColumns; + use Make; private string $relation; diff --git a/src/Fields/Field.php b/src/Fields/Field.php index d8716020..e0c108d7 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -16,8 +16,8 @@ class Field extends OrganicField implements JsonSerializable { - use Make; use HasAction; + use Make; /** * The resource associated with the field. diff --git a/src/Fields/File.php b/src/Fields/File.php index 2fba7281..73f57eb4 100644 --- a/src/Fields/File.php +++ b/src/Fields/File.php @@ -14,11 +14,11 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; -class File extends Field implements StorableContract, DeletableContract +class File extends Field implements DeletableContract, StorableContract { - use FileStorable; use AcceptsTypes; use Deletable; + use FileStorable; /** * The callback that should be used to determine the file's storage name. diff --git a/src/Fields/HasMany.php b/src/Fields/HasMany.php index 234cba23..8f22120b 100644 --- a/src/Fields/HasMany.php +++ b/src/Fields/HasMany.php @@ -21,7 +21,6 @@ public function __construct($relation, string $parentRepository = null) /** * @param Repository $repository - * @param null $attribute * @return $this|EagerField|HasMany */ public function resolve($repository, $attribute = null) diff --git a/src/Fields/OrganicField.php b/src/Fields/OrganicField.php index 169595f5..0df304cf 100644 --- a/src/Fields/OrganicField.php +++ b/src/Fields/OrganicField.php @@ -90,7 +90,7 @@ public function isShownOnShow(RestifyRequest $request, $repository): bool public function isHiddenOnShow(RestifyRequest $request, $repository): bool { - return false === $this->isShownOnShow($request, $repository); + return $this->isShownOnShow($request, $repository) === false; } public function isShownOnIndex(RestifyRequest $request, $repository): bool @@ -99,7 +99,7 @@ public function isShownOnIndex(RestifyRequest $request, $repository): bool return false; } - return false === $this->isHiddenOnIndex($request, $repository); + return $this->isHiddenOnIndex($request, $repository) === false; } public function isHiddenOnIndex(RestifyRequest $request, $repository): bool diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index c9b2016a..94391815 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -17,8 +17,8 @@ abstract class Filter implements JsonSerializable { - use Make; use HasMode; + use Make; use Metable; public string $type = 'value'; diff --git a/src/Getters/Getter.php b/src/Getters/Getter.php index 702f9f55..8ab65195 100644 --- a/src/Getters/Getter.php +++ b/src/Getters/Getter.php @@ -19,9 +19,10 @@ use JsonSerializable; use ReturnTypeWillChange; use Symfony\Component\HttpFoundation\Response; +use Throwable; + use function tap; use function throw_unless; -use Throwable; /** * Class Getter @@ -30,9 +31,9 @@ */ abstract class Getter implements JsonSerializable { - use Make; - use AuthorizedToSee; use AuthorizedToRun; + use AuthorizedToSee; + use Make; use ProxiesCanSeeToGate; use Visibility; diff --git a/src/Http/Controllers/RestController.php b/src/Http/Controllers/RestController.php index 4868ff45..06cc30d2 100644 --- a/src/Http/Controllers/RestController.php +++ b/src/Http/Controllers/RestController.php @@ -31,8 +31,8 @@ abstract class RestController extends BaseController { use AuthorizesRequests; use DispatchesJobs; - use ValidatesRequests; use ForwardsCalls; + use ValidatesRequests; protected RestResponse $response; diff --git a/src/Http/Controllers/RestResponse.php b/src/Http/Controllers/RestResponse.php index 7baa121a..fc0d6e80 100644 --- a/src/Http/Controllers/RestResponse.php +++ b/src/Http/Controllers/RestResponse.php @@ -392,7 +392,7 @@ public function forRepository(Repository $repository, $withRelations = false): s { $model = $repository->model(); - if (false === $model instanceof Model) { + if ($model instanceof Model === false) { return $this; } diff --git a/src/Repositories/Repository.php b/src/Repositories/Repository.php index 2e1ffe0e..8ac596e9 100644 --- a/src/Repositories/Repository.php +++ b/src/Repositories/Repository.php @@ -41,23 +41,23 @@ /** * @property string $type */ -class Repository implements RestifySearchable, JsonSerializable +class Repository implements JsonSerializable, RestifySearchable { - use InteractWithSearch; - use ValidatingTrait; - use PerformsQueries; use ConditionallyLoadsAttributes; use DelegatesToResource; - use ResolvesActions; - use ResolvesGetters; - use RepositoryEvents; - use WithRoutePrefix; - use InteractWithFields; - use InteractsWithModel; - use InteractsWithAttachers; use HasColumns; + use InteractsWithAttachers; + use InteractsWithModel; + use InteractWithFields; + use InteractWithSearch; use Mockable; + use PerformsQueries; + use RepositoryEvents; + use ResolvesActions; + use ResolvesGetters; use Testing; + use ValidatingTrait; + use WithRoutePrefix; /** * This is named `resource` because of the forwarding properties from DelegatesToResource trait. diff --git a/src/Repositories/ValidatingTrait.php b/src/Repositories/ValidatingTrait.php index 9ae06b44..0a3db492 100644 --- a/src/Repositories/ValidatingTrait.php +++ b/src/Repositories/ValidatingTrait.php @@ -73,8 +73,6 @@ public static function validatorForStoringBulk(RestifyRequest $request, array $p /** * Validate a resource update request. - * - * @param null $resource */ public static function validateForUpdate(RestifyRequest $request, $resource = null) { diff --git a/src/Restify.php b/src/Restify.php index 5e36041e..a62f3acf 100644 --- a/src/Restify.php +++ b/src/Restify.php @@ -172,7 +172,6 @@ public static function repositoriesFrom(string $directory, string $namespace): v /** * Get the URI path prefix utilized by Restify. * - * @param null $plus * @return string */ public static function path($plus = null, array $query = []) diff --git a/src/Traits/AuthorizableModels.php b/src/Traits/AuthorizableModels.php index b6e0bf05..5668b163 100644 --- a/src/Traits/AuthorizableModels.php +++ b/src/Traits/AuthorizableModels.php @@ -110,7 +110,7 @@ public function authorizeToAttach(Request $request, $method, $model): bool ? Gate::check($method, [$this->model(), $model]) : abort(403, "Missing method [$method] in your [$policyClass] policy."); - if (false === $authorized) { + if ($authorized === false) { abort(403, 'You cannot attach model:'.get_class($model).', to the model:'.get_class($this->model()).', check your permissions.'); } @@ -130,7 +130,7 @@ public function authorizeToSync(Request $request, $method, Collection $keys): bo ? Gate::check($method, [$this->model(), $keys]) : abort(403, "Missing method [$method] in your [$policyClass] policy."); - if (false === $authorized) { + if ($authorized === false) { abort(403, 'You cannot sync key to the model:'.get_class($this->model()).', check your permissions.'); } @@ -148,7 +148,7 @@ public function authorizeToDetach(Request $request, $method, $model) ? Gate::check($method, [$this->model(), $model]) : false; - if (false === $authorized) { + if ($authorized === false) { throw new AuthorizationException(); } } diff --git a/src/Traits/Visibility.php b/src/Traits/Visibility.php index ed1e5674..c524d865 100644 --- a/src/Traits/Visibility.php +++ b/src/Traits/Visibility.php @@ -71,12 +71,12 @@ public function isShownOnShow(RestifyRequest $request, $repository): bool public function isHiddenOnShow(RestifyRequest $request, $repository): bool { - return false === $this->isShownOnShow($request, $repository); + return $this->isShownOnShow($request, $repository) === false; } public function isShownOnIndex(RestifyRequest $request, $repository): bool { - return false === $this->isHiddenOnIndex($request, $repository); + return $this->isHiddenOnIndex($request, $repository) === false; } public function isHiddenOnIndex(RestifyRequest $request, $repository): bool diff --git a/tests/Assertables/AssertableModel.php b/tests/Assertables/AssertableModel.php index 50714bca..a098fdf2 100644 --- a/tests/Assertables/AssertableModel.php +++ b/tests/Assertables/AssertableModel.php @@ -11,18 +11,19 @@ use Illuminate\Testing\Fluent\Concerns\Has; use Illuminate\Testing\Fluent\Concerns\Interaction; use Illuminate\Testing\Fluent\Concerns\Matching; + use function PHPUnit\Framework\assertNotNull; abstract class AssertableModel { - use Has; - use Matching; + use CarbonMatching; use Debugging; + use Has; use Interaction; use Macroable; - use Tappable; use Make; - use CarbonMatching; + use Matching; + use Tappable; public function __construct( protected Model $model, diff --git a/tests/Controllers/RepositoryAttachControllerTest.php b/tests/Controllers/RepositoryAttachControllerTest.php index 9d691e11..dcc3a5fb 100644 --- a/tests/Controllers/RepositoryAttachControllerTest.php +++ b/tests/Controllers/RepositoryAttachControllerTest.php @@ -14,6 +14,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; use Illuminate\Testing\Fluent\AssertableJson; + use function PHPUnit\Framework\assertInstanceOf; class RepositoryAttachControllerTest extends IntegrationTestCase diff --git a/tests/Fields/FieldTest.php b/tests/Fields/FieldTest.php index 3f518841..d92dece7 100644 --- a/tests/Fields/FieldTest.php +++ b/tests/Fields/FieldTest.php @@ -10,6 +10,7 @@ use Binaryk\LaravelRestify\Tests\IntegrationTestCase; use Illuminate\Database\Eloquent\Model; use Illuminate\Routing\Route; + use function PHPUnit\Framework\assertInstanceOf; use function PHPUnit\Framework\assertSame; diff --git a/tests/Fixtures/User/User.php b/tests/Fixtures/User/User.php index 393dc00d..fcbfdd94 100644 --- a/tests/Fixtures/User/User.php +++ b/tests/Fixtures/User/User.php @@ -24,11 +24,11 @@ * @property string avatar_size * @property string avatar_original */ -class User extends Authenticatable implements Sanctumable, MustVerifyEmail +class User extends Authenticatable implements MustVerifyEmail, Sanctumable { + use HasFactory; use \Illuminate\Auth\MustVerifyEmail; use Notifiable; - use HasFactory; public static $search = ['id', 'email'];