Have you noticed that Laravel 10 came with a big skeleton rewriting to use PHP types everywhere - for parameters, properties, variables, and method returns. But let's explore what are the possible types and their syntax details.
Let's look at two code samples:
Without types:
class UserService { public $data; public function processData($user) { // ... }}
With types:
use App\Models\User; class UserService { public array $data; public function processData(User $user): User { // ... }}
The second example is more readable, right? If a developer opens the first example for the first time, he would have...