Skip to content

Commit

Permalink
Adopt Laravel type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
laravel-shift committed Jun 2, 2024
1 parent 5113f60 commit 049e098
Show file tree
Hide file tree
Showing 24 changed files with 35 additions and 33 deletions.
3 changes: 2 additions & 1 deletion app/Http/Middleware/ApplyLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Middleware;

use Symfony\Component\HttpFoundation\Response;
use Closure;
use Illuminate\Http\Request;

Expand All @@ -12,7 +13,7 @@ class ApplyLocale
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$locale = $request->header('X-Locale');
if (! empty($locale)) {
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Middleware;

use Symfony\Component\HttpFoundation\Response;
use App\Providers\AppServiceProvider;
use App\Providers\RouteServiceProvider;
use Closure;
Expand All @@ -17,7 +18,7 @@ class RedirectIfAuthenticated
* @param string|null ...$guards
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*/
public function handle(Request $request, Closure $next, ...$guards)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/DestroyUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DestroyUserRequest extends BaseRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/StoreUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StoreUserRequest extends BaseRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'first_name' => 'required|string|max:100',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/UpdateAvatarRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class UpdateAvatarRequest extends BaseRequest
{
public function rules()
public function rules(): array
{
return [
'avatar' => 'required|image',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/UpdateUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UpdateUserRequest extends BaseRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'first_name' => 'required|string|max:100',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RoleResource extends JsonResource
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
public function toArray($request): array
{
$data = $this->resource->toArray();

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/UserBasicResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UserBasicResource extends JsonResource
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
public function toArray($request): array
{
return [
'id' => $this->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UserResource extends JsonResource
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
public function toArray($request): array
{

$data = $this->resource->toArray();
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AppServiceProvider extends ServiceProvider
*
* @return void
*/
public function register()
public function register(): void
{

}
Expand All @@ -35,7 +35,7 @@ public function register()
*
* @return void
*/
public function boot()
public function boot(): void
{
//

Expand Down
4 changes: 2 additions & 2 deletions app/Providers/FortifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FortifyServiceProvider extends ServiceProvider
*
* @return void
*/
public function register()
public function register(): void
{
$this->app->instance(LoginResponseContract::class, new LoginResponse());
}
Expand All @@ -28,7 +28,7 @@ public function register()
*
* @return void
*/
public function boot()
public function boot(): void
{
Fortify::createUsersUsing(CreateNewUser::class);
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
Expand Down
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UserFactory extends Factory
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'first_name' => $this->faker->firstName(),
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
Expand All @@ -31,7 +31,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('users');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
Expand All @@ -25,7 +25,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('password_resets');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->text('two_factor_secret')
Expand All @@ -29,7 +29,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('two_factor_secret', 'two_factor_recovery_codes');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
Expand All @@ -29,7 +29,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
Expand All @@ -30,7 +30,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create(Models::table('abilities'), function (Blueprint $table) {
$table->bigIncrements('id');
Expand Down Expand Up @@ -82,7 +82,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::drop(Models::table('permissions'));
Schema::drop(Models::table('assigned_roles'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return void
*/
public function up()
public function up(): void
{
Schema::rename('password_resets', 'password_reset_tokens');
}
Expand All @@ -21,7 +21,7 @@ public function up()
*
* @return void
*/
public function down()
public function down(): void
{
Schema::rename('password_reset_tokens', 'password_resets');
}
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/BouncerSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BouncerSeeder extends Seeder
*
* @return void
*/
public function run()
public function run(): void
{
Bouncer::allow('admin')->everything();
Bouncer::allow('regular')->toOwn(MediaFile::class)->to(['list', 'view', 'create', 'edit', 'delete']);
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DatabaseSeeder extends Seeder
*
* @return void
*/
public function run()
public function run(): void
{
$this->call([
BouncerSeeder::class,
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/UsersTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UsersTableSeeder extends Seeder
*
* @return void
*/
public function run()
public function run(): void
{
$users = User::factory(1)->create(
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ExampleTest extends TestCase
*
* @return void
*/
public function test_the_application_returns_a_successful_response()
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ExampleTest extends TestCase
*
* @return void
*/
public function test_that_true_is_true()
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
Expand Down

0 comments on commit 049e098

Please sign in to comment.