Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/NewPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function store(Request $request): RedirectResponse
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function (User $user) use ($request) {
function (User $user) use ($request): void {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
Expand Down
6 changes: 3 additions & 3 deletions app/Repositories/TripRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public function findAll(): array
public function findWithSuggestions(Trip $trip): Trip
{
return $trip->load([
'suggestions' => function ($query) {
'suggestions' => function ($query): void {
$query->withCount([
'vote as up_votes_count' => function ($q) {
'vote as up_votes_count' => function ($q): void {
$q->where('type', VoteType::UP);
},
'vote as down_votes_count' => function ($q) {
'vote as down_votes_count' => function ($q): void {
$q->where('type', VoteType::DOWN);
},
]);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"pestphp/pest": "^4.1",
"pestphp/pest-plugin-laravel": "^4.0"
"pestphp/pest-plugin-laravel": "^4.0",
"rector/rector": "^2.2"
},
"autoload": {
"psr-4": {
Expand Down
62 changes: 61 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__.'/app',
__DIR__.'/bootstrap',
__DIR__.'/config',
__DIR__.'/public',
__DIR__.'/resources',
__DIR__.'/routes',
__DIR__.'/tests',
])
// uncomment to reach your current PHP version
// ->withPhpSets()
->withPreparedSets(
// deadCode: true,
// codeQuality: true,
// typeDeclarations: true,
privatization: true,
earlyReturn: true,
strictBooleans: true,
)
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
4 changes: 2 additions & 2 deletions routes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use App\Http\Controllers\Auth\VerifyEmailController;
use Illuminate\Support\Facades\Route;

Route::middleware('guest')->group(function () {
Route::middleware('guest')->group(function (): void {
Route::get('register', [RegisteredUserController::class, 'create'])
->name('register');

Expand All @@ -35,7 +35,7 @@
->name('password.store');
});

Route::middleware('auth')->group(function () {
Route::middleware('auth')->group(function (): void {
Route::get('verify-email', EmailVerificationPromptController::class)
->name('verification.notice');

Expand Down
2 changes: 1 addition & 1 deletion routes/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;

Artisan::command('inspire', function () {
Artisan::command('inspire', function (): void {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
10 changes: 5 additions & 5 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
return view('welcome');
});

Route::middleware('auth')->group(function () {
Route::middleware('auth')->group(function (): void {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

Route::middleware(['auth'])->group(function () {
Route::middleware(['auth'])->group(function (): void {
Route::get('/dashboard', [TripController::class, 'index'])->name('dashboard');

// Ungated
Route::get('trips/create', [TripController::class, 'create'])->name('trips.create');
Route::post('trips', [TripController::class, 'store'])->name('trips.store');

// They can view trip assigned to them
Route::middleware('can:view,trip')->group(function () {
Route::middleware('can:view,trip')->group(function (): void {
Route::get('trips/{trip}/', [TripController::class, 'show'])->name('trips.show');
Route::resource('trips.suggestions', SuggestionController::class)->only(['store']);

});
//
Route::middleware('can:view,suggestion.trip')->group(function () {
Route::middleware('can:view,suggestion.trip')->group(function (): void {
Route::get('/suggestions/{suggestion}/status', [SuggestionController::class, 'status'])->name('suggestions.status');
Route::get('/suggestions/{suggestion}/vote', [VoteController::class, 'vote'])->name('suggestions.vote');
});

// They can update the trips
Route::middleware('can:update,trip')->group(function () {
Route::middleware('can:update,trip')->group(function (): void {
Route::get('trips/{trip}/edit', [TripController::class, 'edit'])->name('trips.edit');
Route::put('trips/{trip}', [TripController::class, 'update'])->name('trips.update');
});
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use App\Models\User;

test('login screen can be rendered', function () {
test('login screen can be rendered', function (): void {
$response = $this->get('/login');

$response->assertStatus(200);
});

test('users can authenticate using the login screen', function () {
test('users can authenticate using the login screen', function (): void {
$user = User::factory()->create();

$response = $this->post('/login', [
Expand All @@ -20,7 +20,7 @@
$response->assertRedirect(route('dashboard', absolute: false));
});

test('users can not authenticate with invalid password', function () {
test('users can not authenticate with invalid password', function (): void {
$user = User::factory()->create();

$this->post('/login', [
Expand All @@ -31,7 +31,7 @@
$this->assertGuest();
});

test('users can logout', function () {
test('users can logout', function (): void {
$user = User::factory()->create();

$response = $this->actingAs($user)->post('/logout');
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Auth/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;

test('email verification screen can be rendered', function () {
test('email verification screen can be rendered', function (): void {
$user = User::factory()->unverified()->create();

$response = $this->actingAs($user)->get('/verify-email');

$response->assertStatus(200);
});

test('email can be verified', function () {
test('email can be verified', function (): void {
$user = User::factory()->unverified()->create();

Event::fake();
Expand All @@ -31,7 +31,7 @@
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
});

test('email is not verified with invalid hash', function () {
test('email is not verified with invalid hash', function (): void {
$user = User::factory()->unverified()->create();

$verificationUrl = URL::temporarySignedRoute(
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Auth/PasswordConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

use App\Models\User;

test('confirm password screen can be rendered', function () {
test('confirm password screen can be rendered', function (): void {
$user = User::factory()->create();

$response = $this->actingAs($user)->get('/confirm-password');

$response->assertStatus(200);
});

test('password can be confirmed', function () {
test('password can be confirmed', function (): void {
$user = User::factory()->create();

$response = $this->actingAs($user)->post('/confirm-password', [
Expand All @@ -21,7 +21,7 @@
$response->assertSessionHasNoErrors();
});

test('password is not confirmed with invalid password', function () {
test('password is not confirmed with invalid password', function (): void {
$user = User::factory()->create();

$response = $this->actingAs($user)->post('/confirm-password', [
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/Auth/PasswordResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Support\Facades\Notification;

test('reset password link screen can be rendered', function () {
test('reset password link screen can be rendered', function (): void {
$response = $this->get('/forgot-password');

$response->assertStatus(200);
});

test('reset password link can be requested', function () {
test('reset password link can be requested', function (): void {
Notification::fake();

$user = User::factory()->create();
Expand All @@ -20,7 +20,7 @@
Notification::assertSentTo($user, ResetPassword::class);
});

test('reset password screen can be rendered', function () {
test('reset password screen can be rendered', function (): void {
Notification::fake();

$user = User::factory()->create();
Expand All @@ -36,7 +36,7 @@
});
});

test('password can be reset with valid token', function () {
test('password can be reset with valid token', function (): void {
Notification::fake();

$user = User::factory()->create();
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Auth/PasswordUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use App\Models\User;
use Illuminate\Support\Facades\Hash;

test('password can be updated', function () {
test('password can be updated', function (): void {
$user = User::factory()->create();

$response = $this
Expand All @@ -22,7 +22,7 @@
$this->assertTrue(Hash::check('new-password', $user->refresh()->password));
});

test('correct password must be provided to update password', function () {
test('correct password must be provided to update password', function (): void {
$user = User::factory()->create();

$response = $this
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

test('registration screen can be rendered', function () {
test('registration screen can be rendered', function (): void {
$response = $this->get('/register');

$response->assertStatus(200);
});

test('new users can register', function () {
test('new users can register', function (): void {
$response = $this->post('/register', [
'name' => 'Test User',
'email' => 'test@example.com',
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

it('returns a successful response', function () {
it('returns a successful response', function (): void {
$response = $this->get('/');

$response->assertStatus(200);
Expand Down
Loading