From d2724d6d0b1c6b855bc30f99aac548a1d5b28dd4 Mon Sep 17 00:00:00 2001 From: Andre Sonnichsen Date: Sat, 8 Jun 2024 10:35:34 -0700 Subject: [PATCH 1/5] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2954bf..b57bd6b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ when updating laravel version: - MethodCallingRule comes back - HasTraits booting/initialize of traits - getForeignKey -> getForeignKeyName for BelongsTo -- WithJson can use Resources + - WithJson can use Resources # Laravel Support Package From 589fa97cfa360b35b1003dd569a297efabe796d8 Mon Sep 17 00:00:00 2001 From: Andre Sonnichsen Date: Sat, 8 Jun 2024 11:21:04 -0700 Subject: [PATCH 2/5] typehinting arrays/Collections --- devops/containers/compose.env | 1 + devops/containers/compose.yml | 17 ++++++++++++++ devops/containers/dev/Dockerfile | 19 ++++++++++++++++ devops/phpstan.neon | 1 - src/Blade/FormBuilder.php | 14 ++++++------ src/Blade/FormOptionsHelper.php | 26 +++++++++++----------- src/Blade/Tags/CollectionHelpers.php | 2 +- src/Blade/Tags/CollectionSelect.php | 2 +- src/Blade/Tags/GroupedCollectionSelect.php | 2 +- src/Eloquent/AutosavesRelations.php | 2 +- src/Eloquent/FluentModel.php | 7 ++++-- src/Eloquent/Model.php | 2 +- src/Eloquent/Naming/Name.php | 3 +++ src/Eloquent/Transactions.php | 6 ++--- src/Libs/StrongParameters/Parameters.php | 4 ++++ 15 files changed, 77 insertions(+), 31 deletions(-) create mode 100644 devops/containers/compose.env create mode 100644 devops/containers/compose.yml create mode 100644 devops/containers/dev/Dockerfile diff --git a/devops/containers/compose.env b/devops/containers/compose.env new file mode 100644 index 0000000..56b8c9c --- /dev/null +++ b/devops/containers/compose.env @@ -0,0 +1 @@ +APP_SERVICE=support diff --git a/devops/containers/compose.yml b/devops/containers/compose.yml new file mode 100644 index 0000000..31e5002 --- /dev/null +++ b/devops/containers/compose.yml @@ -0,0 +1,17 @@ +version: '3' +name: support + +x-var-check: + - SUPPORT_PATH: ${SUPPORT_PATH?missing} + +services: + support: + image: vpf/support-php8.2-alpine3.19 + build: + context: ${SUPPORT_PATH} + dockerfile: ./devops/containers/dev/Dockerfile + volumes: + - type: bind + source: ${SUPPORT_PATH} + target: /var/www/html + diff --git a/devops/containers/dev/Dockerfile b/devops/containers/dev/Dockerfile new file mode 100644 index 0000000..4edf859 --- /dev/null +++ b/devops/containers/dev/Dockerfile @@ -0,0 +1,19 @@ +FROM php:8.2-fpm-alpine3.19 + +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ +RUN install-php-extensions \ + bz2 \ + calendar \ + exif \ + gd \ + gettext \ + intl \ + pcntl \ + pdo_mysql \ + shmop \ + sockets \ + zip + + +# install composer +COPY --from=composer:2.5 /usr/bin/composer /usr/bin/composer diff --git a/devops/phpstan.neon b/devops/phpstan.neon index f0aecab..43d8946 100644 --- a/devops/phpstan.neon +++ b/devops/phpstan.neon @@ -6,7 +6,6 @@ parameters: paths: - ../src - checkGenericClassInNonGenericObjectType: false reportUnmatchedIgnoredErrors: false ignoreErrors: diff --git a/src/Blade/FormBuilder.php b/src/Blade/FormBuilder.php index 0905711..af098f5 100644 --- a/src/Blade/FormBuilder.php +++ b/src/Blade/FormBuilder.php @@ -113,7 +113,7 @@ public function checkBox( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -139,7 +139,7 @@ public function collectionCheckBoxes( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -165,7 +165,7 @@ public function collectionRadioButtons( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -270,7 +270,7 @@ public function fileField(string $method, array $options = []): HtmlString { } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -532,7 +532,7 @@ public function yieldingButton( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions * @return HtmlStringGenerator @@ -562,7 +562,7 @@ public function yieldingCollectionCheckBoxes( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions * @return HtmlStringGenerator @@ -710,7 +710,7 @@ protected function yieldingFieldsForNestedModel(string $name, ?object $object, a } /** - * @param array|Model|Collection|null $association + * @param array|Model|Collection|null $association * @param OptionHash $options * @return HtmlStringGenerator */ diff --git a/src/Blade/FormOptionsHelper.php b/src/Blade/FormOptionsHelper.php index da384e9..8647ccb 100644 --- a/src/Blade/FormOptionsHelper.php +++ b/src/Blade/FormOptionsHelper.php @@ -22,7 +22,7 @@ trait FormOptionsHelper { use TagHelper; /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -58,7 +58,7 @@ public static function collectionCheckBoxes( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -94,7 +94,7 @@ public static function collectionRadioButtons( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -120,7 +120,7 @@ public static function collectionSelect( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -152,7 +152,7 @@ public static function groupedCollectionSelect( } /** - * @param array|Collection $groupedOptions + * @param array|Collection $groupedOptions * @param OptionHash $options */ public static function groupedOptionsForSelect( @@ -191,7 +191,7 @@ public static function groupedOptionsForSelect( } /** - * @param string|array|Collection $container + * @param string|array|Collection $container */ public static function optionsForSelect( string|array|Collection|null $container, @@ -237,7 +237,7 @@ public static function optionsForSelect( } /** - * @param array|Collection|QueryBuilder $collection + * @param array|Collection|QueryBuilder $collection */ public static function optionsFromCollectionForSelect( array|Collection|QueryBuilder $collection, @@ -267,7 +267,7 @@ public static function optionsFromCollectionForSelect( } /** - * @param array|Collection|QueryBuilder $collection + * @param array|Collection|QueryBuilder $collection */ public static function optionGroupsFromCollectionForSelect( array|Collection|QueryBuilder $collection, @@ -307,7 +307,7 @@ public static function optionGroupsFromCollectionForSelect( } /** - * @param string|Stringable|array|Collection|null $choices + * @param string|Stringable|array|Collection|null $choices * @param OptionHash $options * @param OptionHash $htmlOptions */ @@ -416,7 +416,7 @@ public static function weekdaySelect( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions * @return HtmlStringGenerator @@ -453,7 +453,7 @@ public static function yieldingCollectionCheckBoxes( } /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param OptionHash $options * @param OptionHash $htmlOptions * @return HtmlStringGenerator @@ -490,7 +490,7 @@ public static function yieldingCollectionRadioButtons( } /** - * @param string|Stringable|array|Collection|null $choices + * @param string|Stringable|array|Collection|null $choices * @param OptionHash $options * @param OptionHash $htmlOptions * @return HtmlStringGenerator @@ -576,7 +576,7 @@ protected static function extractSelectedAndDisabled(mixed $selected): array { } /** - * @param array|Collection $collection + * @param array|Collection $collection */ protected static function extractValuesFromCollection( array|Collection $collection, diff --git a/src/Blade/Tags/CollectionHelpers.php b/src/Blade/Tags/CollectionHelpers.php index 0905908..ed08173 100644 --- a/src/Blade/Tags/CollectionHelpers.php +++ b/src/Blade/Tags/CollectionHelpers.php @@ -16,7 +16,7 @@ trait CollectionHelpers { /** - * @param array|Collection|QueryBuilder|null $collection + * @param array|Collection|QueryBuilder|null $collection * @param array $options * @param array $htmlOptions */ diff --git a/src/Blade/Tags/CollectionSelect.php b/src/Blade/Tags/CollectionSelect.php index 326fbef..4187678 100644 --- a/src/Blade/Tags/CollectionSelect.php +++ b/src/Blade/Tags/CollectionSelect.php @@ -13,7 +13,7 @@ class CollectionSelect extends Base { /** - * @param array|Collection|QueryBuilder $collection + * @param array|Collection|QueryBuilder $collection * @param array $options * @param array $htmlOptions */ diff --git a/src/Blade/Tags/GroupedCollectionSelect.php b/src/Blade/Tags/GroupedCollectionSelect.php index e6d06eb..741c23d 100644 --- a/src/Blade/Tags/GroupedCollectionSelect.php +++ b/src/Blade/Tags/GroupedCollectionSelect.php @@ -13,7 +13,7 @@ class GroupedCollectionSelect extends Base { /** - * @param array|Collection|QueryBuilder $collection + * @param array|Collection|QueryBuilder $collection * @param array $options * @param array $htmlOptions */ diff --git a/src/Eloquent/AutosavesRelations.php b/src/Eloquent/AutosavesRelations.php index 2769b09..9f8ff67 100644 --- a/src/Eloquent/AutosavesRelations.php +++ b/src/Eloquent/AutosavesRelations.php @@ -182,7 +182,7 @@ protected function pushAutosavedModels(?array $models, string $relationName, arr } /** - * @param Collection|Model|array|null $value + * @param Collection|Model|array|null $value * @param array $pushOptions */ protected function pushAutosavedRelation( diff --git a/src/Eloquent/FluentModel.php b/src/Eloquent/FluentModel.php index 789843f..9dd4152 100644 --- a/src/Eloquent/FluentModel.php +++ b/src/Eloquent/FluentModel.php @@ -8,6 +8,9 @@ use Illuminate\Support\Str; use SilvertipSoftware\LaravelSupport\Libs\StrongParameters\Parameters; +/** + * @extends Fluent + */ class FluentModel extends Fluent implements ModelContract { use HasEvents, Naming, @@ -15,7 +18,7 @@ class FluentModel extends Fluent implements ModelContract { Validation; /** - * @param array|Arrayable $attributes + * @param array|Arrayable $attributes */ public function __construct(array|Arrayable $attributes = []) { parent::__construct([]); @@ -25,7 +28,7 @@ public function __construct(array|Arrayable $attributes = []) { } /** - * @param array|Arrayable $attributes + * @param array|Arrayable $attributes */ public function fill(array|Arrayable $attributes): static { $attributes = $attributes instanceof Arrayable diff --git a/src/Eloquent/Model.php b/src/Eloquent/Model.php index 1df2420..80b99a7 100644 --- a/src/Eloquent/Model.php +++ b/src/Eloquent/Model.php @@ -20,7 +20,7 @@ class Model extends EloquentModel implements ModelContract { protected $guarded = []; /** - * @param array|Arrayable $attributes + * @param array|Arrayable $attributes */ public function __construct(array|Arrayable $attributes = []) { $attributes = $attributes instanceof Arrayable diff --git a/src/Eloquent/Naming/Name.php b/src/Eloquent/Naming/Name.php index 9599985..6b65736 100644 --- a/src/Eloquent/Naming/Name.php +++ b/src/Eloquent/Naming/Name.php @@ -8,6 +8,9 @@ use Illuminate\Support\Fluent; use Illuminate\Support\Str; +/** + * @extends Fluent + */ class Name extends Fluent { public static string|Closure $rootModelNamespace = 'App\\Models'; diff --git a/src/Eloquent/Transactions.php b/src/Eloquent/Transactions.php index c7f58f2..0688af7 100644 --- a/src/Eloquent/Transactions.php +++ b/src/Eloquent/Transactions.php @@ -12,7 +12,7 @@ trait Transactions { /** - * @param array|Arrayable $attributes + * @param array|Arrayable $attributes */ public static function createOrFail(array|Arrayable $attributes = []): static { $attrs = $attributes instanceof Arrayable @@ -62,7 +62,7 @@ public function saveOrFail(array $options = []): bool { } /** - * @param array|Arrayable $attributes + * @param array|Arrayable $attributes * @param array $options */ public function update(array|Arrayable $attributes = [], array $options = []) { @@ -77,7 +77,7 @@ public function update(array|Arrayable $attributes = [], array $options = []) { } /** - * @param array|Arrayable $attributes + * @param array|Arrayable $attributes * @param array $options */ public function updateOrFail(array|Arrayable $attributes = [], array $options = []) { diff --git a/src/Libs/StrongParameters/Parameters.php b/src/Libs/StrongParameters/Parameters.php index 4acfe89..75a7970 100644 --- a/src/Libs/StrongParameters/Parameters.php +++ b/src/Libs/StrongParameters/Parameters.php @@ -14,6 +14,10 @@ use RuntimeException; use SilvertipSoftware\LaravelSupport\Libs\ArrUtils; +/** + * @implements ArrayAccess + * @implements Arrayable + */ class Parameters implements Arrayable, ArrayAccess, Jsonable, JsonSerializable { /** @var array|Parameters> */ From 9aa71fc9b0d367ddfef1d80836a05cd3737ed31a Mon Sep 17 00:00:00 2001 From: Andre Sonnichsen Date: Sat, 8 Jun 2024 11:24:55 -0700 Subject: [PATCH 3/5] fix lint name in workflow --- .github/workflows/pr-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 3a50da6..aa5e92b 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -22,7 +22,7 @@ jobs: - name: PHP Lint run: | - composer run lint-php + composer run lint - name: Check code style run: | From 2a5457835d44c1fe4a5c4a1faff186b7529370b1 Mon Sep 17 00:00:00 2001 From: Andre Sonnichsen Date: Sat, 8 Jun 2024 11:38:53 -0700 Subject: [PATCH 4/5] fix validation errors --- .github/workflows/pr-test.yml | 12 ++---------- composer.json | 6 +++++- tests/models/TestModels.php | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index aa5e92b..3443caf 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -20,17 +20,9 @@ jobs: run: | composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: PHP Lint + - name: Code Validation run: | - composer run lint - - - name: Check code style - run: | - composer run cs - - - name: Check PHP compatibility - run: | - composer run cscompat8 + composer run code-validate phpunit: runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index 8c484a4..a25a807 100644 --- a/composer.json +++ b/composer.json @@ -23,10 +23,14 @@ }, "scripts": { "check-all": [ + "@code-validate", + "@ut" + ], + "code-validate": [ "@lint", "@cs", "@stan", - "@ut" + "@cscompat81" ], "cs": "vendor/bin/phpcs --standard=devops/style --report-width=80 --colors .", "lint": "vendor/bin/parallel-lint --exclude .git --exclude vendor --colors .", diff --git a/tests/models/TestModels.php b/tests/models/TestModels.php index 7ed09c8..a0868d8 100644 --- a/tests/models/TestModels.php +++ b/tests/models/TestModels.php @@ -21,7 +21,7 @@ public function lastBillAmount(): float { 1 => 100, 2 => 90, 3 => 0 - ])[$this->value]; + ])[$this->value]; // phpcs:ignore } } From ab90d4bc5243ee66b334a65c28026d6bf0f945f8 Mon Sep 17 00:00:00 2001 From: Andre Sonnichsen Date: Sat, 8 Jun 2024 11:42:54 -0700 Subject: [PATCH 5/5] ignore all of views dir --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a25a807..74e20ea 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,6 @@ "lint": "vendor/bin/parallel-lint --exclude .git --exclude vendor --colors .", "stan": "vendor/bin/phpstan analyse --configuration=devops/phpstan.neon", "ut": "vendor/bin/phpunit", - "cscompat81": "vendor/bin/phpcs --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --colors --runtime-set testVersion 8.1- --ignore=blade.php src tests" + "cscompat81": "vendor/bin/phpcs --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --colors --runtime-set testVersion 8.1- --ignore=tests/views/ src tests" } }