From b7ddffb564f6b74279a01111e9680f5c60017de6 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 12 Feb 2023 22:37:49 +0100 Subject: [PATCH] Lint --- app/Initialize/InitializeMembers.php | 3 +- app/Member/MemberRequest.php | 2 - phpstan-baseline.neon | 38 ++- phpstan.neon | 218 ++---------------- .../RequestFactories/MemberRequestFactory.php | 3 + 5 files changed, 63 insertions(+), 201 deletions(-) diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index 35c1fac7..af0cf8e2 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -10,6 +10,7 @@ use DB; use Illuminate\Console\Command; use Lorisleiva\Actions\Concerns\AsAction; use Zoomyboy\LaravelNami\Api; +use Zoomyboy\LaravelNami\Data\MemberEntry as NamiMember; use Zoomyboy\LaravelNami\Exceptions\Skippable; class InitializeMembers @@ -22,7 +23,7 @@ class InitializeMembers { $allMembers = collect([]); - $api->search([])->each(function ($member) { + $api->search([])->each(function (NamiMember $member) { try { $localMember = app(PullMemberAction::class)->handle($member->groupId, $member->id); } catch (Skippable $e) { diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index 41e6fed2..3f12d28e 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -53,9 +53,7 @@ class MemberRequest extends FormRequest 'zip' => 'required|numeric', 'location' => 'required', 'birthday' => 'date|required', - 'region_id' => 'nullable|exists:regions,id', 'country_id' => 'required|exists:countries,id', - 'nationality_id' => 'required|exists:nationalities,id', 'email' => 'nullable|email', 'email_parents' => 'nullable|email', 'bill_kind' => ['nullable', Rule::in(BillKind::values())], diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index baebd67a..73308de5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,11 +1,41 @@ parameters: ignoreErrors: - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$first_activity_id\\.$#" + message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\LazyCollection\\\\:\\:each\\(\\) expects callable\\(int, int\\)\\: mixed, Closure\\(Zoomyboy\\\\LaravelNami\\\\Data\\\\MemberEntry\\)\\: void given\\.$#" count: 1 - path: packages/laravel-nami/src/Member.php + path: app/Initialize/InitializeMembers.php - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$first_subactivity_id\\.$#" + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:never\\(\\)\\.$#" count: 1 - path: packages/laravel-nami/src/Member.php + path: tests/Feature/Initialize/InitializeActionTest.php + + - + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:with\\(\\)\\.$#" + count: 1 + path: tests/Feature/Initialize/InitializeActionTest.php + + - + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#" + count: 10 + path: tests/Feature/Initialize/InitializeMembersTest.php + + - + message: "#^Parameter \\#1 \\$mock of static method Phake\\:\\:verify\\(\\) expects Phake\\\\IMock, App\\\\Actions\\\\PullMemberAction given\\.$#" + count: 1 + path: tests/Feature/Member/NamiPutMemberActionTest.php + + - + message: "#^Parameter \\#1 \\$mock of static method Phake\\:\\:verify\\(\\) expects Phake\\\\IMock, App\\\\Actions\\\\PullMembershipsAction given\\.$#" + count: 1 + path: tests/Feature/Member/NamiPutMemberActionTest.php + + - + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:never\\(\\)\\.$#" + count: 4 + path: tests/Feature/Member/ResyncTest.php + + - + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#" + count: 2 + path: tests/Feature/Member/ResyncTest.php diff --git a/phpstan.neon b/phpstan.neon index 73569689..aeeffc84 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,21 +15,6 @@ parameters: level: 6 ignoreErrors: - - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$fee_id\\.$#" - count: 1 - path: app/Actions/MemberPullAction.php - - - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$group_name\\.$#" - count: 1 - path: app/Actions/MemberPullAction.php - - - - message: "#^Method App\\\\Actions\\\\MemberPullAction\\:\\:fetchMembership\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Actions/MemberPullAction.php - - message: "#^Method App\\\\Activity\\:\\:sluggable\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -40,11 +25,6 @@ parameters: count: 1 path: app/Activity.php - - - message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\LazyCollection\\\\:\\:each\\(\\) expects callable\\(int, int\\)\\: mixed, Closure\\(Zoomyboy\\\\LaravelNami\\\\Member\\)\\: void given\\.$#" - count: 1 - path: app/Console/Commands/MemberResyncCommand.php - - message: "#^Property App\\\\Console\\\\Kernel\\:\\:\\$commands type has no value type specified in iterable type array\\.$#" count: 1 @@ -195,11 +175,6 @@ parameters: count: 1 path: app/Http/Views/MemberView.php - - - message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\LazyCollection\\\\:\\:each\\(\\) expects callable\\(int, int\\)\\: mixed, Closure\\(Zoomyboy\\\\LaravelNami\\\\Member\\)\\: void given\\.$#" - count: 1 - path: app/Initialize/InitializeMembers.php - - message: "#^Access to an undefined property Sabre\\\\VObject\\\\Document\\:\\:\\$ADR\\.$#" count: 1 @@ -220,31 +195,11 @@ parameters: count: 1 path: app/Member/Member.php - - - message: "#^Method App\\\\Member\\\\Member\\:\\:getNamiMemberships\\(\\) has invalid return type App\\\\Member\\\\Collection\\.$#" - count: 1 - path: app/Member/Member.php - - - - message: "#^Method App\\\\Member\\\\Member\\:\\:getNamiMemberships\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Member/Member.php - - - - message: "#^Method App\\\\Member\\\\Member\\:\\:getNamiMemberships\\(\\) should return array but returns Illuminate\\\\Support\\\\Collection\\\\.$#" - count: 1 - path: app/Member/Member.php - - message: "#^Method App\\\\Member\\\\Member\\:\\:scopeFilter\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" count: 1 path: app/Member/Member.php - - - message: "#^PHPDoc tag @return with type App\\\\Member\\\\Collection\\ is incompatible with native type array\\.$#" - count: 1 - path: app/Member/Member.php - - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 1 @@ -255,16 +210,6 @@ parameters: count: 1 path: app/Member/MemberController.php - - - message: "#^Array has 2 duplicate keys with value 'nationality_id' \\('nationality_id', 'nationality_id'\\)\\.$#" - count: 1 - path: app/Member/MemberRequest.php - - - - message: "#^Array has 2 duplicate keys with value 'region_id' \\('region_id', 'region_id'\\)\\.$#" - count: 1 - path: app/Member/MemberRequest.php - - message: "#^Method App\\\\Member\\\\MemberRequest\\:\\:rules\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -360,31 +305,6 @@ parameters: count: 1 path: database/factories/SubactivityFactory.php - - - message: "#^Method Tests\\\\Feature\\\\Initialize\\\\InitializeTest\\:\\:membershipDataProvider\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Feature/Initialize/InitializeTest.php - - - - message: "#^Method Tests\\\\Feature\\\\Initialize\\\\InitializeTest\\:\\:testSyncMembershipsOfMember\\(\\) has parameter \\$membership with no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Feature/Initialize/InitializeTest.php - - - - message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:never\\(\\)\\.$#" - count: 3 - path: tests/Feature/Initialize/RequestTest.php - - - - message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:with\\(\\)\\.$#" - count: 1 - path: tests/Feature/Initialize/RequestTest.php - - - - message: "#^Parameter \\#1 \\$mock of static method Phake\\:\\:verify\\(\\) expects Phake\\\\IMock, App\\\\Initialize\\\\Initializer given\\.$#" - count: 1 - path: tests/Feature/Initialize/RequestTest.php - - message: "#^Call to an undefined method Phake\\\\Proxies\\\\StubberProxy.*#" @@ -529,16 +449,6 @@ parameters: count: 1 path: packages/laravel-nami/src/Country.php - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Data\\\\Membership\\:\\:fromArray\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/src/Data/Membership.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Data\\\\Membership\\:\\:toNami\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/src/Data/Membership.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Fakes\\\\BausteinFake\\:\\:fetches\\(\\) has parameter \\$courses with no value type specified in iterable type array\\.$#" count: 1 @@ -549,11 +459,6 @@ parameters: count: 1 path: packages/laravel-nami/src/Fakes/BausteinFake.php - - - message: "#^Property Zoomyboy\\\\LaravelNami\\\\Fakes\\\\CourseFake\\:\\:\\$defaults type has no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/src/Fakes/CourseFake.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Fakes\\\\Fake\\:\\:dataResponse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" count: 1 @@ -634,11 +539,6 @@ parameters: count: 1 path: packages/laravel-nami/src/Group.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: packages/laravel-nami/src/Group.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Logger\\:\\:__construct\\(\\) has parameter \\$options with no type specified\\.$#" count: 1 @@ -754,86 +654,6 @@ parameters: count: 1 path: packages/laravel-nami/src/LoginException.php - - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$fee_id\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Array has 2 duplicate keys with value 'geburtsDatum' \\('geburtsDatum', 'geburtsDatum'\\)\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Member\\:\\:fromAttributes\\(\\) has parameter \\$attributes with no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Member\\:\\:fromNami\\(\\) has parameter \\$item with no type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Member\\:\\:setGeschlechtTextAttribute\\(\\) has no return type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Member\\:\\:setGeschlechtTextAttribute\\(\\) has parameter \\$v with no type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Member\\:\\:toNami\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$casts type has no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$geschlechtMaps has no type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$nullable has no type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$overviewAttributes has no type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Unable to resolve the template type TKey in call to function collect$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Unable to resolve the template type TValue in call to function collect$#" - count: 1 - path: packages/laravel-nami/src/Member.php - - - - message: "#^Call to an undefined static method Zoomyboy\\\\LaravelNami\\\\Member\\:\\:fromOverview\\(\\)\\.$#" - count: 1 - path: packages/laravel-nami/src/MemberCollection.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\MemberCollection\\:\\:fromOverview\\(\\) has no return type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/MemberCollection.php - - - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\MemberCollection\\:\\:fromOverview\\(\\) has parameter \\$items with no type specified\\.$#" - count: 1 - path: packages/laravel-nami/src/MemberCollection.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\NamiException\\:\\:getData\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -973,33 +793,43 @@ parameters: message: "#^Method Zoomyboy\\\\LaravelNami\\\\Tests\\\\TestCase\\:\\:getAnnotations\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: packages/laravel-nami/tests/TestCase.php + - + message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\LazyCollection\\\\:\\:each\\(\\) expects callable\\(int, int\\)\\: mixed, Closure\\(Zoomyboy\\\\LaravelNami\\\\Data\\\\MemberEntry\\)\\: void given\\.$#" + count: 1 + path: app/Initialize/InitializeMembers.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Tests\\\\Unit\\\\PushMemberTest\\:\\:dataProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:never\\(\\)\\.$#" count: 1 - path: packages/laravel-nami/tests/Unit/PushMemberTest.php + path: tests/Feature/Initialize/InitializeActionTest.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Tests\\\\Unit\\\\PushMemberTest\\:\\:testPushASingleMember\\(\\) has parameter \\$check with no value type specified in iterable type array\\.$#" + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:with\\(\\)\\.$#" count: 1 - path: packages/laravel-nami/tests/Unit/PushMemberTest.php + path: tests/Feature/Initialize/InitializeActionTest.php - - message: "#^Method Zoomyboy\\\\LaravelNami\\\\Tests\\\\Unit\\\\PushMemberTest\\:\\:testPushASingleMember\\(\\) has parameter \\$overwrites with no value type specified in iterable type array\\.$#" - count: 1 - path: packages/laravel-nami/tests/Unit/PushMemberTest.php + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#" + count: 10 + path: tests/Feature/Initialize/InitializeMembersTest.php - - message: "#^Property Zoomyboy\\\\LaravelNami\\\\Tests\\\\Unit\\\\PushMemberTest\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#" + message: "#^Parameter \\#1 \\$mock of static method Phake\\:\\:verify\\(\\) expects Phake\\\\IMock, App\\\\Actions\\\\PullMemberAction given\\.$#" count: 1 - path: packages/laravel-nami/tests/Unit/PushMemberTest.php + path: tests/Feature/Member/NamiPutMemberActionTest.php - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$first_activity_id\\.$#" + message: "#^Parameter \\#1 \\$mock of static method Phake\\:\\:verify\\(\\) expects Phake\\\\IMock, App\\\\Actions\\\\PullMembershipsAction given\\.$#" count: 1 - path: packages/laravel-nami/src/Member.php + path: tests/Feature/Member/NamiPutMemberActionTest.php - - message: "#^Access to an undefined property Zoomyboy\\\\LaravelNami\\\\Member\\:\\:\\$first_subactivity_id\\.$#" - count: 1 - path: packages/laravel-nami/src/Member.php + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:never\\(\\)\\.$#" + count: 4 + path: tests/Feature/Member/ResyncTest.php + + - + message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#" + count: 2 + path: tests/Feature/Member/ResyncTest.php + diff --git a/tests/RequestFactories/MemberRequestFactory.php b/tests/RequestFactories/MemberRequestFactory.php index 9adb65f2..1f4658f4 100644 --- a/tests/RequestFactories/MemberRequestFactory.php +++ b/tests/RequestFactories/MemberRequestFactory.php @@ -6,6 +6,9 @@ use Worksome\RequestFactories\RequestFactory; class MemberRequestFactory extends RequestFactory { + /** + * @return array + */ public function definition(): array { return [