diff --git a/demo/app/Console/Kernel.php b/demo/app/Console/Kernel.php index d8bc1d29f..854bcc8a9 100644 --- a/demo/app/Console/Kernel.php +++ b/demo/app/Console/Kernel.php @@ -10,7 +10,6 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. * - * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) diff --git a/demo/app/Http/Middleware/RedirectIfAuthenticated.php b/demo/app/Http/Middleware/RedirectIfAuthenticated.php index a2813a064..4e7c24b7e 100644 --- a/demo/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/demo/app/Http/Middleware/RedirectIfAuthenticated.php @@ -12,7 +12,6 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next * @param string|null ...$guards * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse diff --git a/demo/app/Models/Post.php b/demo/app/Models/Post.php index 5ff6da2fe..12537dbb8 100644 --- a/demo/app/Models/Post.php +++ b/demo/app/Models/Post.php @@ -21,7 +21,9 @@ class Post extends Model 'title', 'content', ]; + protected $guarded = []; + protected $casts = [ 'published_at' => 'datetime', 'state' => PostState::class, diff --git a/demo/app/Providers/AppServiceProvider.php b/demo/app/Providers/AppServiceProvider.php index 49185f5ee..b21a4f0ae 100644 --- a/demo/app/Providers/AppServiceProvider.php +++ b/demo/app/Providers/AppServiceProvider.php @@ -11,7 +11,7 @@ class AppServiceProvider extends ServiceProvider public function register() { $this->app->register(SharpServiceProvider::class); -// $this->app->bind(SharpUploadModel::class, Media::class) + // $this->app->bind(SharpUploadModel::class, Media::class) $this->app->bind(SharpViteComponent::class, function () { return new SharpViteComponent(hotFile: base_path('../resources/assets/dist/hot')); diff --git a/demo/app/Sharp/Categories/CategoryForm.php b/demo/app/Sharp/Categories/CategoryForm.php index 0fbf94ca6..5082ff8a9 100644 --- a/demo/app/Sharp/Categories/CategoryForm.php +++ b/demo/app/Sharp/Categories/CategoryForm.php @@ -47,7 +47,7 @@ public function update($id, array $data) { $category = $id ? Category::findOrFail($id) - : new Category(); + : new Category; $this->save($category, $data); diff --git a/demo/app/Sharp/Dashboard/DemoDashboard.php b/demo/app/Sharp/Dashboard/DemoDashboard.php index e5b47c109..b0a80e26d 100644 --- a/demo/app/Sharp/Dashboard/DemoDashboard.php +++ b/demo/app/Sharp/Dashboard/DemoDashboard.php @@ -37,6 +37,7 @@ class DemoDashboard extends SharpDashboard '#78350F', '#9CA3AF', ]; + private static int $colorsIndex = 0; protected function buildWidgets(WidgetsContainer $widgetsContainer): void @@ -213,7 +214,7 @@ protected function setPieGraphDataSet(): void private static function nextColor(): string { - if (static::$colorsIndex >= sizeof(static::$colors)) { + if (static::$colorsIndex >= count(static::$colors)) { static::$colorsIndex = 0; } diff --git a/demo/app/Sharp/Entities/AuthorEntity.php b/demo/app/Sharp/Entities/AuthorEntity.php index b03d87507..548e36d72 100644 --- a/demo/app/Sharp/Entities/AuthorEntity.php +++ b/demo/app/Sharp/Entities/AuthorEntity.php @@ -8,5 +8,6 @@ class AuthorEntity extends SharpEntity { protected ?string $list = AuthorList::class; + protected array $prohibitedActions = ['view', 'update', 'delete', 'create']; } diff --git a/demo/app/Sharp/Entities/CategoryEntity.php b/demo/app/Sharp/Entities/CategoryEntity.php index 6ed030ad6..0ef0296ca 100644 --- a/demo/app/Sharp/Entities/CategoryEntity.php +++ b/demo/app/Sharp/Entities/CategoryEntity.php @@ -10,6 +10,8 @@ class CategoryEntity extends SharpEntity { protected ?string $list = CategoryList::class; + protected ?string $show = CategoryShow::class; + protected ?string $form = CategoryForm::class; } diff --git a/demo/app/Sharp/Entities/PostBlockEntity.php b/demo/app/Sharp/Entities/PostBlockEntity.php index 19388ca1c..11b5a0d45 100644 --- a/demo/app/Sharp/Entities/PostBlockEntity.php +++ b/demo/app/Sharp/Entities/PostBlockEntity.php @@ -12,7 +12,9 @@ class PostBlockEntity extends SharpEntity { protected ?string $list = PostBlockList::class; + protected ?string $policy = PostBlockPolicy::class; + protected string $label = 'Block'; public function getMultiforms(): array diff --git a/demo/app/Sharp/Entities/PostEntity.php b/demo/app/Sharp/Entities/PostEntity.php index 0ef73f480..e58428d65 100644 --- a/demo/app/Sharp/Entities/PostEntity.php +++ b/demo/app/Sharp/Entities/PostEntity.php @@ -11,7 +11,10 @@ class PostEntity extends SharpEntity { protected ?string $list = PostList::class; + protected ?string $show = PostShow::class; + protected ?string $form = PostForm::class; + protected ?string $policy = PostPolicy::class; } diff --git a/demo/app/Sharp/Entities/ProfileEntity.php b/demo/app/Sharp/Entities/ProfileEntity.php index 2fb331a2f..1ca53463f 100644 --- a/demo/app/Sharp/Entities/ProfileEntity.php +++ b/demo/app/Sharp/Entities/ProfileEntity.php @@ -9,7 +9,10 @@ class ProfileEntity extends SharpEntity { protected bool $isSingle = true; + protected ?string $show = ProfileSingleShow::class; + protected ?string $form = ProfileSingleForm::class; + protected string $label = 'My profile'; } diff --git a/demo/app/Sharp/Entities/TestEntity.php b/demo/app/Sharp/Entities/TestEntity.php index c7d6e6238..0c24de5a9 100644 --- a/demo/app/Sharp/Entities/TestEntity.php +++ b/demo/app/Sharp/Entities/TestEntity.php @@ -7,8 +7,12 @@ class TestEntity extends SharpEntity { protected bool $isSingle = true; + protected ?string $show = \App\Sharp\TestForm\TestShow::class; + protected ?string $form = \App\Sharp\TestForm\TestForm::class; + protected ?string $policy = \App\Sharp\TestForm\TestPolicy::class; + protected string $label = 'Test'; } diff --git a/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php b/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php index 2d9d473a6..6cc4852da 100644 --- a/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php +++ b/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php @@ -17,6 +17,7 @@ abstract class AbstractPostBlockForm extends SharpForm use WithSharpFormEloquentUpdater; protected static string $postBlockType = 'none'; + protected static string $postBlockHelpText = ''; public function buildFormFields(FieldsContainer $formFields): void @@ -46,9 +47,7 @@ public function buildFormLayout(FormLayout $formLayout): void }); } - public function buildFormConfig(): void - { - } + public function buildFormConfig(): void {} public function find($id): array { @@ -100,11 +99,7 @@ protected function getContentField(): ?SharpFormField ->setRowCount(6); } - protected function buildAdditionalFields(FieldsContainer $formFields): void - { - } + protected function buildAdditionalFields(FieldsContainer $formFields): void {} - protected function addAdditionalFieldsToLayout(FormLayoutColumn $column): void - { - } + protected function addAdditionalFieldsToLayout(FormLayoutColumn $column): void {} } diff --git a/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php b/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php index c0d1523fd..cdc5991aa 100644 --- a/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php +++ b/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php @@ -8,6 +8,7 @@ class PostBlockTextForm extends AbstractPostBlockForm { protected static string $postBlockType = 'text'; + protected ?string $formValidatorClass = PostBlockTextValidator::class; protected function getContentField(): ?SharpFormField diff --git a/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php b/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php index 295a8fffe..3b80b5e1a 100644 --- a/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php +++ b/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php @@ -5,6 +5,8 @@ class PostBlockVideoForm extends AbstractPostBlockForm { protected static string $postBlockType = 'video'; + protected static string $postBlockHelpText = 'Please provide a valid Youtube embed text'; + protected ?string $formValidatorClass = PostBlockVideoValidator::class; } diff --git a/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php b/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php index 6e2638cb0..937bfad2e 100644 --- a/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php +++ b/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php @@ -13,6 +13,7 @@ class PostBlockVisualsForm extends AbstractPostBlockForm { protected static string $postBlockType = 'visuals'; + protected ?string $formValidatorClass = PostBlockVisualsValidator::class; protected function getContentField(): ?SharpFormField @@ -60,6 +61,6 @@ protected function addAdditionalFieldsToLayout(FormLayoutColumn $column): void protected function addCustomTransformers(): self { - return $this->setCustomTransformer('files', new SharpUploadModelFormAttributeTransformer()); + return $this->setCustomTransformer('files', new SharpUploadModelFormAttributeTransformer); } } diff --git a/demo/app/Sharp/Posts/PostForm.php b/demo/app/Sharp/Posts/PostForm.php index 72011fa76..94036fba2 100644 --- a/demo/app/Sharp/Posts/PostForm.php +++ b/demo/app/Sharp/Posts/PostForm.php @@ -188,8 +188,8 @@ public function find($id): array ->setCustomTransformer('author_id', function ($value, Post $instance) { return $instance->author; }) - ->setCustomTransformer('cover', new SharpUploadModelFormAttributeTransformer()) - ->setCustomTransformer('attachments[document]', new SharpUploadModelFormAttributeTransformer()) + ->setCustomTransformer('cover', new SharpUploadModelFormAttributeTransformer) + ->setCustomTransformer('attachments[document]', new SharpUploadModelFormAttributeTransformer) ->transform(Post::with('cover', 'attachments', 'categories')->findOrFail($id)); } diff --git a/demo/app/Sharp/Profile/ProfileSingleForm.php b/demo/app/Sharp/Profile/ProfileSingleForm.php index 692a3af7f..e5887a10f 100644 --- a/demo/app/Sharp/Profile/ProfileSingleForm.php +++ b/demo/app/Sharp/Profile/ProfileSingleForm.php @@ -61,7 +61,7 @@ public function buildFormLayout(FormLayout $formLayout): void public function findSingle(): array { return $this - ->setCustomTransformer('avatar', new SharpUploadModelFormAttributeTransformer()) + ->setCustomTransformer('avatar', new SharpUploadModelFormAttributeTransformer) ->transform(auth()->user()); } diff --git a/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php b/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php index 51d743ca7..36997a086 100644 --- a/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php +++ b/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php @@ -55,7 +55,7 @@ public function transformDataForTemplate(array $data, bool $isForm): array return $user?->name; }) - ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer())->dynamicInstance()) + ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer)->dynamicInstance()) ->transformForTemplate($data); } @@ -69,7 +69,7 @@ public function transformDataForFormFields(array $data): array ? Arr::only($user, ['id', 'name', 'email']) : null; }) - ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer())->dynamicInstance()) + ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer)->dynamicInstance()) ->transform($data); } diff --git a/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php b/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php index 157c04cbf..84073e047 100644 --- a/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php +++ b/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php @@ -14,11 +14,7 @@ public function buildEmbedConfig(): void ->configureFormInlineTemplate('- Table of contents -'); } - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} - public function updateContent(array $data = []): array - { - } + public function updateContent(array $data = []): array {} } diff --git a/src/Auth/SharpAuthorizationManager.php b/src/Auth/SharpAuthorizationManager.php index 5a202c5d7..c57868adb 100644 --- a/src/Auth/SharpAuthorizationManager.php +++ b/src/Auth/SharpAuthorizationManager.php @@ -11,9 +11,7 @@ class SharpAuthorizationManager { private array $cachedPolicies = []; - public function __construct(protected SharpEntityManager $entityManager, protected Gate $gate) - { - } + public function __construct(protected SharpEntityManager $entityManager, protected Gate $gate) {} public function isAllowed(string $ability, string $entityKey, ?string $instanceId = null): bool { diff --git a/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php b/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php index 5077b1ce8..6f4a411a4 100644 --- a/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php +++ b/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php @@ -71,7 +71,7 @@ protected function initialDataForStepConfirm(): array new SvgImageBackEnd ) )) - ->writeString($this->get2faHandler()->setUser(auth()->user())->getQRCodeUrl()); + ->writeString($this->get2faHandler()->setUser(auth()->user())->getQRCodeUrl()); return [ 'qr' => [ diff --git a/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php b/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php index acc301835..f85e07348 100644 --- a/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php +++ b/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php @@ -6,9 +6,7 @@ class GoogleTotpEngine implements Sharp2faTotpEngine { - public function __construct(protected Google2FA $google2fa) - { - } + public function __construct(protected Google2FA $google2fa) {} public function verify(string $code, string $secret): bool { diff --git a/src/Auth/TwoFactor/Sharp2faDefaultNotification.php b/src/Auth/TwoFactor/Sharp2faDefaultNotification.php index 74d4b1af2..8a38f9141 100644 --- a/src/Auth/TwoFactor/Sharp2faDefaultNotification.php +++ b/src/Auth/TwoFactor/Sharp2faDefaultNotification.php @@ -10,9 +10,7 @@ class Sharp2faDefaultNotification extends Notification implements ShouldQueue { use \Illuminate\Bus\Queueable; - public function __construct(public string $code) - { - } + public function __construct(public string $code) {} public function via($notifiable) { diff --git a/src/Auth/TwoFactor/Sharp2faTotpHandler.php b/src/Auth/TwoFactor/Sharp2faTotpHandler.php index bb32e71e7..762b76b41 100644 --- a/src/Auth/TwoFactor/Sharp2faTotpHandler.php +++ b/src/Auth/TwoFactor/Sharp2faTotpHandler.php @@ -11,9 +11,7 @@ abstract class Sharp2faTotpHandler implements Sharp2faHandler { protected $user = null; - public function __construct(protected Sharp2faTotpEngine $engine) - { - } + public function __construct(protected Sharp2faTotpEngine $engine) {} public function generateCode(bool $remember = false): void { diff --git a/src/Console/DashboardMakeCommand.php b/src/Console/DashboardMakeCommand.php index a9a6b534c..194defbf7 100644 --- a/src/Console/DashboardMakeCommand.php +++ b/src/Console/DashboardMakeCommand.php @@ -7,7 +7,9 @@ class DashboardMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:dashboard'; + protected $description = 'Create a new Dashboard'; + protected $type = 'Dashboard'; protected function getStub() diff --git a/src/Console/EntityCommandMakeCommand.php b/src/Console/EntityCommandMakeCommand.php index 0908ed775..87e496d16 100644 --- a/src/Console/EntityCommandMakeCommand.php +++ b/src/Console/EntityCommandMakeCommand.php @@ -8,7 +8,9 @@ class EntityCommandMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:entity-command'; + protected $description = 'Create a new Entity List Command class'; + protected $type = 'EntityCommand'; protected function getStub() diff --git a/src/Console/EntityListFilterMakeCommand.php b/src/Console/EntityListFilterMakeCommand.php index ec572cef2..8b56e2db3 100644 --- a/src/Console/EntityListFilterMakeCommand.php +++ b/src/Console/EntityListFilterMakeCommand.php @@ -8,7 +8,9 @@ class EntityListFilterMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:entity-list-filter'; + protected $description = 'Create a new Entity List Filter class'; + protected $type = 'EntityListFilter'; protected function getStub() diff --git a/src/Console/EntityListMakeCommand.php b/src/Console/EntityListMakeCommand.php index 6bd36a6b1..b763c25fa 100644 --- a/src/Console/EntityListMakeCommand.php +++ b/src/Console/EntityListMakeCommand.php @@ -11,7 +11,9 @@ class EntityListMakeCommand extends GeneratorCommand use WithModel; protected $name = 'sharp:make:entity-list'; + protected $description = 'Create a new Entity List class'; + protected $type = 'SharpEntityList'; protected function buildClass($name) diff --git a/src/Console/FormMakeCommand.php b/src/Console/FormMakeCommand.php index 5b13e8c27..4b0e8d2e4 100644 --- a/src/Console/FormMakeCommand.php +++ b/src/Console/FormMakeCommand.php @@ -11,7 +11,9 @@ class FormMakeCommand extends GeneratorCommand use WithModel; protected $name = 'sharp:make:form'; + protected $description = 'Create a new Form class'; + protected $type = 'SharpForm'; protected function buildClass($name) diff --git a/src/Console/InstanceCommandMakeCommand.php b/src/Console/InstanceCommandMakeCommand.php index 4feb5fb6d..b9b208d6a 100644 --- a/src/Console/InstanceCommandMakeCommand.php +++ b/src/Console/InstanceCommandMakeCommand.php @@ -8,7 +8,9 @@ class InstanceCommandMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:instance-command'; + protected $description = 'Create a new instance Command class'; + protected $type = 'InstanceCommand'; protected function getStub() diff --git a/src/Console/MediaMakeCommand.php b/src/Console/MediaMakeCommand.php index 72566ea67..866fe5287 100644 --- a/src/Console/MediaMakeCommand.php +++ b/src/Console/MediaMakeCommand.php @@ -8,7 +8,9 @@ class MediaMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:media'; + protected $description = 'Create the media model for sharp uploads'; + protected $type = 'Media model'; protected function getStub() diff --git a/src/Console/ReorderHandlerMakeCommand.php b/src/Console/ReorderHandlerMakeCommand.php index e015d9474..bde3f8a28 100644 --- a/src/Console/ReorderHandlerMakeCommand.php +++ b/src/Console/ReorderHandlerMakeCommand.php @@ -10,7 +10,9 @@ class ReorderHandlerMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:reorder-handler'; + protected $description = 'Create a new Reorder Handler class'; + protected $type = 'ReorderHandler'; protected function buildClass($name) diff --git a/src/Console/ShowPageMakeCommand.php b/src/Console/ShowPageMakeCommand.php index 9767e3645..ff6179eb5 100644 --- a/src/Console/ShowPageMakeCommand.php +++ b/src/Console/ShowPageMakeCommand.php @@ -11,7 +11,9 @@ class ShowPageMakeCommand extends GeneratorCommand use WithModel; protected $name = 'sharp:make:show-page'; + protected $description = 'Create a new Show Page class'; + protected $type = 'SharpShow'; protected function buildClass($name) diff --git a/src/Console/StateMakeCommand.php b/src/Console/StateMakeCommand.php index f9f4e3d53..79f501e5c 100644 --- a/src/Console/StateMakeCommand.php +++ b/src/Console/StateMakeCommand.php @@ -10,7 +10,9 @@ class StateMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:entity-state'; + protected $description = 'Create a new Entity State class'; + protected $type = 'EntityState'; protected function buildClass($name) diff --git a/src/Console/ValidatorMakeCommand.php b/src/Console/ValidatorMakeCommand.php index c9012e810..14325d594 100644 --- a/src/Console/ValidatorMakeCommand.php +++ b/src/Console/ValidatorMakeCommand.php @@ -7,7 +7,9 @@ class ValidatorMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:validator'; + protected $description = 'Create a new Form Validator class'; + protected $type = 'Validator'; protected function getStub() diff --git a/src/Dashboard/Commands/DashboardWizardCommand.php b/src/Dashboard/Commands/DashboardWizardCommand.php index 34be780d0..887969ef5 100644 --- a/src/Dashboard/Commands/DashboardWizardCommand.php +++ b/src/Dashboard/Commands/DashboardWizardCommand.php @@ -8,7 +8,7 @@ abstract class DashboardWizardCommand extends DashboardCommand { - use IsWizardCommand, IsEntityWizardCommand; + use IsEntityWizardCommand, IsWizardCommand; abstract protected function buildFormFieldsForFirstStep(FieldsContainer $formFields): void; } diff --git a/src/Dashboard/Filters/DashboardCheckFilter.php b/src/Dashboard/Filters/DashboardCheckFilter.php index 188d7eb92..dde07936b 100644 --- a/src/Dashboard/Filters/DashboardCheckFilter.php +++ b/src/Dashboard/Filters/DashboardCheckFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\CheckFilter; -class DashboardCheckFilter extends CheckFilter -{ -} +class DashboardCheckFilter extends CheckFilter {} diff --git a/src/Dashboard/Filters/DashboardDateRangeFilter.php b/src/Dashboard/Filters/DashboardDateRangeFilter.php index 66b6c325a..d8c8bc4da 100644 --- a/src/Dashboard/Filters/DashboardDateRangeFilter.php +++ b/src/Dashboard/Filters/DashboardDateRangeFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeFilter; -abstract class DashboardDateRangeFilter extends DateRangeFilter -{ -} +abstract class DashboardDateRangeFilter extends DateRangeFilter {} diff --git a/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php b/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php index 13bc03360..959661c1d 100644 --- a/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php +++ b/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeRequiredFilter; -abstract class DashboardDateRangeRequiredFilter extends DateRangeRequiredFilter -{ -} +abstract class DashboardDateRangeRequiredFilter extends DateRangeRequiredFilter {} diff --git a/src/Dashboard/Filters/DashboardSelectFilter.php b/src/Dashboard/Filters/DashboardSelectFilter.php index 5f70bd6d2..e9724a9b4 100644 --- a/src/Dashboard/Filters/DashboardSelectFilter.php +++ b/src/Dashboard/Filters/DashboardSelectFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectFilter; -abstract class DashboardSelectFilter extends SelectFilter -{ -} +abstract class DashboardSelectFilter extends SelectFilter {} diff --git a/src/Dashboard/Filters/DashboardSelectMultipleFilter.php b/src/Dashboard/Filters/DashboardSelectMultipleFilter.php index d10a9afc5..541f6c792 100644 --- a/src/Dashboard/Filters/DashboardSelectMultipleFilter.php +++ b/src/Dashboard/Filters/DashboardSelectMultipleFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectMultipleFilter; -abstract class DashboardSelectMultipleFilter extends SelectMultipleFilter -{ -} +abstract class DashboardSelectMultipleFilter extends SelectMultipleFilter {} diff --git a/src/Dashboard/Filters/DashboardSelectRequiredFilter.php b/src/Dashboard/Filters/DashboardSelectRequiredFilter.php index 1f8eea17e..6688b8992 100644 --- a/src/Dashboard/Filters/DashboardSelectRequiredFilter.php +++ b/src/Dashboard/Filters/DashboardSelectRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectRequiredFilter; -abstract class DashboardSelectRequiredFilter extends SelectRequiredFilter -{ -} +abstract class DashboardSelectRequiredFilter extends SelectRequiredFilter {} diff --git a/src/Dashboard/Layout/DashboardLayout.php b/src/Dashboard/Layout/DashboardLayout.php index 802620e78..3ee709fb5 100644 --- a/src/Dashboard/Layout/DashboardLayout.php +++ b/src/Dashboard/Layout/DashboardLayout.php @@ -22,7 +22,7 @@ final public function addRow(Closure $callback): self { $row = $this ->getLonelySection() - ->addRowLayout(new DashboardLayoutRow()); + ->addRowLayout(new DashboardLayoutRow); $callback($row); @@ -38,7 +38,7 @@ final public function addFullWidthWidget(string $widgetKey): self private function getLonelySection(): DashboardLayoutSection { - if (! sizeof($this->sections)) { + if (! count($this->sections)) { return $this->addSectionLayout(new DashboardLayoutSection('')); } diff --git a/src/Dashboard/Layout/DashboardLayoutSection.php b/src/Dashboard/Layout/DashboardLayoutSection.php index bfed778e8..80814bf13 100644 --- a/src/Dashboard/Layout/DashboardLayoutSection.php +++ b/src/Dashboard/Layout/DashboardLayoutSection.php @@ -7,15 +7,14 @@ class DashboardLayoutSection { protected array $rows = []; + protected ?string $sectionKey = null; - public function __construct(protected string $title) - { - } + public function __construct(protected string $title) {} final public function addRow(Closure $callback): self { - $row = new DashboardLayoutRow(); + $row = new DashboardLayoutRow; $callback($row); $this->rows[] = $row; diff --git a/src/Dashboard/SharpDashboard.php b/src/Dashboard/SharpDashboard.php index 32782344e..5e89488cb 100644 --- a/src/Dashboard/SharpDashboard.php +++ b/src/Dashboard/SharpDashboard.php @@ -15,18 +15,26 @@ abstract class SharpDashboard { - use HandleFilters, - HandleDashboardCommands, + use HandleDashboardCommands, + HandleFilters, HandlePageAlertMessage; protected bool $dashboardBuilt = false; + protected array $graphWidgetDataSets = []; + protected array $panelWidgetsData = []; + protected array $figureWidgetsData = []; + protected array $orderedListWidgetsData = []; + protected ?array $pageAlertData = null; + protected ?DashboardQueryParams $queryParams; + protected ?DashboardLayout $dashboardLayout = null; + protected ?WidgetsContainer $widgetsContainer = null; final public function init(): self @@ -58,7 +66,7 @@ final public function widgets(): array final public function widgetsContainer(): WidgetsContainer { if ($this->widgetsContainer === null) { - $this->widgetsContainer = new WidgetsContainer(); + $this->widgetsContainer = new WidgetsContainer; } return $this->widgetsContainer; @@ -67,7 +75,7 @@ final public function widgetsContainer(): WidgetsContainer final public function widgetsLayout(): array { if ($this->dashboardLayout === null) { - $this->dashboardLayout = new DashboardLayout(); + $this->dashboardLayout = new DashboardLayout; $this->buildDashboardLayout($this->dashboardLayout); } @@ -77,9 +85,7 @@ final public function widgetsLayout(): array /** * Build config if necessary. */ - public function buildDashboardConfig(): void - { - } + public function buildDashboardConfig(): void {} /** * Return all filters in an array of class names or instances. diff --git a/src/Dashboard/Widgets/SharpBarGraphWidget.php b/src/Dashboard/Widgets/SharpBarGraphWidget.php index 1cf4a4738..b8c779528 100644 --- a/src/Dashboard/Widgets/SharpBarGraphWidget.php +++ b/src/Dashboard/Widgets/SharpBarGraphWidget.php @@ -5,6 +5,7 @@ class SharpBarGraphWidget extends SharpGraphWidget { protected bool $horizontal = false; + protected bool $displayHorizontalAxisAsTimeline = false; public static function make(string $key): SharpBarGraphWidget diff --git a/src/Dashboard/Widgets/SharpGraphWidget.php b/src/Dashboard/Widgets/SharpGraphWidget.php index 53a08eb78..079ed004d 100644 --- a/src/Dashboard/Widgets/SharpGraphWidget.php +++ b/src/Dashboard/Widgets/SharpGraphWidget.php @@ -5,9 +5,13 @@ abstract class SharpGraphWidget extends SharpWidget { protected ?string $display = null; + protected array $ratio = [16, 9]; + protected ?int $height = null; + protected bool $showLegend = true; + protected bool $minimal = false; public function setRatio(string $ratio): self diff --git a/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php b/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php index 9ca37471c..bce1b0692 100644 --- a/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php +++ b/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php @@ -7,7 +7,9 @@ class SharpGraphWidgetDataSet { protected array $values; + protected ?string $label = null; + protected ?string $color = null; protected function __construct(array|Collection $values) diff --git a/src/Dashboard/Widgets/SharpLineGraphWidget.php b/src/Dashboard/Widgets/SharpLineGraphWidget.php index 18e34cca9..bf3e75bf2 100644 --- a/src/Dashboard/Widgets/SharpLineGraphWidget.php +++ b/src/Dashboard/Widgets/SharpLineGraphWidget.php @@ -5,6 +5,7 @@ class SharpLineGraphWidget extends SharpGraphWidget { protected bool $curvedLines = true; + protected bool $displayHorizontalAxisAsTimeline = false; public static function make(string $key): SharpLineGraphWidget diff --git a/src/Dashboard/Widgets/SharpOrderedListWidget.php b/src/Dashboard/Widgets/SharpOrderedListWidget.php index 78a5c3dcd..f32596217 100644 --- a/src/Dashboard/Widgets/SharpOrderedListWidget.php +++ b/src/Dashboard/Widgets/SharpOrderedListWidget.php @@ -8,6 +8,7 @@ class SharpOrderedListWidget extends SharpWidget { protected ?Closure $itemLinkBuilderClosure = null; + protected bool $html = false; public static function make(string $key): self diff --git a/src/Dashboard/Widgets/SharpWidget.php b/src/Dashboard/Widgets/SharpWidget.php index e4324fa19..01743da64 100644 --- a/src/Dashboard/Widgets/SharpWidget.php +++ b/src/Dashboard/Widgets/SharpWidget.php @@ -9,8 +9,11 @@ abstract class SharpWidget { protected string $key; + protected string $type; + protected ?string $title = null; + protected ?string $link = null; protected function __construct(string $key, string $type) @@ -70,9 +73,9 @@ protected function buildArray(array $childArray): array 'title' => $this->title, 'link' => $this->link, ]) - ->merge($childArray) - ->filter(fn ($value) => $value !== null) - ->all(), + ->merge($childArray) + ->filter(fn ($value) => $value !== null) + ->all(), fn ($array) => $this->validate($array) ); } diff --git a/src/EntityList/Commands/Command.php b/src/EntityList/Commands/Command.php index 0aea83e9e..7a5d2a809 100644 --- a/src/EntityList/Commands/Command.php +++ b/src/EntityList/Commands/Command.php @@ -14,14 +14,19 @@ abstract class Command { use HandleFormFields, HandlePageAlertMessage, - WithCustomTransformers, - HandleValidation; + HandleValidation, + WithCustomTransformers; protected int $groupIndex = 0; + protected ?string $commandKey = null; + private ?string $formModalTitle = null; + private ?string $formModalButtonLabel = null; + private ?string $confirmationText = null; + private ?string $description = null; protected function info(string $message): array @@ -62,7 +67,7 @@ protected function view(string $bladeView, array $params = []): array 'html' => view($bladeView, $params)->render(), ]; } - + protected function html(string $htmlContent): array { return [ @@ -71,7 +76,7 @@ protected function html(string $htmlContent): array ]; } - protected function download(string $filePath, string $fileName = null, string $diskName = null): array + protected function download(string $filePath, ?string $fileName = null, ?string $diskName = null): array { return [ 'action' => 'download', @@ -159,23 +164,17 @@ final public function getFormModalButtonLabel(): ?string /** * Build the optional Command config with configure... methods. */ - public function buildCommandConfig(): void - { - } + public function buildCommandConfig(): void {} /** * Build the optional Command form. */ - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} /** * Build the optional Command form layout. */ - public function buildFormLayout(FormLayoutColumn &$column): void - { - } + public function buildFormLayout(FormLayoutColumn &$column): void {} final public function commandFormConfig(): ?array { diff --git a/src/EntityList/Commands/EntityCommand.php b/src/EntityList/Commands/EntityCommand.php index 40c323aab..0615215e6 100644 --- a/src/EntityList/Commands/EntityCommand.php +++ b/src/EntityList/Commands/EntityCommand.php @@ -7,6 +7,7 @@ abstract class EntityCommand extends Command { protected ?EntityListQueryParams $queryParams = null; + protected ?string $instanceSelectionMode = null; public function type(): string diff --git a/src/EntityList/Commands/EntityState.php b/src/EntityList/Commands/EntityState.php index 233cf5db3..67e9fabfe 100644 --- a/src/EntityList/Commands/EntityState.php +++ b/src/EntityList/Commands/EntityState.php @@ -19,7 +19,7 @@ public function states(): array return $this->states; } - protected function addState(string $key, string $label, string $color = null): self + protected function addState(string $key, string $label, ?string $color = null): self { $this->states[$key] = [$label, $color]; @@ -38,8 +38,6 @@ protected function info(string $message): array /** * @param mixed $instanceId - * @param array $data - * @return array * * @throws SharpInvalidEntityStateException */ @@ -64,7 +62,6 @@ abstract protected function buildStates(): void; /** * @param mixed $instanceId - * @param string $stateId * @return mixed */ abstract protected function updateState($instanceId, string $stateId): array; diff --git a/src/EntityList/Commands/Wizards/EntityWizardCommand.php b/src/EntityList/Commands/Wizards/EntityWizardCommand.php index 86087c554..4d242d6f0 100644 --- a/src/EntityList/Commands/Wizards/EntityWizardCommand.php +++ b/src/EntityList/Commands/Wizards/EntityWizardCommand.php @@ -7,7 +7,7 @@ abstract class EntityWizardCommand extends EntityCommand { - use IsWizardCommand, IsEntityWizardCommand; + use IsEntityWizardCommand, IsWizardCommand; abstract protected function buildFormFieldsForFirstStep(FieldsContainer $formFields): void; } diff --git a/src/EntityList/Commands/Wizards/InstanceWizardCommand.php b/src/EntityList/Commands/Wizards/InstanceWizardCommand.php index 873680619..b266dca7b 100644 --- a/src/EntityList/Commands/Wizards/InstanceWizardCommand.php +++ b/src/EntityList/Commands/Wizards/InstanceWizardCommand.php @@ -31,7 +31,7 @@ public function executeStep(string $step, mixed $instanceId, array $data = []): // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step executeStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } protected function initialData(mixed $instanceId): array diff --git a/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php b/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php index a962f39dc..7a44a14ff 100644 --- a/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php +++ b/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php @@ -29,7 +29,7 @@ public function executeStep(string $step, array $data = []): array // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step executeStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } protected function initialData(): array diff --git a/src/EntityList/Commands/Wizards/IsWizardCommand.php b/src/EntityList/Commands/Wizards/IsWizardCommand.php index af2a98183..6cca67333 100644 --- a/src/EntityList/Commands/Wizards/IsWizardCommand.php +++ b/src/EntityList/Commands/Wizards/IsWizardCommand.php @@ -10,6 +10,7 @@ trait IsWizardCommand { protected ?WizardCommandContext $wizardCommandContext = null; + private string $key; protected function getWizardContext(): WizardCommandContext @@ -17,7 +18,7 @@ protected function getWizardContext(): WizardCommandContext if (! $this->wizardCommandContext) { $this->wizardCommandContext = session()->get(sprintf('CWC.%s.%s', get_class($this), $this->getKey())); if (! $this->wizardCommandContext) { - $this->wizardCommandContext = new WizardCommandContext(); + $this->wizardCommandContext = new WizardCommandContext; } } @@ -80,7 +81,7 @@ protected function buildFormFieldsForStep(string $step, FieldsContainer $formFie // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step buildFormFieldsForStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } public function buildFormLayout(FormLayoutColumn &$column): void @@ -97,11 +98,7 @@ public function buildFormLayout(FormLayoutColumn &$column): void } } - protected function buildFormLayoutForFirstStep(FormLayoutColumn &$column): void - { - } + protected function buildFormLayoutForFirstStep(FormLayoutColumn &$column): void {} - protected function buildFormLayoutForStep(string $step, FormLayoutColumn &$column): void - { - } + protected function buildFormLayoutForStep(string $step, FormLayoutColumn &$column): void {} } diff --git a/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php b/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php index 8d3a4877b..6f50e3790 100644 --- a/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php +++ b/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php @@ -31,7 +31,7 @@ public function executeStep(string $step, array $data = []): array // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step executeStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } protected function initialSingleData(): array diff --git a/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php b/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php index fd40ce6ac..970f74dc2 100644 --- a/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php +++ b/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php @@ -7,11 +7,10 @@ class SimpleEloquentReorderHandler implements ReorderHandler { protected string $idAttribute = 'id'; + protected string $orderAttribute = 'order'; - public function __construct(private string $modelClassName) - { - } + public function __construct(private string $modelClassName) {} public function setIdAttribute(string $idAttribute): self { diff --git a/src/EntityList/EntityListQueryParams.php b/src/EntityList/EntityListQueryParams.php index 9cc9c5819..a8f849bec 100644 --- a/src/EntityList/EntityListQueryParams.php +++ b/src/EntityList/EntityListQueryParams.php @@ -10,9 +10,13 @@ class EntityListQueryParams use HasFiltersInQuery; protected ?int $page; + protected ?string $search = null; + protected ?string $sortedBy = null; + protected ?string $sortedDir = null; + protected array $specificIds = []; public static function create(): static diff --git a/src/EntityList/Fields/EntityListField.php b/src/EntityList/Fields/EntityListField.php index 356ab6a1d..9932fc139 100644 --- a/src/EntityList/Fields/EntityListField.php +++ b/src/EntityList/Fields/EntityListField.php @@ -5,16 +5,22 @@ class EntityListField { public string $key; + protected string $label = ''; + protected bool $sortable = false; + protected bool $html = true; + protected ?int $width; + protected int|bool|null $widthXs; + protected bool $hideOnXs = false; public static function make(string $key): self { - $instance = new static(); + $instance = new static; $instance->key = $key; return $instance; diff --git a/src/EntityList/Fields/EntityListFieldsLayout.php b/src/EntityList/Fields/EntityListFieldsLayout.php index 6c3b63a88..94f2b8f50 100644 --- a/src/EntityList/Fields/EntityListFieldsLayout.php +++ b/src/EntityList/Fields/EntityListFieldsLayout.php @@ -11,7 +11,7 @@ class EntityListFieldsLayout { protected array $columns = []; - final public function addColumn(string $key, int $size = null): self + final public function addColumn(string $key, ?int $size = null): self { $this->columns[$key] = ($size ?: 'fill'); @@ -25,7 +25,7 @@ final public function getSizeOf(string $key): int|string|null final public function hasColumns(): bool { - return sizeof($this->columns) > 0; + return count($this->columns) > 0; } final public function getColumns(): Collection diff --git a/src/EntityList/Filters/EntityListCheckFilter.php b/src/EntityList/Filters/EntityListCheckFilter.php index dfc5a84cf..d7b5c295c 100644 --- a/src/EntityList/Filters/EntityListCheckFilter.php +++ b/src/EntityList/Filters/EntityListCheckFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\CheckFilter; -class EntityListCheckFilter extends CheckFilter -{ -} +class EntityListCheckFilter extends CheckFilter {} diff --git a/src/EntityList/Filters/EntityListDateRangeFilter.php b/src/EntityList/Filters/EntityListDateRangeFilter.php index f84452876..9df30d667 100644 --- a/src/EntityList/Filters/EntityListDateRangeFilter.php +++ b/src/EntityList/Filters/EntityListDateRangeFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeFilter; -abstract class EntityListDateRangeFilter extends DateRangeFilter -{ -} +abstract class EntityListDateRangeFilter extends DateRangeFilter {} diff --git a/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php b/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php index 3d32b2135..8513993bd 100644 --- a/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php +++ b/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeRequiredFilter; -abstract class EntityListDateRangeRequiredFilter extends DateRangeRequiredFilter -{ -} +abstract class EntityListDateRangeRequiredFilter extends DateRangeRequiredFilter {} diff --git a/src/EntityList/Filters/EntityListSelectFilter.php b/src/EntityList/Filters/EntityListSelectFilter.php index 5b1f461fb..4defd6b4b 100644 --- a/src/EntityList/Filters/EntityListSelectFilter.php +++ b/src/EntityList/Filters/EntityListSelectFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectFilter; -abstract class EntityListSelectFilter extends SelectFilter -{ -} +abstract class EntityListSelectFilter extends SelectFilter {} diff --git a/src/EntityList/Filters/EntityListSelectMultipleFilter.php b/src/EntityList/Filters/EntityListSelectMultipleFilter.php index 652e88adf..33b7b7261 100644 --- a/src/EntityList/Filters/EntityListSelectMultipleFilter.php +++ b/src/EntityList/Filters/EntityListSelectMultipleFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectMultipleFilter; -abstract class EntityListSelectMultipleFilter extends SelectMultipleFilter -{ -} +abstract class EntityListSelectMultipleFilter extends SelectMultipleFilter {} diff --git a/src/EntityList/Filters/EntityListSelectRequiredFilter.php b/src/EntityList/Filters/EntityListSelectRequiredFilter.php index fe4b89019..698f93313 100644 --- a/src/EntityList/Filters/EntityListSelectRequiredFilter.php +++ b/src/EntityList/Filters/EntityListSelectRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectRequiredFilter; -abstract class EntityListSelectRequiredFilter extends SelectRequiredFilter -{ -} +abstract class EntityListSelectRequiredFilter extends SelectRequiredFilter {} diff --git a/src/EntityList/SharpEntityList.php b/src/EntityList/SharpEntityList.php index 95b26a05a..e35b1a517 100644 --- a/src/EntityList/SharpEntityList.php +++ b/src/EntityList/SharpEntityList.php @@ -17,25 +17,37 @@ abstract class SharpEntityList { - use HandleFilters, + use HandleEntityCommands, HandleEntityState, - HandleEntityCommands, + HandleFilters, HandleInstanceCommands, HandlePageAlertMessage, WithCustomTransformers; private ?EntityListFieldsContainer $fieldsContainer = null; + private ?EntityListFieldsLayout $fieldsLayout = null; + private ?EntityListFieldsLayout $xsFieldsLayout = null; + protected ?EntityListQueryParams $queryParams; + protected string $instanceIdAttribute = 'id'; + protected ?string $multiformAttribute = null; + protected bool $searchable = false; + protected bool $paginated = false; + protected ?ReorderHandler $reorderHandler = null; + protected ?string $defaultSort = null; + protected ?string $defaultSortDir = null; + protected bool $deleteHidden = false; + protected ?string $deleteConfirmationText = null; final public function initQueryParams(): self @@ -222,7 +234,7 @@ final public function reorderHandler(): ?ReorderHandler private function checkListIsBuilt(): void { if ($this->fieldsContainer === null) { - $this->fieldsContainer = new EntityListFieldsContainer(); + $this->fieldsContainer = new EntityListFieldsContainer; $this->buildList($this->fieldsContainer); } } @@ -237,9 +249,7 @@ final protected function getDataKeys(): array /** * Build list config. */ - public function buildListConfig(): void - { - } + public function buildListConfig(): void {} /** * Return all entity commands in an array of class names or instances. @@ -277,9 +287,7 @@ protected function getGlobalMessageData(): ?array * Delete the given instance. Do not implement this method if you want to delegate * the deletion responsibility to the Show Page (then implement it there). */ - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} /** * Retrieve all rows data as an array. @@ -293,12 +301,12 @@ protected function buildList(EntityListFieldsContainer $fields): void { // This default implementation is there to avoid breaking changes; // it will be removed in the next major version of Sharp. - $this->fieldsContainer = new EntityListFieldsContainer(); + $this->fieldsContainer = new EntityListFieldsContainer; $this->buildListFields($this->fieldsContainer); - $fieldsLayout = new EntityListFieldsLayout(); + $fieldsLayout = new EntityListFieldsLayout; $this->buildListLayout($fieldsLayout); - $xsFieldsLayout = new EntityListFieldsLayout(); + $xsFieldsLayout = new EntityListFieldsLayout; $this->buildListLayoutForSmallScreens($xsFieldsLayout); $this->fieldsContainer @@ -332,25 +340,19 @@ protected function buildList(EntityListFieldsContainer $fields): void * * @deprecated use buildList instead */ - protected function buildListFields(EntityListFieldsContainer $fieldsContainer): void - { - } + protected function buildListFields(EntityListFieldsContainer $fieldsContainer): void {} /** * Build list layout. * * @deprecated use buildList instead */ - protected function buildListLayout(EntityListFieldsLayout $fieldsLayout): void - { - } + protected function buildListLayout(EntityListFieldsLayout $fieldsLayout): void {} /** * Build layout for small screen. Optional, only if needed. * * @deprecated use buildList instead */ - protected function buildListLayoutForSmallScreens(EntityListFieldsLayout $fieldsLayout): void - { - } + protected function buildListLayoutForSmallScreens(EntityListFieldsLayout $fieldsLayout): void {} } diff --git a/src/EntityList/Traits/HandleEntityCommands.php b/src/EntityList/Traits/HandleEntityCommands.php index 87a56e91a..b3b7fe22a 100644 --- a/src/EntityList/Traits/HandleEntityCommands.php +++ b/src/EntityList/Traits/HandleEntityCommands.php @@ -10,6 +10,7 @@ trait HandleEntityCommands { protected ?Collection $entityCommandHandlers = null; + protected ?string $primaryEntityCommandKey = null; protected function configurePrimaryEntityCommand(string $commandKeyOrClassName): self diff --git a/src/EntityList/Traits/HandleEntityState.php b/src/EntityList/Traits/HandleEntityState.php index db9261544..94c455b19 100644 --- a/src/EntityList/Traits/HandleEntityState.php +++ b/src/EntityList/Traits/HandleEntityState.php @@ -7,6 +7,7 @@ trait HandleEntityState { protected ?string $entityStateAttribute = null; + protected ?EntityState $entityStateHandler = null; protected function configureEntityState(string $stateAttribute, $stateHandlerOrClassName): self diff --git a/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php b/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php index fb57b41eb..350bf081e 100644 --- a/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php +++ b/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpAuthenticationNeeds2faException extends SharpException -{ -} +class SharpAuthenticationNeeds2faException extends SharpException {} diff --git a/src/Exceptions/Auth/SharpAuthorizationException.php b/src/Exceptions/Auth/SharpAuthorizationException.php index 262db896a..ee7872804 100644 --- a/src/Exceptions/Auth/SharpAuthorizationException.php +++ b/src/Exceptions/Auth/SharpAuthorizationException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpAuthorizationException extends SharpException -{ -} +class SharpAuthorizationException extends SharpException {} diff --git a/src/Exceptions/Commands/SharpInvalidStepException.php b/src/Exceptions/Commands/SharpInvalidStepException.php index ede046367..ceac26f64 100644 --- a/src/Exceptions/Commands/SharpInvalidStepException.php +++ b/src/Exceptions/Commands/SharpInvalidStepException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpInvalidStepException extends SharpException -{ -} +class SharpInvalidStepException extends SharpException {} diff --git a/src/Exceptions/EntityList/SharpEntityListLayoutException.php b/src/Exceptions/EntityList/SharpEntityListLayoutException.php index 0366ea2d1..0e4f8ca86 100644 --- a/src/Exceptions/EntityList/SharpEntityListLayoutException.php +++ b/src/Exceptions/EntityList/SharpEntityListLayoutException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpEntityListLayoutException extends SharpException -{ -} +class SharpEntityListLayoutException extends SharpException {} diff --git a/src/Exceptions/EntityList/SharpInvalidEntityStateException.php b/src/Exceptions/EntityList/SharpInvalidEntityStateException.php index 3d51f095c..8c5e39958 100644 --- a/src/Exceptions/EntityList/SharpInvalidEntityStateException.php +++ b/src/Exceptions/EntityList/SharpInvalidEntityStateException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpInvalidEntityStateException extends SharpException -{ -} +class SharpInvalidEntityStateException extends SharpException {} diff --git a/src/Exceptions/Form/SharpApplicativeException.php b/src/Exceptions/Form/SharpApplicativeException.php index 644000683..3fd050967 100644 --- a/src/Exceptions/Form/SharpApplicativeException.php +++ b/src/Exceptions/Form/SharpApplicativeException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpApplicativeException extends SharpException -{ -} +class SharpApplicativeException extends SharpException {} diff --git a/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php b/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php index e4da371b0..2ecc81ed6 100644 --- a/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php +++ b/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpFormFieldFormattingMustBeDelayedException extends SharpException -{ -} +class SharpFormFieldFormattingMustBeDelayedException extends SharpException {} diff --git a/src/Exceptions/Form/SharpFormUpdateException.php b/src/Exceptions/Form/SharpFormUpdateException.php index 4c8ddd32b..0c948fa97 100644 --- a/src/Exceptions/Form/SharpFormUpdateException.php +++ b/src/Exceptions/Form/SharpFormUpdateException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpFormUpdateException extends SharpException -{ -} +class SharpFormUpdateException extends SharpException {} diff --git a/src/Exceptions/SharpException.php b/src/Exceptions/SharpException.php index 98fad27a3..8db6d41b0 100644 --- a/src/Exceptions/SharpException.php +++ b/src/Exceptions/SharpException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpException extends \Exception -{ -} +class SharpException extends \Exception {} diff --git a/src/Exceptions/SharpInvalidBreadcrumbItemException.php b/src/Exceptions/SharpInvalidBreadcrumbItemException.php index cc8b0e020..3e2f36b20 100644 --- a/src/Exceptions/SharpInvalidBreadcrumbItemException.php +++ b/src/Exceptions/SharpInvalidBreadcrumbItemException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpInvalidBreadcrumbItemException extends SharpException -{ -} +class SharpInvalidBreadcrumbItemException extends SharpException {} diff --git a/src/Exceptions/SharpInvalidConfigException.php b/src/Exceptions/SharpInvalidConfigException.php index 861491f4e..ac20e5c50 100644 --- a/src/Exceptions/SharpInvalidConfigException.php +++ b/src/Exceptions/SharpInvalidConfigException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpInvalidConfigException extends SharpException -{ -} +class SharpInvalidConfigException extends SharpException {} diff --git a/src/Exceptions/SharpInvalidEntityKeyException.php b/src/Exceptions/SharpInvalidEntityKeyException.php index 7ea084879..ba3f5c264 100644 --- a/src/Exceptions/SharpInvalidEntityKeyException.php +++ b/src/Exceptions/SharpInvalidEntityKeyException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpInvalidEntityKeyException extends SharpException -{ -} +class SharpInvalidEntityKeyException extends SharpException {} diff --git a/src/Exceptions/SharpMethodNotImplementedException.php b/src/Exceptions/SharpMethodNotImplementedException.php index 67a574d57..fabd98dbd 100644 --- a/src/Exceptions/SharpMethodNotImplementedException.php +++ b/src/Exceptions/SharpMethodNotImplementedException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpMethodNotImplementedException extends SharpException -{ -} +class SharpMethodNotImplementedException extends SharpException {} diff --git a/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php b/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php index 62df10a8d..cb494d2e6 100644 --- a/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php +++ b/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpInvalidAssetRenderStrategy extends SharpException -{ -} +class SharpInvalidAssetRenderStrategy extends SharpException {} diff --git a/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php b/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php index 9905b6c75..72abc1c90 100644 --- a/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php +++ b/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpFormEloquentUpdateException extends SharpException -{ -} +class SharpFormEloquentUpdateException extends SharpException {} diff --git a/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php b/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php index 7a80a2331..7ea97f6b8 100644 --- a/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php +++ b/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Eloquent\Relationships; -class MorphManyRelationUpdater extends HasManyRelationUpdater -{ -} +class MorphManyRelationUpdater extends HasManyRelationUpdater {} diff --git a/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php b/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php index 112267840..df4ece496 100644 --- a/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php +++ b/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Eloquent\Relationships; -class MorphOneRelationUpdater extends HasOneRelationUpdater -{ -} +class MorphOneRelationUpdater extends HasOneRelationUpdater {} diff --git a/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php b/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php index 5a25b70f3..6c885e6cb 100644 --- a/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php +++ b/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Eloquent\Relationships; -class MorphToManyRelationUpdater extends BelongsToManyRelationUpdater -{ -} +class MorphToManyRelationUpdater extends BelongsToManyRelationUpdater {} diff --git a/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php b/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php index 395ffc4aa..29008f33c 100644 --- a/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php +++ b/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php @@ -29,9 +29,6 @@ class CreateUploadsMigration extends Command /** * Create a new migration install command instance. - * - * @param UploadsMigrationCreator $creator - * @param Composer $composer */ public function __construct(UploadsMigrationCreator $creator, Composer $composer) { diff --git a/src/Form/Eloquent/Uploads/SharpUploadModel.php b/src/Form/Eloquent/Uploads/SharpUploadModel.php index d74bffdce..a93e24fbd 100644 --- a/src/Form/Eloquent/Uploads/SharpUploadModel.php +++ b/src/Form/Eloquent/Uploads/SharpUploadModel.php @@ -9,6 +9,7 @@ class SharpUploadModel extends Model { protected $guarded = []; + protected $casts = [ 'custom_properties' => 'array', 'size' => 'integer', @@ -73,7 +74,7 @@ protected function isRealAttribute(string $name): bool ]); } - public function thumbnail(int $width = null, int $height = null, array $customFilters = []): ?string + public function thumbnail(?int $width = null, ?int $height = null, array $customFilters = []): ?string { return (new Thumbnail($this)) ->setTransformationFilters($this->filters ?: null) diff --git a/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php b/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php index 46015ddba..8994e0f0b 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php @@ -12,6 +12,6 @@ class GreyscaleFilter extends ThumbnailFilter public function applyFilter(Image $image) { return (new GreyscaleModifier($this->params)) - ->apply($image); + ->apply($image); } } diff --git a/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php b/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php index 35155051b..3e141977f 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php @@ -15,14 +15,20 @@ class Thumbnail { protected ImageManager $imageManager; + protected FilesystemManager $storage; + protected SharpUploadModel $uploadModel; + protected int $quality = 90; + protected bool $appendTimestamp = false; + protected ?Closure $afterClosure = null; + protected ?array $transformationFilters = null; - public function __construct(SharpUploadModel $model, ImageManager $imageManager = null, FilesystemManager $storage = null) + public function __construct(SharpUploadModel $model, ?ImageManager $imageManager = null, ?FilesystemManager $storage = null) { $this->uploadModel = $model; $this->imageManager = $imageManager ?: app(ImageManager::class); @@ -50,7 +56,7 @@ public function setAppendTimestamp(bool $appendTimestamp = true): self return $this; } - public function setTransformationFilters(array $transformationFilters = null): self + public function setTransformationFilters(?array $transformationFilters = null): self { $this->transformationFilters = $transformationFilters; @@ -66,7 +72,7 @@ public function make(?int $width, ?int $height = null, array $filters = []): ?st $thumbnailDisk = $this->storage->disk(config('sharp.uploads.thumbnails_disk', 'public')); $thumbDirNameAppender = ($this->transformationFilters ? '_'.md5(serialize($this->transformationFilters)) : '') - .(sizeof($filters) ? '_'.md5(serialize($filters)) : '') + .(count($filters) ? '_'.md5(serialize($filters)) : '') ."_q-$this->quality"; $thumbnailPath = sprintf( diff --git a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php index c34b97aa0..88c7ac268 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php @@ -9,9 +9,7 @@ */ abstract class ThumbnailFilter { - public function __construct(protected array $params) - { - } + public function __construct(protected array $params) {} public function resized() { diff --git a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php index 07cfbd593..b861d2664 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php @@ -6,9 +6,7 @@ abstract class ThumbnailModifier implements ModifierInterface { - public function __construct(protected array $params) - { - } + public function __construct(protected array $params) {} public function resized(): bool { diff --git a/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php b/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php index f53690c80..38ff01160 100644 --- a/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php +++ b/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php @@ -15,8 +15,11 @@ class SharpUploadModelFormAttributeTransformer implements SharpAttributeTransfor use UsesSharpUploadModel; protected bool $withThumbnails; + protected int $thumbnailWidth; + protected int $thumbnailHeight; + private bool $dynamicSharpUploadModel = false; public function __construct(bool $withThumbnails = true, int $thumbnailWidth = 200, int $thumbnailHeight = 200) @@ -36,8 +39,6 @@ public function dynamicInstance(): self /** * Transform a model attribute to array (json-able). * - * @param $value - * @param $instance * @param string $attribute * @return mixed */ diff --git a/src/Form/Fields/Embeds/SharpFormEditorEmbed.php b/src/Form/Fields/Embeds/SharpFormEditorEmbed.php index 341407cea..f4764dc7f 100644 --- a/src/Form/Fields/Embeds/SharpFormEditorEmbed.php +++ b/src/Form/Fields/Embeds/SharpFormEditorEmbed.php @@ -15,11 +15,13 @@ abstract class SharpFormEditorEmbed { use HandleFields, HandlePageAlertMessage, - WithCustomTransformers, - HandleValidation; + HandleValidation, + WithCustomTransformers; protected ?string $label = null; + protected ?string $tagName = null; + protected array $templates = []; public function toConfigArray(bool $isForm): array @@ -50,9 +52,7 @@ public function toConfigArray(bool $isForm): array return $config; } - public function buildEmbedConfig(): void - { - } + public function buildEmbedConfig(): void {} /** * Must return all the data needed by the templates. @@ -81,9 +81,7 @@ abstract public function updateContent(array $data = []): array; /** * Build the optional Embed form layout. */ - public function buildFormLayout(FormLayoutColumn &$column): void - { - } + public function buildFormLayout(FormLayoutColumn &$column): void {} final public function formLayout(): ?array { diff --git a/src/Form/Fields/Formatters/AbstractSimpleFormatter.php b/src/Form/Fields/Formatters/AbstractSimpleFormatter.php index 0044a322f..61eddc5c9 100644 --- a/src/Form/Fields/Formatters/AbstractSimpleFormatter.php +++ b/src/Form/Fields/Formatters/AbstractSimpleFormatter.php @@ -7,8 +7,6 @@ abstract class AbstractSimpleFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/AutocompleteFormatter.php b/src/Form/Fields/Formatters/AutocompleteFormatter.php index 56667a497..d0ff4ecad 100644 --- a/src/Form/Fields/Formatters/AutocompleteFormatter.php +++ b/src/Form/Fields/Formatters/AutocompleteFormatter.php @@ -8,8 +8,6 @@ class AutocompleteFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -22,9 +20,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/AutocompleteListFormatter.php b/src/Form/Fields/Formatters/AutocompleteListFormatter.php index 07e3a2406..88a96fd2e 100644 --- a/src/Form/Fields/Formatters/AutocompleteListFormatter.php +++ b/src/Form/Fields/Formatters/AutocompleteListFormatter.php @@ -7,8 +7,6 @@ class AutocompleteListFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -28,9 +26,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return array */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/CheckFormatter.php b/src/Form/Fields/Formatters/CheckFormatter.php index ef18d6bfd..426c68d02 100644 --- a/src/Form/Fields/Formatters/CheckFormatter.php +++ b/src/Form/Fields/Formatters/CheckFormatter.php @@ -7,8 +7,6 @@ class CheckFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return bool */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return bool */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/EditorFormatter.php b/src/Form/Fields/Formatters/EditorFormatter.php index 086e49150..57d53bcff 100644 --- a/src/Form/Fields/Formatters/EditorFormatter.php +++ b/src/Form/Fields/Formatters/EditorFormatter.php @@ -78,7 +78,7 @@ protected function handleUploadedFiles(string $text, array $files, SharpFormFiel protected function getDomDocument(string $content): DOMDocument { - return tap(new DOMDocument(), function (DOMDocument $dom) use ($content) { + return tap(new DOMDocument, function (DOMDocument $dom) use ($content) { $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); @$dom->loadHTML("$content"); }); diff --git a/src/Form/Fields/Formatters/GeolocationFormatter.php b/src/Form/Fields/Formatters/GeolocationFormatter.php index 7a4a7f469..b5641bf04 100644 --- a/src/Form/Fields/Formatters/GeolocationFormatter.php +++ b/src/Form/Fields/Formatters/GeolocationFormatter.php @@ -7,8 +7,6 @@ class GeolocationFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -25,9 +23,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return string */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/HtmlFormatter.php b/src/Form/Fields/Formatters/HtmlFormatter.php index 36ff20a6d..3e51573d1 100644 --- a/src/Form/Fields/Formatters/HtmlFormatter.php +++ b/src/Form/Fields/Formatters/HtmlFormatter.php @@ -7,8 +7,6 @@ class HtmlFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return null */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/ListFormatter.php b/src/Form/Fields/Formatters/ListFormatter.php index efe006a8f..59577fc28 100644 --- a/src/Form/Fields/Formatters/ListFormatter.php +++ b/src/Form/Fields/Formatters/ListFormatter.php @@ -7,8 +7,6 @@ class ListFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -43,9 +41,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return array */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/NumberFormatter.php b/src/Form/Fields/Formatters/NumberFormatter.php index 7c22740c2..597da57ba 100644 --- a/src/Form/Fields/Formatters/NumberFormatter.php +++ b/src/Form/Fields/Formatters/NumberFormatter.php @@ -7,8 +7,6 @@ class NumberFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/SelectFormatter.php b/src/Form/Fields/Formatters/SelectFormatter.php index c73ee39e9..63c8792e8 100644 --- a/src/Form/Fields/Formatters/SelectFormatter.php +++ b/src/Form/Fields/Formatters/SelectFormatter.php @@ -8,8 +8,6 @@ class SelectFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -33,9 +31,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/SharpFieldFormatter.php b/src/Form/Fields/Formatters/SharpFieldFormatter.php index cd7d6c515..69d74e9e6 100644 --- a/src/Form/Fields/Formatters/SharpFieldFormatter.php +++ b/src/Form/Fields/Formatters/SharpFieldFormatter.php @@ -7,6 +7,7 @@ abstract class SharpFieldFormatter { protected ?string $instanceId = null; + protected ?array $dataLocalizations = null; public function setInstanceId(?string $instanceId): self @@ -24,16 +25,11 @@ public function setDataLocalizations(array $dataLocalizations): self } /** - * @param SharpFormField $field - * @param $value * @return mixed */ abstract public function toFront(SharpFormField $field, $value); /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ abstract public function fromFront(SharpFormField $field, string $attribute, $value); diff --git a/src/Form/Fields/Formatters/TagsFormatter.php b/src/Form/Fields/Formatters/TagsFormatter.php index 53fcdbf6a..142b06eeb 100644 --- a/src/Form/Fields/Formatters/TagsFormatter.php +++ b/src/Form/Fields/Formatters/TagsFormatter.php @@ -8,8 +8,6 @@ class TagsFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return array */ public function toFront(SharpFormField $field, $value) @@ -30,9 +28,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return array */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/TextareaFormatter.php b/src/Form/Fields/Formatters/TextareaFormatter.php index 8a1641acf..d76f4ccf1 100644 --- a/src/Form/Fields/Formatters/TextareaFormatter.php +++ b/src/Form/Fields/Formatters/TextareaFormatter.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Fields\Formatters; -class TextareaFormatter extends TextFormatter -{ -} +class TextareaFormatter extends TextFormatter {} diff --git a/src/Form/Fields/Formatters/UploadFormatter.php b/src/Form/Fields/Formatters/UploadFormatter.php index dc7af8edb..df38248ca 100644 --- a/src/Form/Fields/Formatters/UploadFormatter.php +++ b/src/Form/Fields/Formatters/UploadFormatter.php @@ -17,8 +17,11 @@ class UploadFormatter extends SharpFieldFormatter { protected FilesystemManager $filesystem; + protected FileUtil $fileUtil; + protected ImageManager $imageManager; + private bool $alwaysReturnFullObject = false; public function __construct() @@ -36,8 +39,6 @@ public function setAlwaysReturnFullObject(?bool $returnFullObject = true): self } /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -133,7 +134,7 @@ protected function getStoragePath(string $fileName, SharpFormUploadField|SharpFo // Well, we need the instance id for the storage path, and we are // in a store() case. Let's delay this formatter, it will be // called again after a first save() on the model. - throw new SharpFormFieldFormattingMustBeDelayedException(); + throw new SharpFormFieldFormattingMustBeDelayedException; } $basePath = str_replace('{id}', $this->instanceId, $basePath); diff --git a/src/Form/Fields/SharpFormAutocompleteField.php b/src/Form/Fields/SharpFormAutocompleteField.php index 968bb53c8..5feca3242 100644 --- a/src/Form/Fields/SharpFormAutocompleteField.php +++ b/src/Form/Fields/SharpFormAutocompleteField.php @@ -11,32 +11,41 @@ class SharpFormAutocompleteField extends SharpFormField { - use SharpFormFieldWithPlaceholder, SharpFormFieldWithTemplates, - SharpFormFieldWithOptions, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithOptions, + SharpFormFieldWithPlaceholder, SharpFormFieldWithTemplates; const FIELD_TYPE = 'autocomplete'; protected string $mode; + /** @var Collection|array */ protected $localValues = []; + protected array $localSearchKeys = ['value']; + protected string $remoteMethod = 'GET'; + protected ?string $remoteEndpoint = null; + protected string $remoteSearchAttribute = 'query'; + protected string $itemIdAttribute = 'id'; + protected int $searchMinChars = 1; + protected ?array $dynamicAttributes = null; + protected string $dataWrapper = ''; + protected int $debounceDelay = 300; /** - * @param string $key * @param string $mode "local" or "remote" * @return static */ public static function make(string $key, string $mode): self { - $instance = new static($key, static::FIELD_TYPE, new AutocompleteFormatter()); + $instance = new static($key, static::FIELD_TYPE, new AutocompleteFormatter); $instance->mode = $mode; return $instance; diff --git a/src/Form/Fields/SharpFormDateField.php b/src/Form/Fields/SharpFormDateField.php index 226916c39..91f6424e8 100644 --- a/src/Form/Fields/SharpFormDateField.php +++ b/src/Form/Fields/SharpFormDateField.php @@ -9,17 +9,24 @@ class SharpFormDateField extends SharpFormField const FIELD_TYPE = 'date'; protected bool $hasDate = true; + protected bool $hasTime = false; + protected bool $mondayFirst = true; + protected string $minTime = '00:00'; + protected string $maxTime = '23:59'; + protected int $stepTime = 30; + protected ?string $displayFormat = null; + protected ?string $language = null; public static function make(string $key): self { - $field = new static($key, static::FIELD_TYPE, new DateFormatter()); + $field = new static($key, static::FIELD_TYPE, new DateFormatter); $field->language = app()->getLocale(); return $field; @@ -72,7 +79,7 @@ public function setStepTime(int $step): self return $this; } - public function setDisplayFormat(string $displayFormat = null): self + public function setDisplayFormat(?string $displayFormat = null): self { $this->displayFormat = $displayFormat; diff --git a/src/Form/Fields/SharpFormEditorField.php b/src/Form/Fields/SharpFormEditorField.php index ff44baa08..00240ebc9 100644 --- a/src/Form/Fields/SharpFormEditorField.php +++ b/src/Form/Fields/SharpFormEditorField.php @@ -11,42 +11,66 @@ class SharpFormEditorField extends SharpFormField { - use SharpFormFieldWithPlaceholder; - use SharpFormFieldWithUpload; use SharpFormFieldWithDataLocalization; use SharpFormFieldWithEmbeds; use SharpFormFieldWithMaxLength { setMaxLength as protected parentSetMaxLength; } + use SharpFormFieldWithPlaceholder; + use SharpFormFieldWithUpload; const FIELD_TYPE = 'editor'; const B = 'bold'; + const I = 'italic'; + const HIGHLIGHT = 'highlight'; + const SMALL = 'small'; + const UL = 'bullet-list'; + const OL = 'ordered-list'; + const SEPARATOR = '|'; + const A = 'link'; + const H1 = 'heading-1'; + const H2 = 'heading-2'; + const H3 = 'heading-3'; + const CODE = 'code'; + const QUOTE = 'blockquote'; + const UPLOAD_IMAGE = 'upload-image'; + const UPLOAD = 'upload'; + const HR = 'horizontal-rule'; + const TABLE = 'table'; + const IFRAME = 'iframe'; + const RAW_HTML = 'html'; + const CODE_BLOCK = 'code-block'; + const SUP = 'superscript'; + const UNDO = 'undo'; + const REDO = 'redo'; protected int $minHeight = 200; + protected ?int $maxHeight = null; + protected array $toolbar = [ self::B, self::I, self::SEPARATOR, @@ -54,17 +78,21 @@ class SharpFormEditorField extends SharpFormField self::SEPARATOR, self::A, ]; + protected bool $showToolbar = true; + protected bool $renderAsMarkdown = false; + protected bool $withoutParagraphs = false; + protected bool $showCharacterCount = false; public static function make(string $key): self { - return new static($key, static::FIELD_TYPE, new EditorFormatter()); + return new static($key, static::FIELD_TYPE, new EditorFormatter); } - public function setHeight(int $height, int|null $maxHeight = null): self + public function setHeight(int $height, ?int $maxHeight = null): self { $this->minHeight = $height; // Spec maxHeight: diff --git a/src/Form/Fields/SharpFormField.php b/src/Form/Fields/SharpFormField.php index 703e69b25..c97d7c40e 100644 --- a/src/Form/Fields/SharpFormField.php +++ b/src/Form/Fields/SharpFormField.php @@ -9,16 +9,24 @@ abstract class SharpFormField { public string $key; + protected ?string $label = null; + protected string $type; + protected ?string $helpMessage = null; + protected string $conditionalDisplayOperator = 'and'; + protected array $conditionalDisplayFields = []; + protected ?bool $readOnly = null; + protected ?string $extraStyle = null; + protected ?SharpFieldFormatter $formatter; - protected function __construct(string $key, string $type, SharpFieldFormatter $formatter = null) + protected function __construct(string $key, string $type, ?SharpFieldFormatter $formatter = null) { $this->key = $key; $this->type = $type; @@ -91,8 +99,6 @@ public function setFormatter(SharpFieldFormatter $formatter): self /** * Create the properties array for the field, using parent::buildArray(). - * - * @return array */ abstract public function toArray(): array; @@ -119,7 +125,6 @@ protected function validationRules(): array /** * Throw an exception in case of invalid attribute value. * - * @param array $properties * * @throws SharpFormFieldValidationException */ @@ -166,7 +171,7 @@ protected function buildArray(array $childArray): array private function buildConditionalDisplayArray(): ?array { - if (! sizeof($this->conditionalDisplayFields)) { + if (! count($this->conditionalDisplayFields)) { return null; } diff --git a/src/Form/Fields/SharpFormGeolocationField.php b/src/Form/Fields/SharpFormGeolocationField.php index 59654024f..e2009af66 100644 --- a/src/Form/Fields/SharpFormGeolocationField.php +++ b/src/Form/Fields/SharpFormGeolocationField.php @@ -9,13 +9,21 @@ class SharpFormGeolocationField extends SharpFormField const FIELD_TYPE = 'geolocation'; protected string $displayUnit = 'DMS'; + protected bool $geocoding = false; + protected int $zoomLevel = 10; + protected ?array $boundaries = null; + protected ?array $initialPosition = null; + protected string $mapsProvider = 'gmaps'; + protected string $geocodingProvider = 'gmaps'; + protected array $mapsProviderOptions = []; + protected array $geocodingProviderOptions = []; public static function make(string $key): self diff --git a/src/Form/Fields/SharpFormListField.php b/src/Form/Fields/SharpFormListField.php index 26d532b6f..1bcc04380 100644 --- a/src/Form/Fields/SharpFormListField.php +++ b/src/Form/Fields/SharpFormListField.php @@ -12,15 +12,25 @@ class SharpFormListField extends SharpFormField const FIELD_TYPE = 'list'; protected bool $addable = false; + protected bool $sortable = false; + protected bool $removable = false; + protected string $addText; + protected string $itemIdAttribute = 'id'; + protected ?string $orderAttribute = null; + protected ?int $maxItemCount = null; + protected array $itemFields = []; + protected bool $allowBulkUpload = false; + private ?string $bulkUploadItemFieldKey = null; + private int $bulkUploadFileCountLimit = 10; public static function make(string $key): self @@ -63,7 +73,7 @@ public function setOrderAttribute(string $orderAttribute): self return $this; } - public function setMaxItemCount(int $maxItemCount = null): self + public function setMaxItemCount(?int $maxItemCount = null): self { if ($maxItemCount === null) { return $this->setMaxItemCountUnlimited(); diff --git a/src/Form/Fields/SharpFormNumberField.php b/src/Form/Fields/SharpFormNumberField.php index f8b209d5f..08b206360 100644 --- a/src/Form/Fields/SharpFormNumberField.php +++ b/src/Form/Fields/SharpFormNumberField.php @@ -12,8 +12,11 @@ class SharpFormNumberField extends SharpFormField const FIELD_TYPE = 'number'; protected ?float $min = null; + protected ?float $max = null; + protected float $step = 1; + protected bool $showControls = false; public static function make(string $key): self diff --git a/src/Form/Fields/SharpFormSelectField.php b/src/Form/Fields/SharpFormSelectField.php index c8e05b02c..47278d214 100644 --- a/src/Form/Fields/SharpFormSelectField.php +++ b/src/Form/Fields/SharpFormSelectField.php @@ -8,18 +8,26 @@ class SharpFormSelectField extends SharpFormField { - use SharpFormFieldWithOptions, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithOptions; const FIELD_TYPE = 'select'; protected array $options; + protected bool $multiple = false; + protected bool $clearable = false; + protected ?int $maxSelected = null; + protected string $display = 'list'; + protected string $idAttribute = 'id'; + protected bool $inline = false; + protected bool $showSelectAll = false; + protected ?array $dynamicAttributes = null; public static function make(string $key, array $options): self diff --git a/src/Form/Fields/SharpFormTagsField.php b/src/Form/Fields/SharpFormTagsField.php index ca9d9c0e1..10c43447f 100644 --- a/src/Form/Fields/SharpFormTagsField.php +++ b/src/Form/Fields/SharpFormTagsField.php @@ -12,11 +12,17 @@ class SharpFormTagsField extends SharpFormField const FIELD_TYPE = 'tags'; protected bool $creatable = false; + protected string $createText = 'Create'; + protected ?string $createAttribute = null; + protected string $idAttribute = 'id'; + protected ?int $maxTagCount = null; + protected array $options = []; + protected array $createAdditionalAttributes = []; public static function make(string $key, array $options): self diff --git a/src/Form/Fields/SharpFormTextField.php b/src/Form/Fields/SharpFormTextField.php index 5e145f4c6..c5c8f7bd9 100644 --- a/src/Form/Fields/SharpFormTextField.php +++ b/src/Form/Fields/SharpFormTextField.php @@ -9,7 +9,7 @@ class SharpFormTextField extends SharpFormField { - use SharpFormFieldWithPlaceholder, SharpFormFieldWithMaxLength, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithMaxLength, SharpFormFieldWithPlaceholder; const FIELD_TYPE = 'text'; diff --git a/src/Form/Fields/SharpFormTextareaField.php b/src/Form/Fields/SharpFormTextareaField.php index ce2463119..319eb1a52 100644 --- a/src/Form/Fields/SharpFormTextareaField.php +++ b/src/Form/Fields/SharpFormTextareaField.php @@ -9,7 +9,7 @@ class SharpFormTextareaField extends SharpFormField { - use SharpFormFieldWithPlaceholder, SharpFormFieldWithMaxLength, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithMaxLength, SharpFormFieldWithPlaceholder; const FIELD_TYPE = 'textarea'; diff --git a/src/Form/Fields/Utils/SharpFormFieldWithOptions.php b/src/Form/Fields/Utils/SharpFormFieldWithOptions.php index 7eef55462..71a8b08c8 100644 --- a/src/Form/Fields/Utils/SharpFormFieldWithOptions.php +++ b/src/Form/Fields/Utils/SharpFormFieldWithOptions.php @@ -9,12 +9,10 @@ trait SharpFormFieldWithOptions { /** * @param array|Collection $options - * @param string $idAttribute - * @return array */ protected static function formatOptions($options, string $idAttribute = 'id'): array { - if (! sizeof($options)) { + if (! count($options)) { return []; } @@ -37,12 +35,10 @@ protected static function formatOptions($options, string $idAttribute = 'id'): a /** * @param array|Collection $options - * @param int $depth - * @return array */ protected static function formatDynamicOptions(&$options, int $depth): array { - if (! sizeof($options)) { + if (! count($options)) { return []; } diff --git a/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php b/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php index f0a3cf863..ebc671222 100644 --- a/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php +++ b/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php @@ -5,6 +5,7 @@ trait SharpFormFieldWithTemplates { protected array $templates = []; + protected ?array $additionalTemplateData = null; protected function setTemplatePath(string $templatePath, string $key): self diff --git a/src/Form/Fields/Utils/SharpFormFieldWithUpload.php b/src/Form/Fields/Utils/SharpFormFieldWithUpload.php index 8bda8fc57..5b550f072 100644 --- a/src/Form/Fields/Utils/SharpFormFieldWithUpload.php +++ b/src/Form/Fields/Utils/SharpFormFieldWithUpload.php @@ -7,14 +7,23 @@ trait SharpFormFieldWithUpload { protected ?float $maxFileSize = null; + protected ?array $cropRatio = null; + protected ?array $transformableFileTypes = null; + protected string $storageDisk = 'local'; + protected string|Closure $storageBasePath = 'data'; + protected bool $transformable = true; + protected ?bool $transformKeepOriginal = null; + protected bool $compactThumbnail = false; + protected bool $shouldOptimizeImage = false; + protected string|array|null $fileFilter = null; public function setMaxFileSize(float $maxFileSizeInMB): self @@ -24,7 +33,7 @@ public function setMaxFileSize(float $maxFileSizeInMB): self return $this; } - public function setCropRatio(string $ratio = null, ?array $transformableFileTypes = null): self + public function setCropRatio(?string $ratio = null, ?array $transformableFileTypes = null): self { if ($ratio) { $this->cropRatio = explode(':', $ratio); diff --git a/src/Form/Layout/FormLayout.php b/src/Form/Layout/FormLayout.php index 2862b622c..41c92a976 100644 --- a/src/Form/Layout/FormLayout.php +++ b/src/Form/Layout/FormLayout.php @@ -9,9 +9,10 @@ class FormLayout implements HasLayout use Conditionable; protected array $tabs = []; + protected bool $tabbed = true; - final public function addTab(string $label, \Closure $callback = null): self + final public function addTab(string $label, ?\Closure $callback = null): self { $tab = $this->addTabLayout(new FormLayoutTab($label)); @@ -22,7 +23,7 @@ final public function addTab(string $label, \Closure $callback = null): self return $this; } - final public function addColumn(int $size, \Closure $callback = null): self + final public function addColumn(int $size, ?\Closure $callback = null): self { $column = $this ->getLonelyTab() @@ -58,7 +59,7 @@ private function addTabLayout(FormLayoutTab $tab): FormLayoutTab private function getLonelyTab(): FormLayoutTab { - if (! sizeof($this->tabs)) { + if (! count($this->tabs)) { $this->addTabLayout(new FormLayoutTab('one')); } diff --git a/src/Form/Layout/FormLayoutColumn.php b/src/Form/Layout/FormLayoutColumn.php index 55b486c2c..97855e2cc 100644 --- a/src/Form/Layout/FormLayoutColumn.php +++ b/src/Form/Layout/FormLayoutColumn.php @@ -8,7 +8,7 @@ class FormLayoutColumn extends LayoutColumn implements HasLayout { protected array $fieldsets = []; - public function withFieldset(string $name, \Closure $callback = null): self + public function withFieldset(string $name, ?\Closure $callback = null): self { $fieldset = new FormLayoutFieldset($name); diff --git a/src/Form/Layout/FormLayoutTab.php b/src/Form/Layout/FormLayoutTab.php index 68fcba543..457d82a54 100644 --- a/src/Form/Layout/FormLayoutTab.php +++ b/src/Form/Layout/FormLayoutTab.php @@ -5,6 +5,7 @@ class FormLayoutTab implements HasLayout { protected string $title; + protected array $columns = []; public function __construct(string $title) @@ -12,7 +13,7 @@ public function __construct(string $title) $this->title = $title; } - public function addColumn(int $size, \Closure $callback = null): self + public function addColumn(int $size, ?\Closure $callback = null): self { $column = $this->addColumnLayout(new FormLayoutColumn($size)); diff --git a/src/Form/Layout/HasFieldRows.php b/src/Form/Layout/HasFieldRows.php index 45f6ccebb..81b979cd4 100644 --- a/src/Form/Layout/HasFieldRows.php +++ b/src/Form/Layout/HasFieldRows.php @@ -11,7 +11,7 @@ trait HasFieldRows protected array $rows = []; - public function withSingleField(string $fieldKey, \Closure $subLayoutCallback = null): self + public function withSingleField(string $fieldKey, ?\Closure $subLayoutCallback = null): self { $this->addRowLayout([ $this->newLayoutField($fieldKey, $subLayoutCallback), @@ -32,7 +32,7 @@ public function withFields(string ...$fieldKeys): self return $this; } - public function insertSingleFieldAt(int $index, string $fieldKey, \Closure $subLayoutCallback = null): self + public function insertSingleFieldAt(int $index, string $fieldKey, ?\Closure $subLayoutCallback = null): self { $rows = collect($this->rows); $rows->splice($index, 0, [[$this->newLayoutField($fieldKey, $subLayoutCallback)]]); @@ -74,7 +74,7 @@ public function fieldsToArray(): array ]; } - protected function newLayoutField(string $fieldKey, \Closure $subLayoutCallback = null): LayoutField + protected function newLayoutField(string $fieldKey, ?\Closure $subLayoutCallback = null): LayoutField { return new FormLayoutField($fieldKey, $subLayoutCallback); } diff --git a/src/Form/SharpForm.php b/src/Form/SharpForm.php index 554d94452..254a5b425 100644 --- a/src/Form/SharpForm.php +++ b/src/Form/SharpForm.php @@ -14,21 +14,24 @@ abstract class SharpForm { - use WithCustomTransformers, + use HandleCustomBreadcrumb, HandleFormFields, + HandleLocalizedFields, HandlePageAlertMessage, - HandleCustomBreadcrumb, - HandleLocalizedFields; + WithCustomTransformers; protected ?FormLayout $formLayout = null; + protected bool $displayShowPageAfterCreation = false; + protected ?string $deleteConfirmationText = null; + protected ?string $formValidatorClass = null; final public function formLayout(): array { if ($this->formLayout === null) { - $this->formLayout = new FormLayout(); + $this->formLayout = new FormLayout; $this->buildFormLayout($this->formLayout); } @@ -74,7 +77,7 @@ final public function newInstance(): ?array ) ->all(); - return sizeof($data) ? $data : null; + return count($data) ? $data : null; } final public function validateRequest(string $entityKey): void @@ -85,9 +88,7 @@ final public function validateRequest(string $entityKey): void } } - public function buildFormConfig(): void - { - } + public function buildFormConfig(): void {} /** * @deprecated @@ -209,9 +210,7 @@ abstract public function update(mixed $id, array $data); * @deprecated * Use delete() in Show Page or in Entity List. Will be removed in v9. */ - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} /** * Build form fields. diff --git a/src/Http/Api/Commands/DashboardCommandController.php b/src/Http/Api/Commands/DashboardCommandController.php index d427db7f1..f288f7fa8 100644 --- a/src/Http/Api/Commands/DashboardCommandController.php +++ b/src/Http/Api/Commands/DashboardCommandController.php @@ -9,7 +9,7 @@ class DashboardCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey) { @@ -47,7 +47,7 @@ protected function getCommandHandler(SharpDashboard $dashboard, string $commandK $handler->buildCommandConfig(); if (! $handler->authorize()) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } $handler->initQueryParams(DashboardQueryParams::create()->fillWithRequest()); diff --git a/src/Http/Api/Commands/EntityListEntityCommandController.php b/src/Http/Api/Commands/EntityListEntityCommandController.php index fe49efbd2..14556ef1a 100644 --- a/src/Http/Api/Commands/EntityListEntityCommandController.php +++ b/src/Http/Api/Commands/EntityListEntityCommandController.php @@ -10,7 +10,7 @@ class EntityListEntityCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey) { @@ -51,7 +51,7 @@ protected function getCommandHandler(SharpEntityList $list, string $commandKey): $commandHandler->initQueryParams(EntityListQueryParams::create()->fillWithRequest()); if (! $commandHandler->authorize()) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $commandHandler; diff --git a/src/Http/Api/Commands/EntityListInstanceCommandController.php b/src/Http/Api/Commands/EntityListInstanceCommandController.php index 3c73bd5ff..db7b310bf 100644 --- a/src/Http/Api/Commands/EntityListInstanceCommandController.php +++ b/src/Http/Api/Commands/EntityListInstanceCommandController.php @@ -6,7 +6,7 @@ class EntityListInstanceCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey, mixed $instanceId) { diff --git a/src/Http/Api/Commands/EntityListInstanceStateController.php b/src/Http/Api/Commands/EntityListInstanceStateController.php index 890331d5b..cef0a39c3 100644 --- a/src/Http/Api/Commands/EntityListInstanceStateController.php +++ b/src/Http/Api/Commands/EntityListInstanceStateController.php @@ -17,7 +17,7 @@ public function update(string $entityKey, mixed $instanceId) if (! $list->entityStateHandler()->authorize() || ! $list->entityStateHandler()->authorizeFor($instanceId)) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $this->returnCommandResult( diff --git a/src/Http/Api/Commands/HandleCommandReturn.php b/src/Http/Api/Commands/HandleCommandReturn.php index 127071dfc..095852b56 100644 --- a/src/Http/Api/Commands/HandleCommandReturn.php +++ b/src/Http/Api/Commands/HandleCommandReturn.php @@ -46,7 +46,7 @@ protected function getInstanceCommandHandler(SharpEntityList|SharpShow $commandC $commandHandler->buildCommandConfig(); if (! $commandHandler->authorize() || ! $commandHandler->authorizeFor($instanceId)) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $commandHandler; diff --git a/src/Http/Api/Commands/ShowInstanceCommandController.php b/src/Http/Api/Commands/ShowInstanceCommandController.php index 9001445d3..397e6adfc 100644 --- a/src/Http/Api/Commands/ShowInstanceCommandController.php +++ b/src/Http/Api/Commands/ShowInstanceCommandController.php @@ -7,7 +7,7 @@ class ShowInstanceCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey, mixed $instanceId = null) { diff --git a/src/Http/Api/Commands/ShowInstanceStateController.php b/src/Http/Api/Commands/ShowInstanceStateController.php index 8fd46e0f7..1619d0948 100644 --- a/src/Http/Api/Commands/ShowInstanceStateController.php +++ b/src/Http/Api/Commands/ShowInstanceStateController.php @@ -17,7 +17,7 @@ public function update(string $entityKey, mixed $instanceId = null) if (! $stateHandler->authorize() || ! $stateHandler->authorizeFor($instanceId)) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $this->returnCommandResult( diff --git a/src/Http/Api/EntityListController.php b/src/Http/Api/EntityListController.php index ab527efcf..de7648013 100644 --- a/src/Http/Api/EntityListController.php +++ b/src/Http/Api/EntityListController.php @@ -45,7 +45,7 @@ public function update(string $entityKey) ]); } - public function delete(string $entityKey, string $instanceId = null) + public function delete(string $entityKey, ?string $instanceId = null) { sharp_check_ability('delete', $entityKey, $instanceId); diff --git a/src/Http/Api/FormController.php b/src/Http/Api/FormController.php index 21703803d..79c4bd729 100644 --- a/src/Http/Api/FormController.php +++ b/src/Http/Api/FormController.php @@ -7,7 +7,7 @@ class FormController extends ApiController { - public function edit(string $entityKey, string $instanceId = null) + public function edit(string $entityKey, ?string $instanceId = null) { sharp_check_ability( $this->entityManager->entityFor($entityKey)->hasShow() ? 'update' : 'view', @@ -56,7 +56,7 @@ public function create(string $entityKey) ); } - public function update(string $entityKey, string $instanceId = null) + public function update(string $entityKey, ?string $instanceId = null) { sharp_check_ability('update', $entityKey, $instanceId); diff --git a/src/Http/Api/ShowController.php b/src/Http/Api/ShowController.php index 7633fcbb9..1ff474151 100644 --- a/src/Http/Api/ShowController.php +++ b/src/Http/Api/ShowController.php @@ -7,7 +7,7 @@ class ShowController extends ApiController { - public function show(string $entityKey, string $instanceId = null) + public function show(string $entityKey, ?string $instanceId = null) { sharp_check_ability('view', $entityKey, $instanceId); diff --git a/src/Http/Context/CurrentSharpRequest.php b/src/Http/Context/CurrentSharpRequest.php index 9997b1dd8..b09225a8a 100644 --- a/src/Http/Context/CurrentSharpRequest.php +++ b/src/Http/Context/CurrentSharpRequest.php @@ -71,7 +71,7 @@ public function getUrlForBreadcrumb(Collection $breadcrumb): string ); } - public function getUrlOfPreviousBreadcrumbItem(string $type = null): string + public function getUrlOfPreviousBreadcrumbItem(?string $type = null): string { $breadcrumb = $this->breadcrumb()->slice(0, -1); if ($type) { @@ -159,7 +159,7 @@ final public function globalFilterFor(string $handlerClass): array|string|null private function buildBreadcrumb(): void { - $this->breadcrumb = new Collection(); + $this->breadcrumb = new Collection; $segments = $this->getSegmentsFromRequest(); $depth = 0; diff --git a/src/Http/Context/Util/BreadcrumbItem.php b/src/Http/Context/Util/BreadcrumbItem.php index e9c5e3bc9..c35aba6cd 100644 --- a/src/Http/Context/Util/BreadcrumbItem.php +++ b/src/Http/Context/Util/BreadcrumbItem.php @@ -7,8 +7,11 @@ class BreadcrumbItem { public string $type; + public string $key; + public ?string $instance = null; + public int $depth = 0; public function __construct(string $type, string $key) diff --git a/src/Http/LangController.php b/src/Http/LangController.php index 658fbcf10..a1dc1cb46 100644 --- a/src/Http/LangController.php +++ b/src/Http/LangController.php @@ -17,7 +17,7 @@ public function index(Request $request) $lang = $request->has('locale') ? $request->input('locale') : app()->getLocale(); $version = sharp_version(); - $strings = Cache::rememberForever("sharp.lang.$lang.$version.js", function () use($lang) { + $strings = Cache::rememberForever("sharp.lang.$lang.$version.js", function () use ($lang) { $localizationStrings = []; $files = [ 'action_bar', @@ -30,7 +30,7 @@ public function index(Request $request) ]; collect($files) - ->map(function (string $filename) use($lang) { + ->map(function (string $filename) use ($lang) { return collect(trans("sharp-front::$filename", [], $lang)) ->mapWithKeys(function ($value, $key) use ($filename) { return ["$filename.$key" => $value]; diff --git a/src/Http/Middleware/Api/AppendBreadcrumb.php b/src/Http/Middleware/Api/AppendBreadcrumb.php index 57f38ccd0..e63f8255c 100644 --- a/src/Http/Middleware/Api/AppendBreadcrumb.php +++ b/src/Http/Middleware/Api/AppendBreadcrumb.php @@ -18,6 +18,7 @@ class AppendBreadcrumb { protected CurrentSharpRequest $currentSharpRequest; + protected ?object $data = null; public function __construct(CurrentSharpRequest $currentSharpRequest) @@ -49,7 +50,7 @@ protected function addBreadcrumbToJsonResponse(JsonResponse $jsonResponse): Json $item->type, isset($item->instance) ? "{$item->key}/{$item->instance}" : $item->key, ); - $isLeaf = $index === sizeof($breadcrumb) - 1; + $isLeaf = $index === count($breadcrumb) - 1; return [ 'type' => $this->getFrontTypeNameFor($item->type), diff --git a/src/Http/Middleware/Api/AppendInstanceAuthorizations.php b/src/Http/Middleware/Api/AppendInstanceAuthorizations.php index e66abfbd2..72f69d647 100644 --- a/src/Http/Middleware/Api/AppendInstanceAuthorizations.php +++ b/src/Http/Middleware/Api/AppendInstanceAuthorizations.php @@ -12,9 +12,7 @@ */ class AppendInstanceAuthorizations { - public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) - { - } + public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) {} public function handle(Request $request, Closure $next) { diff --git a/src/Http/Middleware/Api/AppendListAuthorizations.php b/src/Http/Middleware/Api/AppendListAuthorizations.php index b98a9000d..9e98b8357 100644 --- a/src/Http/Middleware/Api/AppendListAuthorizations.php +++ b/src/Http/Middleware/Api/AppendListAuthorizations.php @@ -9,9 +9,7 @@ class AppendListAuthorizations { - public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) - { - } + public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) {} public function handle(Request $request, Closure $next) { diff --git a/src/Http/Middleware/Api/AppendMultiformInEntityList.php b/src/Http/Middleware/Api/AppendMultiformInEntityList.php index 0c68a98a6..82ad196fc 100644 --- a/src/Http/Middleware/Api/AppendMultiformInEntityList.php +++ b/src/Http/Middleware/Api/AppendMultiformInEntityList.php @@ -10,9 +10,7 @@ class AppendMultiformInEntityList { - public function __construct(protected SharpEntityManager $sharpEntityManager) - { - } + public function __construct(protected SharpEntityManager $sharpEntityManager) {} public function handle(Request $request, Closure $next) { @@ -45,13 +43,13 @@ protected function addMultiformDataToJsonResponse(JsonResponse $jsonResponse): J return [ 'key' => $key, - 'label' => is_array($value) && sizeof($value) > 1 ? $value[1] : $key, + 'label' => is_array($value) && count($value) > 1 ? $value[1] : $key, 'instances' => $instanceIds, ]; }) ->keyBy('key'); - if (sizeof($subFormKeys)) { + if (count($subFormKeys)) { $jsonData->forms = $subFormKeys; $jsonResponse->setData($jsonData); } diff --git a/src/Http/Middleware/Api/AppendNotifications.php b/src/Http/Middleware/Api/AppendNotifications.php index e1decb590..21f14cd98 100644 --- a/src/Http/Middleware/Api/AppendNotifications.php +++ b/src/Http/Middleware/Api/AppendNotifications.php @@ -9,8 +9,6 @@ class AppendNotifications { /** - * @param Request $request - * @param Closure $next * @return JsonResponse */ public function handle(Request $request, Closure $next) diff --git a/src/Http/Middleware/Api/HandleSharpApiErrors.php b/src/Http/Middleware/Api/HandleSharpApiErrors.php index 4cc51be01..b4fdaef16 100644 --- a/src/Http/Middleware/Api/HandleSharpApiErrors.php +++ b/src/Http/Middleware/Api/HandleSharpApiErrors.php @@ -69,7 +69,6 @@ private function getHttpCodeFor($exception) } /** - * @param $response * @return JsonResponse */ protected function handleValidationException($response) diff --git a/src/Http/Middleware/SharpRedirectIfAuthenticated.php b/src/Http/Middleware/SharpRedirectIfAuthenticated.php index ff9d68638..8a1792d00 100644 --- a/src/Http/Middleware/SharpRedirectIfAuthenticated.php +++ b/src/Http/Middleware/SharpRedirectIfAuthenticated.php @@ -10,7 +10,6 @@ class SharpRedirectIfAuthenticated * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next * @param string|null $guard * @return mixed */ diff --git a/src/Http/Requests/LoginRequest.php b/src/Http/Requests/LoginRequest.php index 43656c39d..4851e19fd 100644 --- a/src/Http/Requests/LoginRequest.php +++ b/src/Http/Requests/LoginRequest.php @@ -62,7 +62,7 @@ private function attemptToLogin(bool $remember): bool if ($handler->isEnabledFor($guard->user())) { $handler->setUser($guard->user())->generateCode($remember); - throw new SharpAuthenticationNeeds2faException(); + throw new SharpAuthenticationNeeds2faException; } // 2fa is not enabled for this user, we can proceed with the login diff --git a/src/Search/ResultLink.php b/src/Search/ResultLink.php index aa33c01fb..540990d7f 100644 --- a/src/Search/ResultLink.php +++ b/src/Search/ResultLink.php @@ -10,8 +10,7 @@ public function __construct( protected SharpLinkTo $link, protected string $label, protected ?string $detail = null - ) { - } + ) {} public function toArray(): array { diff --git a/src/Search/SearchResultSet.php b/src/Search/SearchResultSet.php index 21eb4fbf3..7bac7828a 100644 --- a/src/Search/SearchResultSet.php +++ b/src/Search/SearchResultSet.php @@ -7,13 +7,14 @@ class SearchResultSet { protected array $resultLinks = []; + protected ?string $emptyStateLabel = null; + protected array $validationErrors = []; + protected bool $hideWhenEmpty = false; - public function __construct(protected string $label, protected ?string $icon = null) - { - } + public function __construct(protected string $label, protected ?string $icon = null) {} final public function addResultLink(SharpLinkTo $link, string $label, ?string $detail = null): ResultLink { diff --git a/src/Show/Fields/SharpShowEntityListField.php b/src/Show/Fields/SharpShowEntityListField.php index 30e8f0d87..4669f766b 100644 --- a/src/Show/Fields/SharpShowEntityListField.php +++ b/src/Show/Fields/SharpShowEntityListField.php @@ -9,16 +9,24 @@ class SharpShowEntityListField extends SharpShowField const FIELD_TYPE = 'entityList'; protected string $entityListKey; + protected array $hiddenFilters = []; + protected array $hiddenCommands = [ 'entity' => [], 'instance' => [], ]; + protected bool $showEntityState = true; + protected bool $showReorderButton = true; + protected bool $showCreateButton = true; + protected bool $showSearchField = true; + protected bool $showCount = false; + protected ?string $label = null; public static function make(string $key, ?string $entityListKey = null): SharpShowEntityListField @@ -128,7 +136,7 @@ public function toArray(): array 'showSearchField' => $this->showSearchField, 'showCount' => $this->showCount, 'hiddenCommands' => $this->hiddenCommands, - 'hiddenFilters' => sizeof($this->hiddenFilters) + 'hiddenFilters' => count($this->hiddenFilters) ? collect($this->hiddenFilters) ->map(function ($value) { // Filter value can be a Closure diff --git a/src/Show/Fields/SharpShowField.php b/src/Show/Fields/SharpShowField.php index 1b1951b71..e7853ddf8 100644 --- a/src/Show/Fields/SharpShowField.php +++ b/src/Show/Fields/SharpShowField.php @@ -8,7 +8,9 @@ abstract class SharpShowField { public string $key; + protected string $type; + protected bool $emptyVisible = false; protected function __construct(string $key, string $type) @@ -45,7 +47,6 @@ protected function buildArray(array $childArray): array /** * Throw an exception in case of invalid attribute value. * - * @param array $properties * * @throws SharpShowFieldValidationException */ diff --git a/src/Show/Fields/SharpShowFileField.php b/src/Show/Fields/SharpShowFileField.php index 1d4a18c0a..7f973cc60 100644 --- a/src/Show/Fields/SharpShowFileField.php +++ b/src/Show/Fields/SharpShowFileField.php @@ -7,7 +7,9 @@ class SharpShowFileField extends SharpShowField const FIELD_TYPE = 'file'; protected ?string $label = null; + protected string $storageDisk = 'local'; + protected string $storageBasePath = 'data'; public static function make(string $key): SharpShowFileField diff --git a/src/Show/Fields/SharpShowListField.php b/src/Show/Fields/SharpShowListField.php index 8d82ec3aa..420a7c0d4 100644 --- a/src/Show/Fields/SharpShowListField.php +++ b/src/Show/Fields/SharpShowListField.php @@ -7,6 +7,7 @@ class SharpShowListField extends SharpShowField const FIELD_TYPE = 'list'; protected ?string $label = null; + protected array $itemFields = []; public static function make(string $key): SharpShowListField diff --git a/src/Show/Fields/SharpShowTextField.php b/src/Show/Fields/SharpShowTextField.php index be7148449..a1f97a158 100644 --- a/src/Show/Fields/SharpShowTextField.php +++ b/src/Show/Fields/SharpShowTextField.php @@ -13,7 +13,9 @@ class SharpShowTextField extends SharpShowField const FIELD_TYPE = 'text'; protected ?string $label = null; + protected ?int $collapseToWordCount = null; + protected bool $html = true; public static function make(string $key): SharpShowTextField diff --git a/src/Show/Layout/ShowLayout.php b/src/Show/Layout/ShowLayout.php index 3b6d8f131..e6ee169f0 100644 --- a/src/Show/Layout/ShowLayout.php +++ b/src/Show/Layout/ShowLayout.php @@ -11,7 +11,7 @@ class ShowLayout implements HasLayout protected array $sections = []; - final public function addSection(string $label, \Closure $callback = null): self + final public function addSection(string $label, ?\Closure $callback = null): self { $section = new ShowLayoutSection($label); $this->sections[] = $section; diff --git a/src/Show/Layout/ShowLayoutColumn.php b/src/Show/Layout/ShowLayoutColumn.php index 2385016d4..cdfb90e36 100644 --- a/src/Show/Layout/ShowLayoutColumn.php +++ b/src/Show/Layout/ShowLayoutColumn.php @@ -11,11 +11,9 @@ class ShowLayoutColumn extends LayoutColumn implements HasLayout /** * Override HasLayout::newLayoutField. * - * @param string $fieldKey - * @param \Closure|null $subLayoutCallback * @return \Code16\Sharp\Form\Layout\FormLayoutField|ShowLayoutField */ - protected function newLayoutField(string $fieldKey, \Closure $subLayoutCallback = null): LayoutField + protected function newLayoutField(string $fieldKey, ?\Closure $subLayoutCallback = null): LayoutField { return new ShowLayoutField($fieldKey, $subLayoutCallback); } diff --git a/src/Show/Layout/ShowLayoutSection.php b/src/Show/Layout/ShowLayoutSection.php index f8334a077..c148984cb 100644 --- a/src/Show/Layout/ShowLayoutSection.php +++ b/src/Show/Layout/ShowLayoutSection.php @@ -7,8 +7,11 @@ class ShowLayoutSection implements HasLayout { protected ?string $title = null; + protected array $columns = []; + protected bool $collapsable = false; + protected ?string $sectionKey = null; public function __construct(string $title) @@ -16,7 +19,7 @@ public function __construct(string $title) $this->title = $title; } - public function addColumn(int $size, \Closure $callback = null): self + public function addColumn(int $size, ?\Closure $callback = null): self { $column = $this->addColumnLayout(new ShowLayoutColumn($size)); diff --git a/src/Show/SharpShow.php b/src/Show/SharpShow.php index a99648c3e..aea427a48 100644 --- a/src/Show/SharpShow.php +++ b/src/Show/SharpShow.php @@ -15,23 +15,26 @@ abstract class SharpShow { - use WithCustomTransformers, - HandleFields, + use HandleCustomBreadcrumb, HandleEntityState, + HandleFields, HandleInstanceCommands, + HandleLocalizedFields, HandlePageAlertMessage, - HandleCustomBreadcrumb, - HandleLocalizedFields; + WithCustomTransformers; protected ?ShowLayout $showLayout = null; + protected ?string $multiformAttribute = null; + protected ?SharpShowTextField $pageTitleField = null; + protected ?string $deleteConfirmationText = null; final public function showLayout(): array { if ($this->showLayout === null) { - $this->showLayout = new ShowLayout(); + $this->showLayout = new ShowLayout; $this->buildShowLayout($this->showLayout); } diff --git a/src/Utils/Entities/BaseSharpEntity.php b/src/Utils/Entities/BaseSharpEntity.php index 6e91db4be..bd91619b7 100644 --- a/src/Utils/Entities/BaseSharpEntity.php +++ b/src/Utils/Entities/BaseSharpEntity.php @@ -8,8 +8,11 @@ abstract class BaseSharpEntity { protected bool $isDashboard = false; + protected string $entityKey = 'entity'; + protected ?string $policy = null; + protected string $label = 'entity'; final public function setEntityKey(string $entityKey): self @@ -22,7 +25,7 @@ final public function setEntityKey(string $entityKey): self final public function getPolicyOrDefault(): SharpEntityPolicy { if (! $policy = $this->getPolicy()) { - return new SharpEntityPolicy(); + return new SharpEntityPolicy; } if (is_string($policy)) { diff --git a/src/Utils/Entities/SharpDashboardEntity.php b/src/Utils/Entities/SharpDashboardEntity.php index b089ed5cf..94c9a1a4f 100644 --- a/src/Utils/Entities/SharpDashboardEntity.php +++ b/src/Utils/Entities/SharpDashboardEntity.php @@ -8,6 +8,7 @@ abstract class SharpDashboardEntity extends BaseSharpEntity { protected bool $isDashboard = true; + protected ?string $view = null; final public function getViewOrFail(): SharpDashboard diff --git a/src/Utils/Entities/SharpEntity.php b/src/Utils/Entities/SharpEntity.php index 0fde6d15f..294f91c54 100644 --- a/src/Utils/Entities/SharpEntity.php +++ b/src/Utils/Entities/SharpEntity.php @@ -10,9 +10,13 @@ abstract class SharpEntity extends BaseSharpEntity { protected bool $isSingle = false; + protected ?string $list = null; + protected ?string $form = null; + protected ?string $show = null; + protected array $prohibitedActions = []; final public function getListOrFail(): SharpEntityList diff --git a/src/Utils/Entities/SharpEntityManager.php b/src/Utils/Entities/SharpEntityManager.php index 52f28abf4..b3f4c3f1f 100644 --- a/src/Utils/Entities/SharpEntityManager.php +++ b/src/Utils/Entities/SharpEntityManager.php @@ -28,7 +28,7 @@ public function entityFor(string $entityKey): SharpEntity|SharpDashboardEntity if (isset($entity)) { if (! app()->bound($entity)) { app()->singleton($entity, function () use ($entity, $entityKey) { - return (new $entity())->setEntityKey($entityKey); + return (new $entity)->setEntityKey($entityKey); }); } diff --git a/src/Utils/Fields/HandleFields.php b/src/Utils/Fields/HandleFields.php index 8025e0948..23cd9429c 100644 --- a/src/Utils/Fields/HandleFields.php +++ b/src/Utils/Fields/HandleFields.php @@ -8,12 +8,13 @@ trait HandleFields { protected ?FieldsContainer $fieldsContainer = null; + protected bool $formBuilt = false; final public function fieldsContainer(): FieldsContainer { if ($this->fieldsContainer === null) { - $this->fieldsContainer = new FieldsContainer(); + $this->fieldsContainer = new FieldsContainer; } return $this->fieldsContainer; diff --git a/src/Utils/Filters/CheckFilter.php b/src/Utils/Filters/CheckFilter.php index f05fe953c..3a924fe45 100644 --- a/src/Utils/Filters/CheckFilter.php +++ b/src/Utils/Filters/CheckFilter.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Utils\Filters; -abstract class CheckFilter extends Filter -{ -} +abstract class CheckFilter extends Filter {} diff --git a/src/Utils/Filters/DateRangeFilter.php b/src/Utils/Filters/DateRangeFilter.php index 07a5f1a2a..cfbd203f6 100644 --- a/src/Utils/Filters/DateRangeFilter.php +++ b/src/Utils/Filters/DateRangeFilter.php @@ -5,6 +5,7 @@ abstract class DateRangeFilter extends Filter { private string $dateFormat = 'YYYY-MM-DD'; + private bool $isMondayFirst = true; final public function configureDateFormat(string $dateFormat): self diff --git a/src/Utils/Filters/Filter.php b/src/Utils/Filters/Filter.php index 59442f614..aba5172fb 100644 --- a/src/Utils/Filters/Filter.php +++ b/src/Utils/Filters/Filter.php @@ -5,7 +5,9 @@ abstract class Filter { protected ?string $customKey = null; + protected ?string $label = null; + protected bool $retainInSession = false; public function getKey(): string @@ -44,7 +46,5 @@ public function configureRetainInSession(bool $retainInSession = true): self return $this; } - public function buildFilterConfig(): void - { - } + public function buildFilterConfig(): void {} } diff --git a/src/Utils/Filters/HasFiltersInQuery.php b/src/Utils/Filters/HasFiltersInQuery.php index e5cc2ca41..6b2e1353f 100644 --- a/src/Utils/Filters/HasFiltersInQuery.php +++ b/src/Utils/Filters/HasFiltersInQuery.php @@ -53,7 +53,7 @@ public function setDefaultFilters(array $filters): self return $this; } - protected function fillFilterWithRequest(array $query = null): void + protected function fillFilterWithRequest(?array $query = null): void { collect($query) ->filter(function ($value, $name) { diff --git a/src/Utils/Filters/SelectFilter.php b/src/Utils/Filters/SelectFilter.php index 3cec24d93..344e08b21 100644 --- a/src/Utils/Filters/SelectFilter.php +++ b/src/Utils/Filters/SelectFilter.php @@ -5,8 +5,11 @@ abstract class SelectFilter extends Filter { private bool $isMaster = false; + private bool $isSearchable = false; + private array $searchKeys = ['label']; + private string $template = '{{label}}'; final public function isMaster(): bool diff --git a/src/Utils/Filters/SelectMultipleFilter.php b/src/Utils/Filters/SelectMultipleFilter.php index 86bed8cbc..56a7c178a 100644 --- a/src/Utils/Filters/SelectMultipleFilter.php +++ b/src/Utils/Filters/SelectMultipleFilter.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Utils\Filters; -abstract class SelectMultipleFilter extends SelectFilter -{ -} +abstract class SelectMultipleFilter extends SelectFilter {} diff --git a/src/Utils/Layout/LayoutField.php b/src/Utils/Layout/LayoutField.php index 38bd6d248..eb4e9dbce 100644 --- a/src/Utils/Layout/LayoutField.php +++ b/src/Utils/Layout/LayoutField.php @@ -5,11 +5,14 @@ abstract class LayoutField { protected string $fieldKey; + protected int $size = 12; + protected int $sizeXS = 12; + protected array $itemLayout = []; - public function __construct(string $fieldKey, \Closure $subLayoutCallback = null) + public function __construct(string $fieldKey, ?\Closure $subLayoutCallback = null) { if (strpos($fieldKey, '|')) { [$this->fieldKey, $sizes] = explode('|', $fieldKey); diff --git a/src/Utils/Links/LinkToEntityList.php b/src/Utils/Links/LinkToEntityList.php index 4edd5f312..1d96d11c1 100644 --- a/src/Utils/Links/LinkToEntityList.php +++ b/src/Utils/Links/LinkToEntityList.php @@ -8,9 +8,13 @@ class LinkToEntityList extends SharpLinkTo { protected array $filters = []; + protected ?string $searchText = null; + protected ?string $sortAttribute = null; + protected ?string $sortDir = null; + protected ?array $fullQuerystring = null; public static function make(string $entityKey): self diff --git a/src/Utils/Links/LinkToShowPage.php b/src/Utils/Links/LinkToShowPage.php index 0d307f01e..1b771c6ae 100644 --- a/src/Utils/Links/LinkToShowPage.php +++ b/src/Utils/Links/LinkToShowPage.php @@ -7,6 +7,7 @@ class LinkToShowPage extends SharpLinkTo { protected string $instanceId; + protected BreadcrumbBuilder $breadcrumbBuilder; public static function make(string $entityKey, string $instanceId): self @@ -19,7 +20,7 @@ public static function make(string $entityKey, string $instanceId): self public function withBreadcrumb(Closure $closure): self { - $this->breadcrumbBuilder = $closure(new BreadcrumbBuilder()); + $this->breadcrumbBuilder = $closure(new BreadcrumbBuilder); return $this; } diff --git a/src/Utils/Links/SharpLinkTo.php b/src/Utils/Links/SharpLinkTo.php index 150ffa33f..6369950eb 100644 --- a/src/Utils/Links/SharpLinkTo.php +++ b/src/Utils/Links/SharpLinkTo.php @@ -5,6 +5,7 @@ abstract class SharpLinkTo { protected string $entityKey; + protected string $tooltip = ''; protected function __construct(string $entityKey) diff --git a/src/Utils/Menu/SharpMenu.php b/src/Utils/Menu/SharpMenu.php index f432d94fa..1d604ce03 100644 --- a/src/Utils/Menu/SharpMenu.php +++ b/src/Utils/Menu/SharpMenu.php @@ -10,6 +10,7 @@ abstract class SharpMenu use HasSharpMenuItems; protected ?SharpMenuUserMenu $userMenu = null; + private bool $visible = true; final public function addSection(string $title, Closure $callbackClosure): self @@ -23,7 +24,7 @@ final public function addSection(string $title, Closure $callbackClosure): self final public function setUserMenu(Closure $callbackClosure): self { - $this->userMenu = new SharpMenuUserMenu(); + $this->userMenu = new SharpMenuUserMenu; $callbackClosure($this->userMenu); return $this; diff --git a/src/Utils/Menu/SharpMenuItemLink.php b/src/Utils/Menu/SharpMenuItemLink.php index 0e8516d2d..28a4a8adb 100644 --- a/src/Utils/Menu/SharpMenuItemLink.php +++ b/src/Utils/Menu/SharpMenuItemLink.php @@ -9,12 +9,12 @@ class SharpMenuItemLink extends SharpMenuItem { protected SharpEntity|SharpDashboardEntity|null $entity; + protected ?string $entityKey = null; + protected ?string $url = null; - public function __construct(protected ?string $label, protected ?string $icon) - { - } + public function __construct(protected ?string $label, protected ?string $icon) {} public function setEntity(string $entityKey): self { diff --git a/src/Utils/Menu/SharpMenuItemSection.php b/src/Utils/Menu/SharpMenuItemSection.php index c91d807f2..e71d01144 100644 --- a/src/Utils/Menu/SharpMenuItemSection.php +++ b/src/Utils/Menu/SharpMenuItemSection.php @@ -8,9 +8,7 @@ class SharpMenuItemSection extends SharpMenuItem protected bool $collapsible = true; - public function __construct(protected string $label) - { - } + public function __construct(protected string $label) {} public function getLabel(): string { diff --git a/src/Utils/Menu/SharpMenuItemSeparator.php b/src/Utils/Menu/SharpMenuItemSeparator.php index cf0c34a34..96a8d5d2e 100644 --- a/src/Utils/Menu/SharpMenuItemSeparator.php +++ b/src/Utils/Menu/SharpMenuItemSeparator.php @@ -4,9 +4,7 @@ class SharpMenuItemSeparator extends SharpMenuItem { - public function __construct(protected string $label) - { - } + public function __construct(protected string $label) {} public function getLabel(): string { diff --git a/src/Utils/Traits/HandlePageAlertMessage.php b/src/Utils/Traits/HandlePageAlertMessage.php index 0cb4c9bc6..83c182c35 100644 --- a/src/Utils/Traits/HandlePageAlertMessage.php +++ b/src/Utils/Traits/HandlePageAlertMessage.php @@ -7,16 +7,22 @@ trait HandlePageAlertMessage { protected ?SharpShowHtmlField $pageAlertHtmlField = null; + protected string $pageAlertLevel; protected static string $pageAlertLevelNone = 'none'; + protected static string $pageAlertLevelInfo = 'info'; + protected static string $pageAlertLevelWarning = 'warning'; + protected static string $pageAlertLevelDanger = 'danger'; + protected static string $pageAlertLevelPrimary = 'primary'; + protected static string $pageAlertLevelSecondary = 'secondary'; - protected function configurePageAlert(string $template, string $alertLevel = null, string $fieldKey = null, bool $declareTemplateAsPath = false): self + protected function configurePageAlert(string $template, ?string $alertLevel = null, ?string $fieldKey = null, bool $declareTemplateAsPath = false): self { $this->pageAlertHtmlField = SharpShowHtmlField::make($fieldKey ?: uniqid('f')); $this->pageAlertLevel = $alertLevel ?? static::$pageAlertLevelNone; diff --git a/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php b/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php index 81d257b69..e2069be5d 100644 --- a/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php +++ b/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php @@ -18,8 +18,7 @@ public function __construct( protected ?int $width = null, protected ?int $height = null, protected array $filters = [] - ) { - } + ) {} public function renderAsImageTag(bool $renderAsImageTag = true): self { diff --git a/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php b/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php index 5034718fc..fae03b4d8 100644 --- a/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php +++ b/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php @@ -31,8 +31,8 @@ public function apply($value, $instance = null, $attribute = null) 'soft_break' => $this->nl2br ? '
' : "\n", ], ]); - $environment->addExtension(new CommonMarkCoreExtension()); - $environment->addExtension(new TableExtension()); + $environment->addExtension(new CommonMarkCoreExtension); + $environment->addExtension(new TableExtension); $converter = new MarkdownConverter($environment); diff --git a/src/Utils/Transformers/SharpAttributeTransformer.php b/src/Utils/Transformers/SharpAttributeTransformer.php index e6c6005a2..405a28ff7 100644 --- a/src/Utils/Transformers/SharpAttributeTransformer.php +++ b/src/Utils/Transformers/SharpAttributeTransformer.php @@ -7,8 +7,6 @@ interface SharpAttributeTransformer /** * Transform a model attribute to array (json-able). * - * @param $value - * @param $instance * @param string $attribute * @return mixed */ diff --git a/src/Utils/Transformers/WithCustomTransformers.php b/src/Utils/Transformers/WithCustomTransformers.php index 398c52ab6..68d8e3586 100644 --- a/src/Utils/Transformers/WithCustomTransformers.php +++ b/src/Utils/Transformers/WithCustomTransformers.php @@ -68,9 +68,7 @@ protected static function normalizeToSharpAttributeTransformer(Closure $closure) { return new class($closure) implements SharpAttributeTransformer { - public function __construct(private Closure $closure) - { - } + public function __construct(private Closure $closure) {} public function apply($value, $instance = null, $attribute = null) { @@ -130,15 +128,15 @@ protected function applyTransformers(array|object $model, bool $forceFullObject // This is a BC, even if this is a bugfix: in case of a sub-attribute, // we should pass the related model to the transformer. Will do that in 9.x -// if (($sep = strpos($attribute, ':')) !== false) { -// $attributes[$attribute] = $transformer->apply( -// $attributes[$attribute] ?? null, -// $model[substr($attribute, 0, $sep)] ?? null, -// substr($attribute, $sep + 1), -// ); -// -// continue; -// } + // if (($sep = strpos($attribute, ':')) !== false) { + // $attributes[$attribute] = $transformer->apply( + // $attributes[$attribute] ?? null, + // $model[substr($attribute, 0, $sep)] ?? null, + // substr($attribute, $sep + 1), + // ); + // + // continue; + // } $attributes[$attribute] = $transformer->apply( $attributes[$attribute] ?? null, diff --git a/src/View/Components/Content/Attributes.php b/src/View/Components/Content/Attributes.php index b0836aed0..82b3695b9 100644 --- a/src/View/Components/Content/Attributes.php +++ b/src/View/Components/Content/Attributes.php @@ -4,6 +4,4 @@ use Code16\ContentRenderer\View\Components\Attributes as AttributesComponent; -class Attributes extends AttributesComponent -{ -} +class Attributes extends AttributesComponent {} diff --git a/src/View/Components/Extensions/InjectedAssets.php b/src/View/Components/Extensions/InjectedAssets.php index 566bb9ed8..2b31493fa 100644 --- a/src/View/Components/Extensions/InjectedAssets.php +++ b/src/View/Components/Extensions/InjectedAssets.php @@ -92,7 +92,6 @@ public function getInjectedAssets() * Get the asset file type. * * @param string $assetPath - * @return string */ protected function getAssetFileType($assetPath): string { @@ -106,7 +105,6 @@ protected function getAssetFileType($assetPath): string * * @param string $strategy * @param string $assetPath - * @return string */ protected function getAssetPathWithStrategyApplied($strategy, $assetPath): string { @@ -127,7 +125,6 @@ protected function getAssetPathWithStrategyApplied($strategy, $assetPath): strin /** * Get the strategy to render the assets. * - * @return string * * @throws SharpInvalidAssetRenderStrategy */ diff --git a/src/View/Components/File.php b/src/View/Components/File.php index 826a3dfc7..cdb000612 100644 --- a/src/View/Components/File.php +++ b/src/View/Components/File.php @@ -14,7 +14,9 @@ class File extends Component use UsesSharpUploadModel; public ?SharpUploadModel $fileModel = null; + public ?FilesystemAdapter $disk = null; + public bool $exists = false; public function __construct( diff --git a/src/View/Components/Image.php b/src/View/Components/Image.php index a1ebd6a7a..602c5bbaf 100644 --- a/src/View/Components/Image.php +++ b/src/View/Components/Image.php @@ -14,7 +14,9 @@ class Image extends Component use UsesSharpUploadModel; public ?SharpUploadModel $fileModel = null; + public ?FilesystemAdapter $disk = null; + public bool $exists = false; public function __construct( diff --git a/src/View/Components/Menu.php b/src/View/Components/Menu.php index 89d5ae377..2254aac80 100644 --- a/src/View/Components/Menu.php +++ b/src/View/Components/Menu.php @@ -10,9 +10,13 @@ class Menu extends Component { public string $title; + public ?string $currentEntityKey; + public ?SharpMenuItemLink $currentEntityItem; + public bool $hasGlobalFilters; + public bool $isVisible = true; public function __construct(private SharpMenuManager $menuManager) @@ -22,7 +26,7 @@ public function __construct(private SharpMenuManager $menuManager) $this->currentEntityItem = $this->currentEntityKey ? $this->menuManager->getEntityMenuItem($this->currentEntityKey) : null; - $this->hasGlobalFilters = sizeof(value(config('sharp.global_filters')) ?? []) > 0; + $this->hasGlobalFilters = count(value(config('sharp.global_filters')) ?? []) > 0; $this->isVisible = $this->menuManager->menu()?->isVisible() ?? true; } diff --git a/src/View/Components/Menu/MenuSection.php b/src/View/Components/Menu/MenuSection.php index 2f8d56d08..0f7827443 100644 --- a/src/View/Components/Menu/MenuSection.php +++ b/src/View/Components/Menu/MenuSection.php @@ -13,8 +13,7 @@ class MenuSection extends Component public function __construct( public SharpMenuItemSection $item, public ?string $currentEntityKey = null, - ) { - } + ) {} public function hasCurrentItem(): bool { diff --git a/src/View/Components/RootStyles.php b/src/View/Components/RootStyles.php index 6eb032a5a..875d37768 100644 --- a/src/View/Components/RootStyles.php +++ b/src/View/Components/RootStyles.php @@ -9,7 +9,9 @@ class RootStyles extends Component { public string $primaryColor; + public string $primaryColorLuminosity; + public array $primaryColorHSL; public function __construct() diff --git a/src/sharp_helper.php b/src/sharp_helper.php index 24c836678..c18e79b72 100644 --- a/src/sharp_helper.php +++ b/src/sharp_helper.php @@ -18,13 +18,13 @@ function sharp_user() return auth()->user(); } -function sharp_has_ability(string $ability, string $entityKey, string $instanceId = null): bool +function sharp_has_ability(string $ability, string $entityKey, ?string $instanceId = null): bool { return app(Code16\Sharp\Auth\SharpAuthorizationManager::class) ->isAllowed($ability, sharp_normalize_entity_key($entityKey)[0], $instanceId); } -function sharp_check_ability(string $ability, string $entityKey, string $instanceId = null) +function sharp_check_ability(string $ability, string $entityKey, ?string $instanceId = null) { app(Code16\Sharp\Auth\SharpAuthorizationManager::class) ->check($ability, sharp_normalize_entity_key($entityKey)[0], $instanceId); diff --git a/tests/Feature/Api/AuthenticationTest.php b/tests/Feature/Api/AuthenticationTest.php index dcab87ff3..128e78da2 100644 --- a/tests/Feature/Api/AuthenticationTest.php +++ b/tests/Feature/Api/AuthenticationTest.php @@ -8,13 +8,13 @@ class AuthenticationTest extends BaseApiTestCase { -// protected function setUp(): void -// { -// parent::setUp(); -// -// // Have to define a "login" route in Laravel 11 -// Route::get('/test-login', fn () => 'ok')->name('login'); -// } + // protected function setUp(): void + // { + // parent::setUp(); + // + // // Have to define a "login" route in Laravel 11 + // Route::get('/test-login', fn () => 'ok')->name('login'); + // } /** @test */ public function unauthenticated_user_wont_pass_on_an_api_call() @@ -86,9 +86,6 @@ public function we_can_configure_a_custom_auth_check() $this->json('get', '/sharp/api/list/person')->assertStatus(401); } - /** - * @return AuthenticationTestGuard - */ protected function configureCustomAuthGuard(): AuthenticationTestGuard { $authGuard = new AuthenticationTestGuard(true); @@ -115,9 +112,7 @@ protected function configureCustomAuthGuard(): AuthenticationTestGuard class AuthenticationTestGuard implements \Illuminate\Contracts\Auth\Guard { - public function __construct(private bool $isValid) - { - } + public function __construct(private bool $isValid) {} public function check() { @@ -131,7 +126,7 @@ public function guest() public function user() { - return $this->isValid ? new User() : null; + return $this->isValid ? new User : null; } public function id() @@ -144,9 +139,7 @@ public function validate(array $credentials = []) return true; } - public function setUser(Authenticatable $user) - { - } + public function setUser(Authenticatable $user) {} public function hasUser() { @@ -158,13 +151,9 @@ public function setInvalid() $this->isValid = false; } - public function authenticate() - { - } + public function authenticate() {} - public function logout() - { - } + public function logout() {} } class AuthenticationTestCheckHandler diff --git a/tests/Feature/Api/Commands/DashboardCommandControllerTest.php b/tests/Feature/Api/Commands/DashboardCommandControllerTest.php index 8e00ce703..b63c7cec6 100644 --- a/tests/Feature/Api/Commands/DashboardCommandControllerTest.php +++ b/tests/Feature/Api/Commands/DashboardCommandControllerTest.php @@ -72,7 +72,7 @@ class EntityCommandTestSharpDashboard extends SharpDashboard public function getDashboardCommands(): ?array { return [ - 'dashboard_info' => new class() extends DashboardCommand + 'dashboard_info' => new class extends DashboardCommand { public function label(): string { @@ -84,7 +84,7 @@ public function execute(array $data = []): array return $this->info('ok'); } }, - 'dashboard_form' => new class() extends DashboardCommand + 'dashboard_form' => new class extends DashboardCommand { public function label(): string { @@ -104,9 +104,7 @@ protected function initialData(): array ]; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } diff --git a/tests/Feature/Api/Commands/EntityListEntityCommandControllerTest.php b/tests/Feature/Api/Commands/EntityListEntityCommandControllerTest.php index 368e745ec..f749c0612 100644 --- a/tests/Feature/Api/Commands/EntityListEntityCommandControllerTest.php +++ b/tests/Feature/Api/Commands/EntityListEntityCommandControllerTest.php @@ -327,7 +327,7 @@ class EntityCommandTestPersonSharpEntityList extends PersonSharpEntityList public function getEntityCommands(): ?array { return [ - 'entity_info' => new class() extends EntityCommand + 'entity_info' => new class extends EntityCommand { public function label(): string { @@ -339,7 +339,7 @@ public function execute(array $data = []): array return $this->info('ok'); } }, - 'entity_reload' => new class() extends EntityCommand + 'entity_reload' => new class extends EntityCommand { public function label(): string { @@ -351,7 +351,7 @@ public function execute(array $data = []): array return $this->reload(); } }, - 'entity_view' => new class() extends EntityCommand + 'entity_view' => new class extends EntityCommand { public function label(): string { @@ -363,7 +363,7 @@ public function execute(array $data = []): array return $this->view('welcome'); } }, - 'entity_refresh' => new class() extends EntityCommand + 'entity_refresh' => new class extends EntityCommand { public function label(): string { @@ -375,7 +375,7 @@ public function execute(array $data = []): array return $this->refresh([1, 2]); } }, - 'entity_exception' => new class() extends EntityCommand + 'entity_exception' => new class extends EntityCommand { public function label(): string { @@ -387,7 +387,7 @@ public function execute(array $data = []): array throw new SharpApplicativeException('error'); } }, - 'entity_form' => new class() extends EntityCommand + 'entity_form' => new class extends EntityCommand { public function label(): string { @@ -406,7 +406,7 @@ public function execute(array $data = []): array return $this->reload(); } }, - 'entity_global_message' => new class() extends EntityCommand + 'entity_global_message' => new class extends EntityCommand { public function label(): string { @@ -423,11 +423,9 @@ public function buildFormFields(FieldsContainer $formFields): void $formFields->addField(SharpFormTextField::make('name')); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, - 'entity_form_localized' => new class() extends EntityCommand + 'entity_form_localized' => new class extends EntityCommand { public function label(): string { @@ -439,16 +437,14 @@ public function buildFormFields(FieldsContainer $formFields): void $formFields->addField(SharpFormTextField::make('name')); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} public function getDataLocalizations(): array { return ['fr', 'en', 'it']; } }, - 'entity_download' => new class() extends EntityCommand + 'entity_download' => new class extends EntityCommand { public function label(): string { @@ -463,7 +459,7 @@ public function execute(array $data = []): array return $this->download('pdf/account.pdf', 'account.pdf', 'files'); } }, - 'entity_streamDownload' => new class() extends EntityCommand + 'entity_streamDownload' => new class extends EntityCommand { public function label(): string { @@ -475,7 +471,7 @@ public function execute(array $data = []): array return $this->streamDownload('content', 'stream.txt'); } }, - 'entity_download_no_disk' => new class() extends EntityCommand + 'entity_download_no_disk' => new class extends EntityCommand { public function label(): string { @@ -490,7 +486,7 @@ public function execute(array $data = []): array return $this->download('pdf/account.pdf'); } }, - 'entity_unauthorized' => new class() extends EntityCommand + 'entity_unauthorized' => new class extends EntityCommand { public function label(): string { @@ -507,7 +503,7 @@ public function execute(array $data = []): array return $this->reload(); } }, - 'entity_params' => new class() extends EntityCommand + 'entity_params' => new class extends EntityCommand { public function label(): string { @@ -519,7 +515,7 @@ public function execute(array $data = []): array return $this->info($this->queryParams->sortedBy().$this->queryParams->sortedDir()); } }, - 'entity_bulk' => new class() extends EntityCommand + 'entity_bulk' => new class extends EntityCommand { public function label(): string { @@ -536,7 +532,7 @@ public function execute(array $data = []): array return $this->info(implode('-', $this->selectedIds())); } }, - 'entity_with_init_data' => new class() extends EntityCommand + 'entity_with_init_data' => new class extends EntityCommand { public function label(): string { @@ -556,9 +552,7 @@ protected function initialData(): array ]; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } diff --git a/tests/Feature/Api/Commands/EntityListEntityWizardCommandControllerTest.php b/tests/Feature/Api/Commands/EntityListEntityWizardCommandControllerTest.php index b669c2c92..5e4b3c833 100644 --- a/tests/Feature/Api/Commands/EntityListEntityWizardCommandControllerTest.php +++ b/tests/Feature/Api/Commands/EntityListEntityWizardCommandControllerTest.php @@ -142,7 +142,7 @@ class EntityWizardCommandTestPersonSharpEntityList extends PersonSharpEntityList public function getEntityCommands(): ?array { return [ - 'entity_wizard' => new class() extends EntityWizardCommand + 'entity_wizard' => new class extends EntityWizardCommand { protected function getKey(): string { @@ -195,7 +195,7 @@ public function executeStep(string $step, array $data = []): array return $this->info('ok step 3'); } - throw new SharpApplicativeException(); + throw new SharpApplicativeException; } }, ]; diff --git a/tests/Feature/Api/Commands/EntityListInstanceCommandControllerTest.php b/tests/Feature/Api/Commands/EntityListInstanceCommandControllerTest.php index 0732f8bcd..68980bc81 100644 --- a/tests/Feature/Api/Commands/EntityListInstanceCommandControllerTest.php +++ b/tests/Feature/Api/Commands/EntityListInstanceCommandControllerTest.php @@ -197,7 +197,7 @@ class EntityListInstanceCommandPersonSharpEntityList extends PersonSharpEntityLi public function getInstanceCommands(): ?array { return [ - 'instance_info' => new class() extends InstanceCommand + 'instance_info' => new class extends InstanceCommand { public function label(): string { @@ -209,7 +209,7 @@ public function execute($instanceId, array $params = []): array return $this->info('ok'); } }, - 'instance_refresh' => new class() extends InstanceCommand + 'instance_refresh' => new class extends InstanceCommand { public function label(): string { @@ -221,7 +221,7 @@ public function execute($instanceId, array $params = []): array return $this->refresh(1); } }, - 'instance_link' => new class() extends InstanceCommand + 'instance_link' => new class extends InstanceCommand { public function label(): string { @@ -233,7 +233,7 @@ public function execute($instanceId, array $params = []): array return $this->link('/link/out'); } }, - 'instance_unauthorized_odd_id' => new class() extends InstanceCommand + 'instance_unauthorized_odd_id' => new class extends InstanceCommand { public function label(): string { @@ -250,7 +250,7 @@ public function execute($instanceId, array $params = []): array return $this->reload(); } }, - 'instance_form' => new class() extends InstanceCommand + 'instance_form' => new class extends InstanceCommand { public function label(): string { @@ -262,11 +262,9 @@ public function buildFormFields(FieldsContainer $formFields): void $formFields->addField(SharpFormTextField::make('name')); } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, - 'instance_form_localized' => new class() extends InstanceCommand + 'instance_form_localized' => new class extends InstanceCommand { public function label(): string { @@ -278,16 +276,14 @@ public function buildFormFields(FieldsContainer $formFields): void $formFields->addField(SharpFormTextField::make('name')); } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} public function getDataLocalizations(): array { return ['fr', 'en', 'it']; } }, - 'instance_global_message' => new class() extends InstanceCommand + 'instance_global_message' => new class extends InstanceCommand { public function label(): string { @@ -304,11 +300,9 @@ public function buildFormFields(FieldsContainer $formFields): void $formFields->addField(SharpFormTextField::make('name')); } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, - 'instance_with_init_data' => new class() extends InstanceCommand + 'instance_with_init_data' => new class extends InstanceCommand { public function label(): string { @@ -328,9 +322,7 @@ protected function initialData($instanceId): array ]; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, ]; } diff --git a/tests/Feature/Api/Commands/EntityListInstanceStateControllerTest.php b/tests/Feature/Api/Commands/EntityListInstanceStateControllerTest.php index 43ee97b5f..5d4e11af7 100644 --- a/tests/Feature/Api/Commands/EntityListInstanceStateControllerTest.php +++ b/tests/Feature/Api/Commands/EntityListInstanceStateControllerTest.php @@ -128,7 +128,7 @@ class EntityListInstanceStatePersonSharpEntityList extends PersonSharpEntityList { public function buildListConfig(): void { - $this->configureEntityState('state', new class() extends EntityState + $this->configureEntityState('state', new class extends EntityState { protected function buildStates(): void { diff --git a/tests/Feature/Api/Commands/EntityListInstanceWizardCommandControllerTest.php b/tests/Feature/Api/Commands/EntityListInstanceWizardCommandControllerTest.php index 8b1c6c86c..10e142e26 100644 --- a/tests/Feature/Api/Commands/EntityListInstanceWizardCommandControllerTest.php +++ b/tests/Feature/Api/Commands/EntityListInstanceWizardCommandControllerTest.php @@ -144,7 +144,7 @@ class InstanceWizardCommandTestPersonSharpEntityList extends PersonSharpEntityLi public function getInstanceCommands(): ?array { return [ - 'instance_wizard' => new class() extends InstanceWizardCommand + 'instance_wizard' => new class extends InstanceWizardCommand { protected function getKey(): string { @@ -197,7 +197,7 @@ public function executeStep(string $step, mixed $instanceId, array $data = []): return $this->info('ok step 3'); } - throw new SharpApplicativeException(); + throw new SharpApplicativeException; } }, ]; diff --git a/tests/Feature/Api/Commands/ShowInstanceCommandControllerTest.php b/tests/Feature/Api/Commands/ShowInstanceCommandControllerTest.php index 6855c9ea9..7aa9f7bbb 100644 --- a/tests/Feature/Api/Commands/ShowInstanceCommandControllerTest.php +++ b/tests/Feature/Api/Commands/ShowInstanceCommandControllerTest.php @@ -123,7 +123,7 @@ class ShowInstanceCommandPersonSharpShow extends PersonSharpShow public function getInstanceCommands(): ?array { return [ - 'instance_info' => new class() extends InstanceCommand + 'instance_info' => new class extends InstanceCommand { public function label(): string { @@ -135,7 +135,7 @@ public function execute($instanceId, array $params = []): array return $this->info('ok'); } }, - 'instance_with_init_data' => new class() extends InstanceCommand + 'instance_with_init_data' => new class extends InstanceCommand { public function label(): string { @@ -155,9 +155,7 @@ protected function initialData($instanceId): array ]; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, ]; } @@ -168,7 +166,7 @@ class ShowInstanceCommandPersonSharpSingleShow extends PersonSharpSingleShow public function getInstanceCommands(): ?array { return [ - 'instance_info' => new class() extends SingleInstanceCommand + 'instance_info' => new class extends SingleInstanceCommand { public function label(): string { @@ -180,7 +178,7 @@ public function executeSingle(array $params = []): array return $this->info('ok'); } }, - 'instance_with_init_data' => new class() extends SingleInstanceCommand + 'instance_with_init_data' => new class extends SingleInstanceCommand { public function label(): string { @@ -200,9 +198,7 @@ protected function initialSingleData(): array ]; } - public function executeSingle(array $data = []): array - { - } + public function executeSingle(array $data = []): array {} }, ]; } diff --git a/tests/Feature/Api/Commands/ShowInstanceStateControllerTest.php b/tests/Feature/Api/Commands/ShowInstanceStateControllerTest.php index 46fa00f0f..60df2de18 100644 --- a/tests/Feature/Api/Commands/ShowInstanceStateControllerTest.php +++ b/tests/Feature/Api/Commands/ShowInstanceStateControllerTest.php @@ -80,7 +80,7 @@ class ShowInstanceStatePersonSharpShow extends PersonSharpShow { public function buildShowConfig(): void { - $this->configureEntityState('state', new class() extends EntityState + $this->configureEntityState('state', new class extends EntityState { protected function buildStates(): void { @@ -107,7 +107,7 @@ class ShowInstanceStatePersonSharpSingleShow extends PersonSharpSingleShow { public function buildShowConfig(): void { - $this->setEntityState('state', new class() extends SingleEntityState + $this->setEntityState('state', new class extends SingleEntityState { protected function buildStates(): void { diff --git a/tests/Feature/Api/Embeds/EmbedsControllerTest.php b/tests/Feature/Api/Embeds/EmbedsControllerTest.php index 592106911..2ce077147 100644 --- a/tests/Feature/Api/Embeds/EmbedsControllerTest.php +++ b/tests/Feature/Api/Embeds/EmbedsControllerTest.php @@ -150,6 +150,7 @@ public function buildFormFields(FieldsContainer $formFields): void class EmbedsControllerTestEmbed extends SharpFormEditorEmbed { public static string $key = 'Code16.Sharp.Tests.Feature.Api.Embeds.EmbedsControllerTestEmbed'; + public static string $templateTransformMode = 'none'; public function buildEmbedConfig(): void @@ -172,11 +173,7 @@ public function transformDataForTemplate(array $data, bool $isForm): array ]; } - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} - public function updateContent(array $data = []): array - { - } + public function updateContent(array $data = []): array {} } diff --git a/tests/Feature/Api/EntityListControllerTest.php b/tests/Feature/Api/EntityListControllerTest.php index 9703e56e1..69acb816d 100644 --- a/tests/Feature/Api/EntityListControllerTest.php +++ b/tests/Feature/Api/EntityListControllerTest.php @@ -133,7 +133,7 @@ public function we_can_get_list_config_for_an_entity() /** @test */ public function we_can_get_notifications() { - (new PersonSharpForm())->notify('title') + (new PersonSharpForm)->notify('title') ->setLevelSuccess() ->setDetail('body') ->setAutoHide(false); @@ -151,8 +151,8 @@ public function we_can_get_notifications() ->assertOk() ->assertJsonMissing(['alert']); - (new PersonSharpForm())->notify('title1'); - (new PersonSharpForm())->notify('title2'); + (new PersonSharpForm)->notify('title1'); + (new PersonSharpForm)->notify('title2'); $this->json('get', '/sharp/api/list/person') ->assertOk() @@ -302,9 +302,7 @@ public function we_throw_an_exception_if_delete_is_not_implemented_and_there_is_ class PersonSharpEntityListWithDeletion extends PersonSharpEntityList { - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} } // Just an empty list impl to be sure we don't call delete on it @@ -326,7 +324,5 @@ public function delete(mixed $id): void class PersonSharpFormWithDeletion extends PersonSharpForm { - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} } diff --git a/tests/Feature/Api/FiltersInRequestTest.php b/tests/Feature/Api/FiltersInRequestTest.php index 527013b80..c3c14c9e1 100644 --- a/tests/Feature/Api/FiltersInRequestTest.php +++ b/tests/Feature/Api/FiltersInRequestTest.php @@ -99,7 +99,7 @@ public function retained_filters_are_saved_in_the_session() app()->bind( PersonSharpEntityList::class, function () { - return new class() extends PersonSharpEntityList + return new class extends PersonSharpEntityList { public function getFilters(): array { @@ -112,7 +112,7 @@ public function getFilters(): array ); $this->buildTheWorld(); - $key = (new FiltersInRequestTestRetainedActiveFilter())->getKey(); + $key = (new FiltersInRequestTestRetainedActiveFilter)->getKey(); $this->assertFalse((bool) session("_sharp_retained_filter_$key")); @@ -129,7 +129,7 @@ public function retained_filter_values_are_retrieved_from_the_session() app()->bind( PersonSharpEntityList::class, function () { - return new class() extends PersonSharpEntityList + return new class extends PersonSharpEntityList { public function getListData(): array|Arrayable { @@ -203,7 +203,7 @@ public function retained_filter_works_with_multiple_filter() app()->bind( PersonSharpEntityList::class, function () { - return new class() extends PersonSharpEntityList + return new class extends PersonSharpEntityList { public function getListData(): array|Arrayable { @@ -266,7 +266,7 @@ public function retained_filter_works_with_required_filter() app()->bind( PersonSharpEntityList::class, function () { - return new class() extends PersonSharpEntityList + return new class extends PersonSharpEntityList { public function getListData(): array|Arrayable { diff --git a/tests/Feature/Api/FormControllerTest.php b/tests/Feature/Api/FormControllerTest.php index aea00618e..fe41906eb 100644 --- a/tests/Feature/Api/FormControllerTest.php +++ b/tests/Feature/Api/FormControllerTest.php @@ -119,48 +119,48 @@ public function we_can_update_an_entity() ]); } -// /** @test */ -// public function we_can_delete_an_entity() -// { -// $this->buildTheWorld(); -// -// $this->fakeCurrentSharpRequestWithUrl('/sharp/s-list/person/s-form/person/1'); -// $this->deleteJson('/sharp/api/form/person/1') -// ->assertStatus(200) -// ->assertJson([ -// 'redirectUrl' => url('/sharp/s-list/person'), -// ]); -// } -// -// /** @test */ -// public function when_deleting_an_entity_with_a_show_we_are_redirected_to_the_entity_list() -// { -// $this->buildTheWorld(); -// -// $this->fakeCurrentSharpRequestWithUrl('/sharp/s-list/person/s-show/person/1/s-form/person/1'); -// $this->deleteJson('/sharp/api/form/person/1') -// ->assertStatus(200) -// ->assertJson([ -// 'redirectUrl' => url('/sharp/s-list/person'), -// ]); -// } -// -// /** @test */ -// public function when_deleting_an_entity_with_multiple_shows_we_are_redirected_to_the_parent_show() -// { -// $this->withoutExceptionHandling(); -// $this->buildTheWorld(); -// -// // Define a fake "car" entity to avoid 404 -// $this->app['config']->set('sharp.entities.car', CarTestEntity::class); -// -// $this->fakeCurrentSharpRequestWithUrl('/sharp/s-list/person/s-show/person/1/s-show/car/2/s-form/car/2'); -// $this->deleteJson('/sharp/api/form/car/2') -// ->assertOk() -// ->assertJson([ -// 'redirectUrl' => url('/sharp/s-list/person/s-show/person/1'), -// ]); -// } + // /** @test */ + // public function we_can_delete_an_entity() + // { + // $this->buildTheWorld(); + // + // $this->fakeCurrentSharpRequestWithUrl('/sharp/s-list/person/s-form/person/1'); + // $this->deleteJson('/sharp/api/form/person/1') + // ->assertStatus(200) + // ->assertJson([ + // 'redirectUrl' => url('/sharp/s-list/person'), + // ]); + // } + // + // /** @test */ + // public function when_deleting_an_entity_with_a_show_we_are_redirected_to_the_entity_list() + // { + // $this->buildTheWorld(); + // + // $this->fakeCurrentSharpRequestWithUrl('/sharp/s-list/person/s-show/person/1/s-form/person/1'); + // $this->deleteJson('/sharp/api/form/person/1') + // ->assertStatus(200) + // ->assertJson([ + // 'redirectUrl' => url('/sharp/s-list/person'), + // ]); + // } + // + // /** @test */ + // public function when_deleting_an_entity_with_multiple_shows_we_are_redirected_to_the_parent_show() + // { + // $this->withoutExceptionHandling(); + // $this->buildTheWorld(); + // + // // Define a fake "car" entity to avoid 404 + // $this->app['config']->set('sharp.entities.car', CarTestEntity::class); + // + // $this->fakeCurrentSharpRequestWithUrl('/sharp/s-list/person/s-show/person/1/s-show/car/2/s-form/car/2'); + // $this->deleteJson('/sharp/api/form/car/2') + // ->assertOk() + // ->assertJson([ + // 'redirectUrl' => url('/sharp/s-list/person/s-show/person/1'), + // ]); + // } /** @test */ public function we_can_validate_an_entity_before_update() @@ -289,5 +289,6 @@ public function we_can_update_an_entity_on_a_single_form_case() class CarTestEntity extends SharpEntity { protected ?string $form = PersonSharpForm::class; + protected ?string $show = PersonSharpShow::class; } diff --git a/tests/Feature/Api/MultiFormEntityFormControllerTest.php b/tests/Feature/Api/MultiFormEntityFormControllerTest.php index 28fc10766..ecd9c398e 100644 --- a/tests/Feature/Api/MultiFormEntityFormControllerTest.php +++ b/tests/Feature/Api/MultiFormEntityFormControllerTest.php @@ -160,14 +160,12 @@ public function update($id, array $data) return $id; } - public function delete($id): void - { - } + public function delete($id): void {} protected function getFormValidatorClass(): ?string { return app(SharpEntityManager::class) - ->entityFor('person') + ->entityFor('person') ->multiformValidatorsForTest['small'] ?? null; } } @@ -188,7 +186,7 @@ public function find($id): array protected function getFormValidatorClass(): ?string { return app(SharpEntityManager::class) - ->entityFor('person') + ->entityFor('person') ->multiformValidatorsForTest['big'] ?? null; } } diff --git a/tests/Feature/Api/MultiFormEntityShowControllerTest.php b/tests/Feature/Api/MultiFormEntityShowControllerTest.php index 1ae9b3f1d..898f2fc5d 100644 --- a/tests/Feature/Api/MultiFormEntityShowControllerTest.php +++ b/tests/Feature/Api/MultiFormEntityShowControllerTest.php @@ -74,7 +74,5 @@ protected function buildShowLayout(ShowLayout $showLayout): void }); } - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} } diff --git a/tests/Feature/Auth/LoginControllerTest.php b/tests/Feature/Auth/LoginControllerTest.php index bf5561d15..19d0b01ca 100644 --- a/tests/Feature/Auth/LoginControllerTest.php +++ b/tests/Feature/Auth/LoginControllerTest.php @@ -11,7 +11,7 @@ protected function setUp(): void { parent::setUp(); - auth()->extend('sharp', fn () => new TestAuthGuard()); + auth()->extend('sharp', fn () => new TestAuthGuard); $this->app['config']->set('sharp.auth.guard', 'sharp'); $this->app['config']->set( 'auth.guards.sharp', [ diff --git a/tests/Feature/Auth/LoginNotification2faControllerTest.php b/tests/Feature/Auth/LoginNotification2faControllerTest.php index 265580057..2cfa9e4d1 100644 --- a/tests/Feature/Auth/LoginNotification2faControllerTest.php +++ b/tests/Feature/Auth/LoginNotification2faControllerTest.php @@ -15,7 +15,7 @@ protected function setUp(): void { parent::setUp(); - auth()->extend('sharp', fn () => new TestAuthGuard()); + auth()->extend('sharp', fn () => new TestAuthGuard); $this->app['config']->set( 'auth.guards.sharp', [ 'driver' => 'sharp', diff --git a/tests/Feature/Auth/LoginTotp2faControllerTest.php b/tests/Feature/Auth/LoginTotp2faControllerTest.php index c64add475..900af91e9 100644 --- a/tests/Feature/Auth/LoginTotp2faControllerTest.php +++ b/tests/Feature/Auth/LoginTotp2faControllerTest.php @@ -34,7 +34,7 @@ public function getQRCodeUrl(string $email, string $secret): string } ); - auth()->extend('sharp', fn () => new TestAuthGuard()); + auth()->extend('sharp', fn () => new TestAuthGuard); $this->app['config']->set( 'auth.guards.sharp', [ 'driver' => 'sharp', @@ -54,17 +54,11 @@ public function isEnabledFor($user): bool return true; } - public function activate2faForUser(): void - { - } + public function activate2faForUser(): void {} - public function deactivate2faForUser(): void - { - } + public function deactivate2faForUser(): void {} - protected function saveUserSecretAndRecoveryCodes($user, string $encryptedSecret, string $encryptedRecoveryCodes): void - { - } + protected function saveUserSecretAndRecoveryCodes($user, string $encryptedSecret, string $encryptedRecoveryCodes): void {} protected function getUserEncryptedSecret($userId): string { diff --git a/tests/Fixtures/PersonEntity.php b/tests/Fixtures/PersonEntity.php index 03281c91b..e8f23a99f 100644 --- a/tests/Fixtures/PersonEntity.php +++ b/tests/Fixtures/PersonEntity.php @@ -7,12 +7,19 @@ class PersonEntity extends SharpEntity { public ?string $validatorForTest = null; + public array $multiformValidatorsForTest = []; + public array $multiformForTest = []; + protected string $entityKey = 'person'; + protected string $label = 'person'; + protected ?string $list = PersonSharpEntityList::class; + protected ?string $form = PersonSharpForm::class; + protected ?string $show = PersonSharpShow::class; public function setList(string $list): self diff --git a/tests/Fixtures/PersonSharpEntityList.php b/tests/Fixtures/PersonSharpEntityList.php index aa324b4d2..4e28eb985 100644 --- a/tests/Fixtures/PersonSharpEntityList.php +++ b/tests/Fixtures/PersonSharpEntityList.php @@ -138,7 +138,5 @@ public function defaultValue(): mixed class PersonSharpEntityListReorderHandler implements ReorderHandler { - public function reorder(array $ids): void - { - } + public function reorder(array $ids): void {} } diff --git a/tests/Fixtures/PersonSharpShow.php b/tests/Fixtures/PersonSharpShow.php index 1349b8df6..f3fac2789 100644 --- a/tests/Fixtures/PersonSharpShow.php +++ b/tests/Fixtures/PersonSharpShow.php @@ -28,9 +28,7 @@ public function label(): string return 'Label'; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} public function authorizeFor($instanceId): bool { @@ -51,9 +49,7 @@ protected function buildStates(): void $this->addState('active', 'Label', 'blue'); } - protected function updateState($instanceId, $stateId): array - { - } + protected function updateState($instanceId, $stateId): array {} public function authorizeFor($instanceId): bool { @@ -78,7 +74,5 @@ public function find($id): array return ['name' => 'John Wayne', 'job' => 'actor', 'state' => 'active']; } - public function delete($id): void - { - } + public function delete($id): void {} } diff --git a/tests/Fixtures/SinglePersonEntity.php b/tests/Fixtures/SinglePersonEntity.php index 0b6031bce..968d6dba9 100644 --- a/tests/Fixtures/SinglePersonEntity.php +++ b/tests/Fixtures/SinglePersonEntity.php @@ -5,6 +5,8 @@ class SinglePersonEntity extends PersonEntity { protected bool $isSingle = true; + protected ?string $show = PersonSharpSingleShow::class; + protected ?string $form = PersonSharpSingleForm::class; } diff --git a/tests/Fixtures/TestAuthGuard.php b/tests/Fixtures/TestAuthGuard.php index a74fd7816..0634d5b63 100644 --- a/tests/Fixtures/TestAuthGuard.php +++ b/tests/Fixtures/TestAuthGuard.php @@ -30,9 +30,7 @@ public function id() return $this->hasUser() ? 1 : null; } - public function validate(array $credentials = []) - { - } + public function validate(array $credentials = []) {} public function setUser(Authenticatable $user) { @@ -71,17 +69,11 @@ public function login(Authenticatable $user, $remember = false) $this->setUser($user); } - public function loginUsingId($id, $remember = false) - { - } + public function loginUsingId($id, $remember = false) {} - public function onceUsingId($id) - { - } + public function onceUsingId($id) {} - public function viaRemember() - { - } + public function viaRemember() {} public function logout() { diff --git a/tests/SharpTestCase.php b/tests/SharpTestCase.php index 0d400af44..d27c153c6 100644 --- a/tests/SharpTestCase.php +++ b/tests/SharpTestCase.php @@ -28,9 +28,7 @@ public function isAllowed(string $ability, string $entityKey, ?string $instanceI return true; } - public function check(string $ability, string $entityKey, ?string $instanceId = null): void - { - } + public function check(string $ability, string $entityKey, ?string $instanceId = null): void {} }; }); } diff --git a/tests/Unit/Dashboard/DashboardCommandTest.php b/tests/Unit/Dashboard/DashboardCommandTest.php index a2b359047..ec1b5e297 100644 --- a/tests/Unit/Dashboard/DashboardCommandTest.php +++ b/tests/Unit/Dashboard/DashboardCommandTest.php @@ -25,9 +25,7 @@ public function label(): string return 'My Dashboard Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -66,9 +64,7 @@ public function label(): string return 'My Dashboard Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ], 'dashboardCommand' => new class extends DashboardCommand @@ -78,9 +74,7 @@ public function label(): string return 'Another Dashboard Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -117,9 +111,7 @@ public function buildFormFields(FieldsContainer $formFields): void $formFields->addField(SharpFormTextField::make('message')); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } diff --git a/tests/Unit/Dashboard/Fakes/FakeSharpDashboard.php b/tests/Unit/Dashboard/Fakes/FakeSharpDashboard.php index 271c2ee10..cd8c1ddee 100644 --- a/tests/Unit/Dashboard/Fakes/FakeSharpDashboard.php +++ b/tests/Unit/Dashboard/Fakes/FakeSharpDashboard.php @@ -8,15 +8,9 @@ class FakeSharpDashboard extends SharpDashboard { - protected function buildWidgets(WidgetsContainer $widgetsContainer): void - { - } + protected function buildWidgets(WidgetsContainer $widgetsContainer): void {} - protected function buildDashboardLayout(DashboardLayout $dashboardLayout): void - { - } + protected function buildDashboardLayout(DashboardLayout $dashboardLayout): void {} - protected function buildWidgetsData(): void - { - } + protected function buildWidgetsData(): void {} } diff --git a/tests/Unit/Dashboard/SharpDashboardTest.php b/tests/Unit/Dashboard/SharpDashboardTest.php index 8b1e29e3d..c923927f2 100644 --- a/tests/Unit/Dashboard/SharpDashboardTest.php +++ b/tests/Unit/Dashboard/SharpDashboardTest.php @@ -458,7 +458,7 @@ public function we_can_configure_a_global_message_field_with_alert_level() { public function buildDashboardConfig(): void { - $this->configurePageAlert('alert', static::$pageAlertLevelDanger); + $this->configurePageAlert('alert', self::$pageAlertLevelDanger); } }; diff --git a/tests/Unit/EntityList/EntityListFilterTest.php b/tests/Unit/EntityList/EntityListFilterTest.php index 5db8d472e..7caea2e21 100644 --- a/tests/Unit/EntityList/EntityListFilterTest.php +++ b/tests/Unit/EntityList/EntityListFilterTest.php @@ -543,9 +543,7 @@ public function defaultValue(): mixed } } -class SharpEntityListDateRangeTestFilter extends EntityListDateRangeFilter -{ -} +class SharpEntityListDateRangeTestFilter extends EntityListDateRangeFilter {} class SharpEntityListDateRangeRequiredTestFilter extends \Code16\Sharp\EntityList\Filters\EntityListDateRangeRequiredFilter { @@ -555,6 +553,4 @@ public function defaultValue(): array } } -class SharpEntityListTestCheckFilter extends \Code16\Sharp\EntityList\Filters\EntityListCheckFilter -{ -} +class SharpEntityListTestCheckFilter extends \Code16\Sharp\EntityList\Filters\EntityListCheckFilter {} diff --git a/tests/Unit/EntityList/SharpEntityListCommandTest.php b/tests/Unit/EntityList/SharpEntityListCommandTest.php index 1200c8af8..644548692 100644 --- a/tests/Unit/EntityList/SharpEntityListCommandTest.php +++ b/tests/Unit/EntityList/SharpEntityListCommandTest.php @@ -27,9 +27,7 @@ public function label(): string return 'My Entity Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -44,9 +42,7 @@ public function label(): string return 'My Instance Command'; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, ]; } @@ -124,9 +120,7 @@ public function buildCommandConfig(): void $this->configureConfirmationText('Sure?'); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -157,9 +151,7 @@ public function buildCommandConfig(): void $this->configureInstanceSelectionRequired(); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, 'command_allowed' => new class extends EntityCommand { @@ -173,9 +165,7 @@ public function buildCommandConfig(): void $this->configureInstanceSelectionAllowed(); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, 'command_none' => new class extends EntityCommand { @@ -189,9 +179,7 @@ public function buildCommandConfig(): void $this->configureInstanceSelectionNone(); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -229,9 +217,7 @@ public function buildFormLayout(FormLayoutColumn &$column): void $column->withSingleField('message'); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -262,9 +248,7 @@ public function buildCommandConfig(): void $this->configureFormModalTitle('My title'); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -295,9 +279,7 @@ public function authorize(): bool return false; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -328,9 +310,7 @@ public function authorizeFor($instanceId): bool return $instanceId < 3; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, ]; } @@ -365,9 +345,7 @@ public function buildCommandConfig(): void $this->configureDescription('My Entity Command description'); } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -393,9 +371,7 @@ public function label(): string return ''; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, 'command-2' => new class extends InstanceCommand { @@ -404,9 +380,7 @@ public function label(): string return ''; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, '---', 'command-3' => new class extends InstanceCommand @@ -416,9 +390,7 @@ public function label(): string return ''; } - public function execute($instanceId, array $data = []): array - { - } + public function execute($instanceId, array $data = []): array {} }, ]; } @@ -446,9 +418,7 @@ public function label(): string return ''; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, '---', 'command-2' => new class extends EntityCommand @@ -458,9 +428,7 @@ public function label(): string return ''; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, 'command-3' => new class extends EntityCommand { @@ -469,9 +437,7 @@ public function label(): string return ''; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -499,9 +465,7 @@ public function label(): string return 'My Entity Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, 'primary-entity' => new class extends EntityCommand { @@ -510,9 +474,7 @@ public function label(): string return 'My Primary Entity Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} }, ]; } @@ -537,7 +499,5 @@ public function label(): string return 'My Entity Command'; } - public function execute(array $data = []): array - { - } + public function execute(array $data = []): array {} } diff --git a/tests/Unit/EntityList/SharpEntityListReorderTest.php b/tests/Unit/EntityList/SharpEntityListReorderTest.php index 135274f1a..dff5ee590 100644 --- a/tests/Unit/EntityList/SharpEntityListReorderTest.php +++ b/tests/Unit/EntityList/SharpEntityListReorderTest.php @@ -17,9 +17,7 @@ public function buildListConfig(): void { $this->configureReorderable(new class implements ReorderHandler { - public function reorder(array $ids): void - { - } + public function reorder(array $ids): void {} }); } }; diff --git a/tests/Unit/EntityList/SharpEntityListStateTest.php b/tests/Unit/EntityList/SharpEntityListStateTest.php index eb98b56b1..d54391901 100644 --- a/tests/Unit/EntityList/SharpEntityListStateTest.php +++ b/tests/Unit/EntityList/SharpEntityListStateTest.php @@ -26,9 +26,7 @@ protected function buildStates(): void $this->addState('test2', 'Test 2', 'red'); } - protected function updateState($instanceId, $stateId): array - { - } + protected function updateState($instanceId, $stateId): array {} }); } }; @@ -100,9 +98,7 @@ protected function buildStates(): void $this->addState(false, 'Test 2', 'red'); } - protected function updateState($instanceId, $stateId): array - { - } + protected function updateState($instanceId, $stateId): array {} }); } }; @@ -139,9 +135,7 @@ public function authorizeFor($instanceId): bool return $instanceId < 3; } - protected function updateState($instanceId, $stateId): array - { - } + protected function updateState($instanceId, $stateId): array {} }); } }; @@ -172,7 +166,5 @@ protected function buildStates(): void $this->addState('test2', 'Test 2', 'red'); } - protected function updateState($instanceId, $stateId): array - { - } + protected function updateState($instanceId, $stateId): array {} } diff --git a/tests/Unit/EntityList/SharpEntityListTest.php b/tests/Unit/EntityList/SharpEntityListTest.php index 686e7234d..e596231a2 100644 --- a/tests/Unit/EntityList/SharpEntityListTest.php +++ b/tests/Unit/EntityList/SharpEntityListTest.php @@ -266,7 +266,7 @@ public function we_can_configure_a_global_message_field_with_alert_level() { public function buildListConfig(): void { - $this->configurePageAlert('alert', static::$pageAlertLevelDanger); + $this->configurePageAlert('alert', self::$pageAlertLevelDanger); } }; diff --git a/tests/Unit/EntityList/Utils/SharpEntityDefaultTestList.php b/tests/Unit/EntityList/Utils/SharpEntityDefaultTestList.php index 40728f1e2..229d2d0ed 100644 --- a/tests/Unit/EntityList/Utils/SharpEntityDefaultTestList.php +++ b/tests/Unit/EntityList/Utils/SharpEntityDefaultTestList.php @@ -9,17 +9,11 @@ abstract class SharpEntityDefaultTestList extends SharpEntityList { - public function buildListFields(EntityListFieldsContainer $fieldsContainer): void - { - } + public function buildListFields(EntityListFieldsContainer $fieldsContainer): void {} - public function buildListLayout(EntityListFieldsLayout $fieldsLayout): void - { - } + public function buildListLayout(EntityListFieldsLayout $fieldsLayout): void {} - public function buildListConfig(): void - { - } + public function buildListConfig(): void {} public function getListData(): array|Arrayable { diff --git a/tests/Unit/EntityList/WithCustomTransformersInEntityListTest.php b/tests/Unit/EntityList/WithCustomTransformersInEntityListTest.php index 2d3a6857f..07bfdf66f 100644 --- a/tests/Unit/EntityList/WithCustomTransformersInEntityListTest.php +++ b/tests/Unit/EntityList/WithCustomTransformersInEntityListTest.php @@ -21,7 +21,7 @@ public function we_can_retrieve_an_array_version_of_a_models_collection() Person::create(['name' => 'John Wayne']); Person::create(['name' => 'Mary Wayne']); - $list = new WithCustomTransformersTestList(); + $list = new WithCustomTransformersTestList; $this->assertArraySubset( [['name' => 'John Wayne'], ['name' => 'Mary Wayne']], @@ -39,7 +39,7 @@ public function we_can_retrieve_an_array_version_of_a_db_raw_collection() { public function getListData(): array|Arrayable { - return $this->transform(DB::table((new Person())->getTable())->get()); + return $this->transform(DB::table((new Person)->getTable())->get()); } }; @@ -62,7 +62,7 @@ public function we_can_retrieve_an_array_version_of_a_db_raw_paginator() { public function getListData(): array|Arrayable { - return $this->transform(DB::table((new Person())->getTable())->paginate(2)); + return $this->transform(DB::table((new Person)->getTable())->paginate(2)); } }; @@ -176,7 +176,7 @@ public function we_can_define_a_custom_transformer_as_a_class_instance() public function getListData(): array|Arrayable { return $this - ->setCustomTransformer('name', new UppercaseTransformer()) + ->setCustomTransformer('name', new UppercaseTransformer) ->transform(Person::all()); } }; @@ -197,17 +197,11 @@ public function getListData(): array|Arrayable return $this->transform(Person::all()); } - public function buildListFields(EntityListFieldsContainer $fieldsContainer): void - { - } + public function buildListFields(EntityListFieldsContainer $fieldsContainer): void {} - public function buildListLayout(EntityListFieldsLayout $fieldsLayout): void - { - } + public function buildListLayout(EntityListFieldsLayout $fieldsLayout): void {} - public function buildListConfig(): void - { - } + public function buildListConfig(): void {} } class UppercaseTransformer implements SharpAttributeTransformer @@ -215,8 +209,6 @@ class UppercaseTransformer implements SharpAttributeTransformer /** * Transform a model attribute to array (json-able). * - * @param $value - * @param $instance * @param string $attribute * @return mixed */ diff --git a/tests/Unit/Form/Eloquent/Relationships/BelongsToManyRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/BelongsToManyRelationUpdaterTest.php index b61328c30..f3e4c30ef 100644 --- a/tests/Unit/Form/Eloquent/Relationships/BelongsToManyRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/BelongsToManyRelationUpdaterTest.php @@ -14,7 +14,7 @@ public function we_can_update_a_belongsToMany_relation() $person1 = Person::create(['name' => 'A']); $person2 = Person::create(['name' => 'B']); - $updater = new BelongsToManyRelationUpdater(); + $updater = new BelongsToManyRelationUpdater; $updater->update($person1, 'friends', [ ['id' => $person2->id], @@ -39,7 +39,7 @@ public function we_can_update_an_existing_belongsToMany_relation() ['id' => $person2->id], ]); - $updater = new BelongsToManyRelationUpdater(); + $updater = new BelongsToManyRelationUpdater; $updater->update($person1, 'friends', [ ['id' => $person3->id], @@ -61,7 +61,7 @@ public function we_can_can_create_a_new_related_item() { $person1 = Person::create(['name' => 'A']); - $updater = new BelongsToManyRelationUpdater(); + $updater = new BelongsToManyRelationUpdater; $updater->update($person1, 'friends', [ ['id' => null, 'name' => 'John Wayne'], diff --git a/tests/Unit/Form/Eloquent/Relationships/BelongsToRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/BelongsToRelationUpdaterTest.php index 780e9a975..338127532 100644 --- a/tests/Unit/Form/Eloquent/Relationships/BelongsToRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/BelongsToRelationUpdaterTest.php @@ -14,7 +14,7 @@ public function we_can_update_a_belongsTo_relation() $mother = Person::create(['name' => 'Jane Wayne']); $person = Person::create(['name' => 'John Wayne']); - $updater = new BelongsToRelationUpdater(); + $updater = new BelongsToRelationUpdater; $updater->update($person, 'mother', $mother->id); @@ -29,7 +29,7 @@ public function we_can_create_a_belongsTo_relation() { $person = Person::create(['name' => 'John Wayne']); - $updater = new BelongsToRelationUpdater(); + $updater = new BelongsToRelationUpdater; $updater->update($person, 'mother:name', 'Jane Wayne'); $this->assertCount(2, Person::all()); @@ -47,7 +47,7 @@ public function we_set_default_attributes_when_creating_a_belongsTo_relation() { $person = PersonWithDefaultAttributes::create(['name' => 'John Wayne']); - $updater = new BelongsToRelationUpdater(); + $updater = new BelongsToRelationUpdater; $updater->update($person, 'mother:name', 'Jane Wayne'); $this->assertDatabaseHas('people', [ diff --git a/tests/Unit/Form/Eloquent/Relationships/HasManyRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/HasManyRelationUpdaterTest.php index bbec8a9a2..488d0d2f6 100644 --- a/tests/Unit/Form/Eloquent/Relationships/HasManyRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/HasManyRelationUpdaterTest.php @@ -14,7 +14,7 @@ public function we_can_update_a_hasMany_relation() $mother = Person::create(['name' => 'Jane Wayne']); $son1 = Person::create(['name' => 'A', 'mother_id' => $mother->id]); - $updater = new HasManyRelationUpdater(); + $updater = new HasManyRelationUpdater; $updater->update($mother, 'sons', [[ 'id' => $son1->id, @@ -33,7 +33,7 @@ public function we_can_create_a_new_related_item_in_a_hasMany_relation() { $mother = Person::create(['name' => 'Jane Wayne']); - $updater = new HasManyRelationUpdater(); + $updater = new HasManyRelationUpdater; $updater->update($mother, 'sons', [[ 'id' => null, @@ -51,7 +51,7 @@ public function we_do_not_update_the_id_attribute_when_updating_a_related_item_i { $mother = Person::create(['name' => 'Jane Wayne']); - (new HasManyRelationUpdater())->update($mother, 'sons', [[ + (new HasManyRelationUpdater)->update($mother, 'sons', [[ 'id' => 'ABC', // Set a invalid id here to ensure it will be unset 'name' => 'John Wayne', ]]); @@ -65,7 +65,7 @@ public function we_certainly_do_update_the_id_attribute_when_updating_a_related_ { $mother = PersonWithFixedId::create(['name' => 'Jane Wayne']); - (new HasManyRelationUpdater())->update($mother, 'sons', [[ + (new HasManyRelationUpdater)->update($mother, 'sons', [[ 'id' => 123, 'name' => 'John Wayne', ]]); @@ -91,7 +91,7 @@ public function getDefaultAttributesFor($attribute) $mother->name = 'Jane Wayne'; $mother->save(); - $updater = new HasManyRelationUpdater(); + $updater = new HasManyRelationUpdater; $updater->update($mother, 'sons', [[ 'id' => null, 'name' => 'John Wayne', @@ -111,7 +111,7 @@ public function we_can_delete_an_existing_related_item_in_a_hasMany_relation() $son1 = Person::create(['name' => 'John Wayne', 'mother_id' => $mother->id]); $son2 = Person::create(['name' => 'Mary Wayne', 'mother_id' => $mother->id]); - $updater = new HasManyRelationUpdater(); + $updater = new HasManyRelationUpdater; $updater->update($mother, 'sons', [[ 'id' => $son1->id, 'name' => 'John Wayne', @@ -127,6 +127,7 @@ public function we_can_delete_an_existing_related_item_in_a_hasMany_relation() class PersonWithFixedId extends Person { protected $table = 'people'; + public $incrementing = false; public function sons() diff --git a/tests/Unit/Form/Eloquent/Relationships/HasOneRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/HasOneRelationUpdaterTest.php index 2b261225c..6b260c8ad 100644 --- a/tests/Unit/Form/Eloquent/Relationships/HasOneRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/HasOneRelationUpdaterTest.php @@ -14,7 +14,7 @@ public function we_can_update_a_hasOne_relation() $mother = Person::create(['name' => 'Jane Wayne']); $son = Person::create(['name' => 'John Wayne']); - $updater = new HasOneRelationUpdater(); + $updater = new HasOneRelationUpdater; $updater->update($mother, 'elderSon', $son->id); @@ -29,7 +29,7 @@ public function we_can_create_a_hasOne_related() { $mother = Person::create(['name' => 'Jane Wayne']); - $updater = new HasOneRelationUpdater(); + $updater = new HasOneRelationUpdater; $updater->update($mother, 'elderSon:name', 'John Wayne'); diff --git a/tests/Unit/Form/Eloquent/Relationships/MorphManyRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/MorphManyRelationUpdaterTest.php index 68bae1bd4..c46a9a0d4 100644 --- a/tests/Unit/Form/Eloquent/Relationships/MorphManyRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/MorphManyRelationUpdaterTest.php @@ -13,7 +13,7 @@ public function we_can_create_a_morphMany_related() { $person = Person::create(['name' => 'John Wayne']); - $updater = new MorphManyRelationUpdater(); + $updater = new MorphManyRelationUpdater; $updater->update($person, 'pictures', [[ 'id' => null, @@ -35,7 +35,7 @@ public function we_can_update_a_morphMany_related() 'file' => 'old.jpg', ]); - $updater = new MorphManyRelationUpdater(); + $updater = new MorphManyRelationUpdater; $updater->update($person, 'pictures', [[ 'id' => $person->pictures->first()->id, diff --git a/tests/Unit/Form/Eloquent/Relationships/MorphOneRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/MorphOneRelationUpdaterTest.php index a464344fb..f3597e219 100644 --- a/tests/Unit/Form/Eloquent/Relationships/MorphOneRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/MorphOneRelationUpdaterTest.php @@ -14,7 +14,7 @@ public function we_can_create_a_morphOne_related() { $person = Person::create(['name' => 'John Wayne']); - $updater = new MorphOneRelationUpdater(); + $updater = new MorphOneRelationUpdater; $updater->update($person, 'picture:file', 'test.jpg'); @@ -33,7 +33,7 @@ public function we_can_update_a_morphOne_related() 'file' => 'old.jpg', ]); - $updater = new MorphOneRelationUpdater(); + $updater = new MorphOneRelationUpdater; $updater->update($person, 'picture:file', 'test.jpg'); @@ -49,7 +49,7 @@ public function we_ignore_a_morphOne_related_if_null() { $person = Person::create(['name' => 'John Wayne']); - $updater = new MorphOneRelationUpdater(); + $updater = new MorphOneRelationUpdater; $updater->update($person, 'picture:file', null); diff --git a/tests/Unit/Form/Eloquent/Relationships/MorphToManyRelationUpdaterTest.php b/tests/Unit/Form/Eloquent/Relationships/MorphToManyRelationUpdaterTest.php index f130cc982..07e535fba 100644 --- a/tests/Unit/Form/Eloquent/Relationships/MorphToManyRelationUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/Relationships/MorphToManyRelationUpdaterTest.php @@ -35,7 +35,7 @@ public function we_can_update_a_morphToMany_relation() $person = TaggablePerson::create(['name' => 'A']); $tag = Tag::create(['name' => 'A']); - $updater = new MorphToManyRelationUpdater(); + $updater = new MorphToManyRelationUpdater; $updater->update($person, 'tags', [ ['id' => $tag->id], @@ -59,7 +59,7 @@ public function we_can_update_an_existing_morphToMany_relation() ['id' => $oldTag->id], ]); - $updater = new MorphToManyRelationUpdater(); + $updater = new MorphToManyRelationUpdater; $updater->update($person, 'tags', [ ['id' => $newTag->id], @@ -83,7 +83,7 @@ public function we_can_can_create_a_new_related_item() { $person = TaggablePerson::create(['name' => 'A']); - $updater = new MorphToManyRelationUpdater(); + $updater = new MorphToManyRelationUpdater; $updater->update($person, 'tags', [ ['id' => null, 'name' => 'Z'], diff --git a/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php b/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php index 67123311c..1cafc9cfb 100644 --- a/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php +++ b/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php @@ -32,7 +32,7 @@ public function we_can_transform_a_single_upload() $picturable = Picturable::create(); $upload = $this->createSharpUploadModel($this->createImage(), $picturable); - $transformer = new SharpUploadModelFormAttributeTransformer(); + $transformer = new SharpUploadModelFormAttributeTransformer; $this->assertEquals( [ @@ -65,7 +65,7 @@ public function we_can_transform_a_single_upload_with_transformations() ]; $upload->save(); - $transformer = new SharpUploadModelFormAttributeTransformer(); + $transformer = new SharpUploadModelFormAttributeTransformer; $this->assertEquals( [ @@ -98,7 +98,7 @@ public function we_can_transform_a_list_of_upload() $upload = $this->createSharpUploadModel($this->createImage(), $picturable); $upload2 = $this->createSharpUploadModel($this->createImage(), $picturable); - $transformer = new SharpUploadModelFormAttributeTransformer(); + $transformer = new SharpUploadModelFormAttributeTransformer; $this->assertEquals( [ @@ -148,7 +148,7 @@ public function we_can_transform_a_list_of_upload_with_transformations() $upload->filters = $filters; $upload->save(); - $transformer = new SharpUploadModelFormAttributeTransformer(); + $transformer = new SharpUploadModelFormAttributeTransformer; $this->assertEquals( [ @@ -189,7 +189,7 @@ public function we_can_fake_an_sharpUpload_and_transform_a_single_upload() 'filters' => [], ]; - $transformer = (new SharpUploadModelFormAttributeTransformer())->dynamicInstance(); + $transformer = (new SharpUploadModelFormAttributeTransformer)->dynamicInstance(); $this->assertEquals( [ diff --git a/tests/Unit/Form/Eloquent/WithSharpFormEloquentUpdaterTest.php b/tests/Unit/Form/Eloquent/WithSharpFormEloquentUpdaterTest.php index 55850d4bc..89d0ca128 100644 --- a/tests/Unit/Form/Eloquent/WithSharpFormEloquentUpdaterTest.php +++ b/tests/Unit/Form/Eloquent/WithSharpFormEloquentUpdaterTest.php @@ -59,7 +59,7 @@ public function undeclared_fields_are_ignored() { $person = Person::create(['name' => 'John Wayne']); - $form = new WithSharpFormEloquentUpdaterTestForm(); + $form = new WithSharpFormEloquentUpdaterTestForm; $form->updateInstance($person->id, ['id' => 1200, 'job' => 'Actor']); @@ -468,15 +468,9 @@ public function update($id, array $data) return $this->save($instance, $data); } - public function delete($id): void - { - } + public function delete($id): void {} - public function buildFormLayout(FormLayout $formLayout): void - { - } + public function buildFormLayout(FormLayout $formLayout): void {} - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} } diff --git a/tests/Unit/Form/Fields/Embeds/SharpFormEditorEmbedTest.php b/tests/Unit/Form/Fields/Embeds/SharpFormEditorEmbedTest.php index f18de145f..e7544652d 100644 --- a/tests/Unit/Form/Fields/Embeds/SharpFormEditorEmbedTest.php +++ b/tests/Unit/Form/Fields/Embeds/SharpFormEditorEmbedTest.php @@ -12,7 +12,7 @@ class SharpFormEditorEmbedTest extends SharpTestCase /** @test */ public function default_values_are_set_in_config() { - $defaultEmbed = new DefaultFakeSharpFormEditorEmbed(); + $defaultEmbed = new DefaultFakeSharpFormEditorEmbed; $defaultEmbed->buildEmbedConfig(); $this->assertEquals( @@ -30,7 +30,7 @@ public function default_values_are_set_in_config() /** @test */ public function we_can_configure_tag() { - $defaultEmbed = new class() extends DefaultFakeSharpFormEditorEmbed + $defaultEmbed = new class extends DefaultFakeSharpFormEditorEmbed { public function buildEmbedConfig(): void { @@ -49,7 +49,7 @@ public function buildEmbedConfig(): void /** @test */ public function we_can_configure_label() { - $defaultEmbed = new class() extends DefaultFakeSharpFormEditorEmbed + $defaultEmbed = new class extends DefaultFakeSharpFormEditorEmbed { public function buildEmbedConfig(): void { @@ -69,7 +69,7 @@ public function buildEmbedConfig(): void /** @test */ public function we_can_configure_form_template() { - $defaultEmbed = new class() extends DefaultFakeSharpFormEditorEmbed + $defaultEmbed = new class extends DefaultFakeSharpFormEditorEmbed { public function buildEmbedConfig(): void { @@ -89,7 +89,7 @@ public function buildEmbedConfig(): void /** @test */ public function we_can_configure_show_template() { - $defaultEmbed = new class() extends DefaultFakeSharpFormEditorEmbed + $defaultEmbed = new class extends DefaultFakeSharpFormEditorEmbed { public function buildEmbedConfig(): void { @@ -121,7 +121,5 @@ public function buildFormFields(FieldsContainer $formFields): void ); } - public function updateContent(array $data = []): array - { - } + public function updateContent(array $data = []): array {} } diff --git a/tests/Unit/Form/Fields/Formatters/AutocompleteListFormatterTest.php b/tests/Unit/Form/Fields/Formatters/AutocompleteListFormatterTest.php index 4e36c4ecc..90c8b123c 100644 --- a/tests/Unit/Form/Fields/Formatters/AutocompleteListFormatterTest.php +++ b/tests/Unit/Form/Fields/Formatters/AutocompleteListFormatterTest.php @@ -12,7 +12,7 @@ class AutocompleteListFormatterTest extends SharpTestCase /** @test */ public function we_can_format_value_to_front() { - $formatter = new AutocompleteListFormatter(); + $formatter = new AutocompleteListFormatter; $field = SharpFormAutocompleteListField::make('list') ->setItemField(SharpFormAutocompleteField::make('item', 'remote') ->setRemoteEndpoint('/endpoint'), @@ -31,7 +31,7 @@ public function we_can_format_value_to_front() /** @test */ public function we_can_format_value_from_front() { - $formatter = new AutocompleteListFormatter(); + $formatter = new AutocompleteListFormatter; $field = SharpFormAutocompleteListField::make('list') ->setItemField(SharpFormAutocompleteField::make('item', 'remote') ->setRemoteEndpoint('/endpoint'), diff --git a/tests/Unit/Form/Fields/Formatters/FieldWithDataLocalizationFormatterTest.php b/tests/Unit/Form/Fields/Formatters/FieldWithDataLocalizationFormatterTest.php index f7d2b4392..8cc278d44 100644 --- a/tests/Unit/Form/Fields/Formatters/FieldWithDataLocalizationFormatterTest.php +++ b/tests/Unit/Form/Fields/Formatters/FieldWithDataLocalizationFormatterTest.php @@ -20,7 +20,7 @@ public function we_add_missing_locales_when_formatting_a_localized_text_value_fr $this->assertEquals( ['fr' => $value, 'en' => null, 'es' => null], - (new TextFormatter()) + (new TextFormatter) ->setDataLocalizations(['fr', 'en', 'es']) ->fromFront( SharpFormTextField::make('text')->setLocalized(), @@ -37,7 +37,7 @@ public function we_format_locales_when_formatting_a_localized_text_value_from_fr $this->assertEquals( ['fr' => null, 'en' => $value, 'es' => null], - (new TextFormatter()) + (new TextFormatter) ->setDataLocalizations(['fr', 'en', 'es']) ->fromFront( SharpFormTextField::make('md')->setLocalized(), @@ -52,7 +52,7 @@ public function we_set_all_locales_to_null_when_formatting_a_null_localized_text { $this->assertEquals( ['fr' => null, 'en' => null, 'es' => null], - (new TextFormatter()) + (new TextFormatter) ->setDataLocalizations(['fr', 'en', 'es']) ->fromFront( SharpFormTextField::make('md')->setLocalized(), @@ -86,7 +86,7 @@ public function we_format_locales_when_formatting_a_localized_text_value_from_fr $this->assertEquals( ['fr' => null, 'en' => $value, 'es' => null], - (new TextareaFormatter()) + (new TextareaFormatter) ->setDataLocalizations(['fr', 'en', 'es']) ->fromFront( SharpFormTextareaField::make('md')->setLocalized(), @@ -135,7 +135,7 @@ public function we_stand_to_null_when_formatting_a_null_localized_text_value_fro { $this->assertEquals( null, - (new EditorFormatter()) + (new EditorFormatter) ->setDataLocalizations(['fr', 'en', 'es']) ->fromFront( SharpFormEditorField::make('md')->setLocalized(), diff --git a/tests/Unit/Form/Fields/Formatters/GeolocationFormatterTest.php b/tests/Unit/Form/Fields/Formatters/GeolocationFormatterTest.php index be984cc5b..d8769242e 100644 --- a/tests/Unit/Form/Fields/Formatters/GeolocationFormatterTest.php +++ b/tests/Unit/Form/Fields/Formatters/GeolocationFormatterTest.php @@ -11,7 +11,7 @@ class GeolocationFormatterTest extends SharpTestCase /** @test */ public function we_can_format_value_to_front() { - $formatter = new GeolocationFormatter(); + $formatter = new GeolocationFormatter; $field = SharpFormGeolocationField::make('geo'); $this->assertEquals(['lat' => 12.3, 'lng' => 24.5], $formatter->toFront($field, '12.3,24.5')); @@ -23,7 +23,7 @@ public function we_can_format_value_to_front() /** @test */ public function we_can_format_value_from_front() { - $formatter = new GeolocationFormatter(); + $formatter = new GeolocationFormatter; $attribute = 'attribute'; $field = SharpFormGeolocationField::make('geo'); diff --git a/tests/Unit/Form/Fields/Formatters/HtmlFormatterTest.php b/tests/Unit/Form/Fields/Formatters/HtmlFormatterTest.php index 5132af280..02261f430 100644 --- a/tests/Unit/Form/Fields/Formatters/HtmlFormatterTest.php +++ b/tests/Unit/Form/Fields/Formatters/HtmlFormatterTest.php @@ -14,14 +14,14 @@ public function we_can_format_value_to_front() { $value = Str::random(); - $this->assertEquals($value, (new HtmlFormatter())->toFront(SharpFormHtmlField::make('html'), $value)); + $this->assertEquals($value, (new HtmlFormatter)->toFront(SharpFormHtmlField::make('html'), $value)); } /** @test */ public function we_can_format_value_from_front() { $this->assertNull( - (new HtmlFormatter())->fromFront(SharpFormHtmlField::make('html'), 'attribute', Str::random()), + (new HtmlFormatter)->fromFront(SharpFormHtmlField::make('html'), 'attribute', Str::random()), ); } } diff --git a/tests/Unit/Form/Fields/Formatters/ListFormatterTest.php b/tests/Unit/Form/Fields/Formatters/ListFormatterTest.php index d0a99febf..1211f3faf 100644 --- a/tests/Unit/Form/Fields/Formatters/ListFormatterTest.php +++ b/tests/Unit/Form/Fields/Formatters/ListFormatterTest.php @@ -131,9 +131,6 @@ public function we_can_format_sub_value_to_front() ], $formatter->toFront($field, $data)); } - /** - * @return array - */ protected function getData(): array { return [ diff --git a/tests/Unit/Form/Fields/SharpFormAutocompleteFieldTest.php b/tests/Unit/Form/Fields/SharpFormAutocompleteFieldTest.php index b142466f5..4cb83a337 100644 --- a/tests/Unit/Form/Fields/SharpFormAutocompleteFieldTest.php +++ b/tests/Unit/Form/Fields/SharpFormAutocompleteFieldTest.php @@ -377,7 +377,6 @@ private function getDefaultLocalAutocomplete($localValues = null) /** * @param string $remoteEndpoint - * @param array $defaultValues * @return SharpFormAutocompleteField */ private function getDefaultDynamicRemoteAutocomplete($remoteEndpoint, array $defaultValues = []) diff --git a/tests/Unit/Form/Fields/SharpFormFieldsTest.php b/tests/Unit/Form/Fields/SharpFormFieldsTest.php index af1102d29..6c8853fb4 100644 --- a/tests/Unit/Form/Fields/SharpFormFieldsTest.php +++ b/tests/Unit/Form/Fields/SharpFormFieldsTest.php @@ -60,11 +60,7 @@ public function update($id, array $data) return false; } - public function delete($id): void - { - } + public function delete($id): void {} - public function buildFormLayout(FormLayout $formLayout): void - { - } + public function buildFormLayout(FormLayout $formLayout): void {} } diff --git a/tests/Unit/Form/Fields/SharpFormTest.php b/tests/Unit/Form/Fields/SharpFormTest.php index aae803e06..6c5517dde 100644 --- a/tests/Unit/Form/Fields/SharpFormTest.php +++ b/tests/Unit/Form/Fields/SharpFormTest.php @@ -119,23 +119,13 @@ public function buildFormFields(FieldsContainer $formFields): void abstract class SharpFormTestForm extends SharpForm { - public function find($id): array - { - } + public function find($id): array {} - public function update($id, array $data): bool - { - } + public function update($id, array $data): bool {} - public function delete($id): void - { - } + public function delete($id): void {} - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} - public function buildFormLayout(FormLayout $formLayout): void - { - } + public function buildFormLayout(FormLayout $formLayout): void {} } diff --git a/tests/Unit/Form/Layout/FormLayoutTest.php b/tests/Unit/Form/Layout/FormLayoutTest.php index 5d94f9c41..ae27813f0 100644 --- a/tests/Unit/Form/Layout/FormLayoutTest.php +++ b/tests/Unit/Form/Layout/FormLayoutTest.php @@ -98,11 +98,7 @@ public function update($id, array $data) return false; } - public function delete($id): void - { - } + public function delete($id): void {} - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} } diff --git a/tests/Unit/Form/SharpFormTest.php b/tests/Unit/Form/SharpFormTest.php index 2332db2ed..1d364f25b 100644 --- a/tests/Unit/Form/SharpFormTest.php +++ b/tests/Unit/Form/SharpFormTest.php @@ -78,14 +78,12 @@ public function buildFormFields(FieldsContainer $formFields): void SharpFormTextField::make('delayed') ->setFormatter(new class extends SharpFieldFormatter { - public function toFront(SharpFormField $field, $value) - { - } + public function toFront(SharpFormField $field, $value) {} public function fromFront(SharpFormField $field, string $attribute, $value) { if (! $this->instanceId) { - throw new SharpFormFieldFormattingMustBeDelayedException(); + throw new SharpFormFieldFormattingMustBeDelayedException; } return $value.'-'.$this->instanceId; @@ -132,13 +130,11 @@ public function buildFormFields(FieldsContainer $formFields): void SharpFormTextField::make('delayed') ->setFormatter(new class extends SharpFieldFormatter { - public function toFront(SharpFormField $field, $value) - { - } + public function toFront(SharpFormField $field, $value) {} public function fromFront(SharpFormField $field, string $attribute, $value) { - throw new SharpFormFieldFormattingMustBeDelayedException(); + throw new SharpFormFieldFormattingMustBeDelayedException; } }), ); @@ -154,8 +150,7 @@ public function fromFront(SharpFormField $field, string $attribute, $value) /** @test */ public function single_forms_are_declared_in_config() { - $sharpForm = new class extends BaseSharpSingleForm { - }; + $sharpForm = new class extends BaseSharpSingleForm {}; $sharpForm->buildFormConfig(); @@ -194,42 +189,24 @@ public function buildFormConfig(): void class BaseSharpForm extends SharpForm { - public function find($id): array - { - } + public function find($id): array {} - public function update($id, array $data) - { - } + public function update($id, array $data) {} - public function delete($id): void - { - } + public function delete($id): void {} - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} - public function buildFormLayout(FormLayout $formLayout): void - { - } + public function buildFormLayout(FormLayout $formLayout): void {} } class BaseSharpSingleForm extends SharpSingleForm { - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} - public function buildFormLayout(FormLayout $formLayout): void - { - } + public function buildFormLayout(FormLayout $formLayout): void {} - protected function findSingle() - { - } + protected function findSingle() {} - protected function updateSingle(array $data) - { - } + protected function updateSingle(array $data) {} } diff --git a/tests/Unit/Form/WithCustomTransformersInFormTest.php b/tests/Unit/Form/WithCustomTransformersInFormTest.php index 81207c977..b560e6fd1 100644 --- a/tests/Unit/Form/WithCustomTransformersInFormTest.php +++ b/tests/Unit/Form/WithCustomTransformersInFormTest.php @@ -23,7 +23,7 @@ public function we_can_retrieve_an_array_version_of_a_model() 'name' => 'John Wayne', ]); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset([ 'name' => 'John Wayne', @@ -42,7 +42,7 @@ public function we_can_retrieve_an_array_version_of_a_stdclass() public function find($id): array { return $this->transform( - DB::table((new Person())->getTable())->where(['id' => $id])->first(), + DB::table((new Person)->getTable())->where(['id' => $id])->first(), ); } }; @@ -64,7 +64,7 @@ public function belongsTo_is_handled() 'mother_id' => $mother->id, ]); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset([ 'mother_id' => $person->mother_id, @@ -85,7 +85,7 @@ public function hasOne_is_handled() 'mother_id' => $mother->id, ]); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset( [ @@ -112,7 +112,7 @@ public function hasMany_is_handled() 'mother_id' => $mother->id, ]); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset([ 'sons' => [ @@ -142,7 +142,7 @@ public function belongsToMany_is_handled() $person2->id, $person3->id, ]); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset([ 'friends' => [ @@ -159,7 +159,7 @@ public function morphOne_is_handled() $person = Person::create(['name' => 'John Wayne']); $person->picture()->create(['file' => 'test.jpg']); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset( [ @@ -175,7 +175,7 @@ public function morphMany_is_handled() $person = Person::create(['name' => 'John Wayne']); $person->pictures()->create(['file' => 'test.jpg']); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $this->assertArraySubset( [ @@ -222,7 +222,7 @@ public function we_can_use_a_closure_as_a_custom_transformer() 'name' => 'John Wayne', ]); - $form = new WithCustomTransformersTestForm(); + $form = new WithCustomTransformersTestForm; $form->setCustomTransformer('name', function ($name) { return strtoupper($name); }); @@ -360,17 +360,11 @@ public function update($id, array $data): bool return false; } - public function delete($id): void - { - } + public function delete($id): void {} - public function buildFormLayout(FormLayout $formLayout): void - { - } + public function buildFormLayout(FormLayout $formLayout): void {} - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} } class SharpAttributeUppercaseTransformer implements SharpAttributeTransformer diff --git a/tests/Unit/Show/Layout/ShowLayoutTest.php b/tests/Unit/Show/Layout/ShowLayoutTest.php index 768b87619..6e6578d2d 100644 --- a/tests/Unit/Show/Layout/ShowLayoutTest.php +++ b/tests/Unit/Show/Layout/ShowLayoutTest.php @@ -113,15 +113,9 @@ public function find($id): array return []; } - public function buildShowFields(FieldsContainer $showFields): void - { - } + public function buildShowFields(FieldsContainer $showFields): void {} - public function buildShowLayout(ShowLayout $showLayout): void - { - } + public function buildShowLayout(ShowLayout $showLayout): void {} - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} } diff --git a/tests/Unit/Show/SharpShowTestDefault.php b/tests/Unit/Show/SharpShowTestDefault.php index 76c06679b..456fe2150 100644 --- a/tests/Unit/Show/SharpShowTestDefault.php +++ b/tests/Unit/Show/SharpShowTestDefault.php @@ -191,7 +191,7 @@ public function we_can_declare_a_global_message_field() { public function buildShowConfig(): void { - $this->configurePageAlert('template', static::$pageAlertLevelWarning, 'test-key'); + $this->configurePageAlert('template', self::$pageAlertLevelWarning, 'test-key'); } }; @@ -306,8 +306,7 @@ public function find($id): array /** @test */ public function single_shows_have_are_declared_in_config() { - $sharpShow = new class extends BaseSharpSingleShowTestDefault { - }; + $sharpShow = new class extends BaseSharpSingleShowTestDefault {}; $this->assertArraySubset( [ diff --git a/tests/Unit/Show/Utils/BaseSharpShowTestDefault.php b/tests/Unit/Show/Utils/BaseSharpShowTestDefault.php index 1680bcc2e..d3dfbf767 100644 --- a/tests/Unit/Show/Utils/BaseSharpShowTestDefault.php +++ b/tests/Unit/Show/Utils/BaseSharpShowTestDefault.php @@ -8,19 +8,11 @@ class BaseSharpShowTestDefault extends SharpShow { - public function find($id): array - { - } + public function find($id): array {} - public function buildShowFields(FieldsContainer $showFields): void - { - } + public function buildShowFields(FieldsContainer $showFields): void {} - public function buildShowLayout(ShowLayout $showLayout): void - { - } + public function buildShowLayout(ShowLayout $showLayout): void {} - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} } diff --git a/tests/Unit/Show/Utils/BaseSharpSingleShowTestDefault.php b/tests/Unit/Show/Utils/BaseSharpSingleShowTestDefault.php index 43eb468b8..9e3d91ff1 100644 --- a/tests/Unit/Show/Utils/BaseSharpSingleShowTestDefault.php +++ b/tests/Unit/Show/Utils/BaseSharpSingleShowTestDefault.php @@ -8,15 +8,9 @@ class BaseSharpSingleShowTestDefault extends SharpSingleShow { - public function buildShowFields(FieldsContainer $showFields): void - { - } + public function buildShowFields(FieldsContainer $showFields): void {} - public function buildShowLayout(ShowLayout $showLayout): void - { - } + public function buildShowLayout(ShowLayout $showLayout): void {} - public function findSingle(): array - { - } + public function findSingle(): array {} } diff --git a/tests/Unit/Utils/FileUtilTest.php b/tests/Unit/Utils/FileUtilTest.php index dade28659..bab6e7ada 100644 --- a/tests/Unit/Utils/FileUtilTest.php +++ b/tests/Unit/Utils/FileUtilTest.php @@ -18,7 +18,7 @@ protected function setUp(): void /** @test */ public function we_keep_the_file_name_if_it_is_the_first_one() { - $fileUtil = new FileUtil(); + $fileUtil = new FileUtil; $this->assertEquals( 'test.txt', @@ -29,7 +29,7 @@ public function we_keep_the_file_name_if_it_is_the_first_one() /** @test */ public function we_add_a_number_suffix_if_needed() { - $fileUtil = new FileUtil(); + $fileUtil = new FileUtil; mkdir(storage_path('app/tmp/')); touch(storage_path('app/tmp/test.txt')); @@ -50,7 +50,7 @@ public function we_add_a_number_suffix_if_needed() /** @test */ public function we_normalize_file_name() { - $fileUtil = new FileUtil(); + $fileUtil = new FileUtil; $this->assertEquals( 'test.txt', diff --git a/tests/Unit/Utils/Transformers/MarkdownAttributeTransformerTest.php b/tests/Unit/Utils/Transformers/MarkdownAttributeTransformerTest.php index 2cd9c4f16..fb7740dbc 100644 --- a/tests/Unit/Utils/Transformers/MarkdownAttributeTransformerTest.php +++ b/tests/Unit/Utils/Transformers/MarkdownAttributeTransformerTest.php @@ -16,7 +16,7 @@ public function we_can_transform_a_text_to_markdown() $this->assertEquals( "

some basic markdown test

\n", - (new MarkdownAttributeTransformer())->apply($object->text, $object, 'text'), + (new MarkdownAttributeTransformer)->apply($object->text, $object, 'text'), ); } }