Skip to content

Commit

Permalink
Update codebase to PHP 7.4 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
TavoNiievez authored Nov 21, 2021
1 parent dff7199 commit a3bbcb4
Show file tree
Hide file tree
Showing 25 changed files with 361 additions and 336 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['7.4', '8.0']
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@

abstract class AbstractController extends Controller
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/ConfirmPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ final class ConfirmPasswordController extends AbstractController
{
use ConfirmsPasswords;

/** @var string */
protected $redirectTo = RouteServiceProvider::HOME;
protected string $redirectTo = RouteServiceProvider::HOME;

public function __construct()
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ final class LoginController extends AbstractController
{
use AuthenticatesUsers;

/** @var string */
protected $redirectTo = RouteServiceProvider::HOME;
protected string $redirectTo = RouteServiceProvider::HOME;

public function __construct()
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ final class RegisterController extends AbstractController
{
use RegistersUsers;

/** @var string */
protected $redirectTo = RouteServiceProvider::HOME;
protected string $redirectTo = RouteServiceProvider::HOME;

public function __construct()
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ final class ResetPasswordController extends AbstractController
{
use ResetsPasswords;

/** @var string */
protected $redirectTo = RouteServiceProvider::HOME;
protected string $redirectTo = RouteServiceProvider::HOME;
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/VerificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ final class VerificationController extends AbstractController
{
use VerifiesEmails;

/** @var string */
protected $redirectTo = RouteServiceProvider::HOME;
protected string $redirectTo = RouteServiceProvider::HOME;

public function __construct()
{
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Http\Controllers;

use App\Events\TestEvent;
use Illuminate\Contracts\Config\Repository as Config;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;

Expand All @@ -17,9 +18,11 @@ public function fireEvent(): void

public function testValue(): string
{
return 'Test value is: ' . config('test_value');
$config = app()->get(Config::class);
return 'Test value is: ' . $config->get('test_value');
}

/** @return array<string, array<bool|int>> */
public function uploadFiles(Request $request): array
{
$response = [];
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@

final class Authenticate extends Middleware
{
/**
* @param Request $request
* @return string|null
*/
/** @param Request $request */
protected function redirectTo($request): ?string
{
$urlGenerator = app()->get(UrlGenerator::class);
if (! $request->expectsJson()) {
$urlGenerator->route('login');
}

return null;
}
}
8 changes: 1 addition & 7 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@

final class RedirectIfAuthenticated
{
/**
* @param Request $request
* @param Closure $next
* @param string|null $guard
* @return Response
*/
public function handle(Request $request, Closure $next, $guard = null): Response
public function handle(Request $request, Closure $next, string $guard = null): Response
{
$auth = app()->get(Auth::class);
$redirect = app()->get(Redirect::class);
Expand Down
8 changes: 4 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getName(): string
return $this->name;
}

public function setName(string $name): User
public function setName(string $name): self
{
$this->name = $name;
return $this;
Expand All @@ -76,7 +76,7 @@ public function getEmail(): string
return $this->email;
}

public function setEmail(string $email): User
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
Expand All @@ -87,7 +87,7 @@ public function getPassword(): string
return $this->password;
}

public function setPassword(string $password): User
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
Expand All @@ -98,7 +98,7 @@ public function getEmailVerifiedAt(): ?Carbon
return $this->email_verified_at;
}

public function setEmailVerifiedAt(Carbon $verifiedDate): User
public function setEmailVerifiedAt(Carbon $verifiedDate): self
{
$this->email_verified_at = $verifiedDate;
return $this;
Expand Down
7 changes: 4 additions & 3 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
use Illuminate\Routing\Router;
use function base_path;

final class RouteServiceProvider extends ServiceProvider
Expand All @@ -18,12 +18,13 @@ final class RouteServiceProvider extends ServiceProvider

public function map(): void
{
Route::prefix('api')
$router = app()->get(Router::class);
$router->prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));

Route::middleware('web')
$router->middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
Expand Down
3 changes: 1 addition & 2 deletions app/Utils/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

final class Repeat implements StringConverterInterface
{
/** @var int */
private $times;
private int $times;

public function __construct(int $times)
{
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=7.3.0",
"php": ">=7.4.0",
"ext-pdo": "*",
"laravel/framework": "^6.20",
"laravel/ui": "^1.3"
Expand All @@ -33,7 +33,7 @@
"preferred-install": "dist",
"sort-packages": true,
"platform": {
"php": "7.3.0"
"php": "7.4.0"
}
},
"extra": {
Expand Down
Loading

0 comments on commit a3bbcb4

Please sign in to comment.