From 5632ed60e206528761ac7fefa62f532eb57a8a43 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 12 Feb 2022 15:33:16 +0100 Subject: [PATCH] Lint php --- app/Member/UpdateJob.php | 10 ++++++---- app/Payment/PaymentController.php | 17 ++++++++++++----- app/Payment/Status.php | 11 +++++++---- database/factories/FeeFactory.php | 3 +++ .../factories/Payment/SubscriptionFactory.php | 2 +- .../2021_11_18_215522_create_settings_table.php | 3 +++ tests/Feature/Member/IndexTest.php | 2 +- tests/TestCase.php | 3 ++- 8 files changed, 35 insertions(+), 16 deletions(-) diff --git a/app/Member/UpdateJob.php b/app/Member/UpdateJob.php index af6ed943..f56d2b43 100644 --- a/app/Member/UpdateJob.php +++ b/app/Member/UpdateJob.php @@ -3,22 +3,24 @@ namespace App\Member; use App\Confession; +use App\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Zoomyboy\LaravelNami\Nami; +use Zoomyboy\LaravelNami\NamiUser; class UpdateJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $memberId; - public $member; - public $user; + public int $memberId; + public Member $member; + public NamiUser $user; - public function __construct(Member $member, $user) + public function __construct(Member $member, NamiUser $user) { $this->memberId = $member->id; $this->user = $user; diff --git a/app/Payment/PaymentController.php b/app/Payment/PaymentController.php index ecb8a8f3..4c6e42c1 100644 --- a/app/Payment/PaymentController.php +++ b/app/Payment/PaymentController.php @@ -6,11 +6,14 @@ use App\Http\Controllers\Controller; use App\Http\Views\MemberView; use App\Member\Member; use App\Member\MemberResource; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Inertia\Response; class PaymentController extends Controller { - public function index(Request $request, Member $member) { + public function index(Request $request, Member $member): Response + { session()->put('menu', 'member'); session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); @@ -20,7 +23,8 @@ class PaymentController extends Controller return \Inertia::render('member/VIndex', $payload); } - public function store(Request $request, Member $member) { + public function store(Request $request, Member $member): RedirectResponse + { $member->createPayment($request->validate([ 'nr' => 'required|numeric', 'subscription_id' => 'required|exists:subscriptions,id', @@ -30,7 +34,8 @@ class PaymentController extends Controller return redirect()->back(); } - public function edit(Member $member, Request $request, Payment $payment) { + public function edit(Member $member, Request $request, Payment $payment): Response + { session()->put('menu', 'member'); session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); @@ -40,7 +45,8 @@ class PaymentController extends Controller return \Inertia::render('member/VIndex', $payload); } - public function update(Request $request, Member $member, Payment $payment) { + public function update(Request $request, Member $member, Payment $payment): RedirectResponse + { $payment->update($request->validate([ 'nr' => 'required|numeric', 'subscription_id' => 'required|exists:subscriptions,id', @@ -50,7 +56,8 @@ class PaymentController extends Controller return redirect()->back(); } - public function destroy(Request $request, Member $member, Payment $payment) { + public function destroy(Request $request, Member $member, Payment $payment): RedirectResponse + { $payment->delete(); return redirect()->back(); diff --git a/app/Payment/Status.php b/app/Payment/Status.php index b39070ae..e5e77ae7 100644 --- a/app/Payment/Status.php +++ b/app/Payment/Status.php @@ -2,6 +2,7 @@ namespace App\Payment; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -17,7 +18,8 @@ class Status extends Model ]; - public static function default() { + public static function default(): int + { return static::where('is_bill', true)->where('is_remember', true)->first()->id; } @@ -27,9 +29,10 @@ class Status extends Model } // ---------------------------------- Scopes ----------------------------------- - public function scopeNeedsPayment($q) { - return $q->where(function($q) { - $q->where('is_bill', true)->orWhere('is_remember', true); + public function scopeNeedsPayment(Builder $query): Builder + { + return $query->where(function(Builder $query): Builder { + return $query->where('is_bill', true)->orWhere('is_remember', true); }); } } diff --git a/database/factories/FeeFactory.php b/database/factories/FeeFactory.php index abe72525..af55bece 100644 --- a/database/factories/FeeFactory.php +++ b/database/factories/FeeFactory.php @@ -5,6 +5,9 @@ namespace Database\Factories; use App\Fee; use Illuminate\Database\Eloquent\Factories\Factory; +/** + * @extends Factory + */ class FeeFactory extends Factory { diff --git a/database/factories/Payment/SubscriptionFactory.php b/database/factories/Payment/SubscriptionFactory.php index e69aeb68..2ed22003 100644 --- a/database/factories/Payment/SubscriptionFactory.php +++ b/database/factories/Payment/SubscriptionFactory.php @@ -16,7 +16,7 @@ class SubscriptionFactory extends Factory return [ 'name' => $this->faker->word, 'amount' => $this->faker->numberBetween(1000, 50000), - 'fee_id' => Fee::factory()->create()->id, + 'fee_id' => Fee::factory()->createOne()->id, ]; } diff --git a/database/migrations/2021_11_18_215522_create_settings_table.php b/database/migrations/2021_11_18_215522_create_settings_table.php index b695f7a3..c4cee231 100644 --- a/database/migrations/2021_11_18_215522_create_settings_table.php +++ b/database/migrations/2021_11_18_215522_create_settings_table.php @@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Schema; class CreateSettingsTable extends Migration { + /** + * @return void + */ public function up() { Schema::create('settings', function (Blueprint $table): void { diff --git a/tests/Feature/Member/IndexTest.php b/tests/Feature/Member/IndexTest.php index 85b1326f..934bf18c 100644 --- a/tests/Feature/Member/IndexTest.php +++ b/tests/Feature/Member/IndexTest.php @@ -41,7 +41,7 @@ class IndexTest extends TestCase $response = $this->get('/member'); - $this->assertComponent('member/Index', $response); + $this->assertComponent('member/VIndex', $response); $this->assertInertiaHas('::firstname::', $response, 'data.data.0.firstname'); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 45245a14..fed9948f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -16,7 +16,8 @@ abstract class TestCase extends BaseTestCase use CreatesApplication; use TestsInertia; - public function fakeAuthUser() { + public function fakeAuthUser(): void + { app(FakeBackend::class) ->fakeLogin('123') ->addSearch(123, ['entries_vorname' => '::firstname::', 'entries_nachname' => '::lastname::', 'entries_gruppierungId' => 1000]);