1 | <?php |
||
2 | |||
3 | namespace Diglabby\Doika\Models; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Collection; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | use Illuminate\Database\Eloquent\Relations\HasMany; |
||
8 | use Illuminate\Support\Carbon; |
||
9 | |||
10 | /** |
||
11 | * @property int $id |
||
12 | * @property string $email |
||
13 | * @property string|null $name |
||
14 | * @property int|null $phone |
||
15 | * @property Carbon $created_at |
||
16 | * @property Carbon $updated_at |
||
17 | * |
||
18 | * Relationships: |
||
19 | * @property-read Collection|Subscription[] $subscriptions |
||
20 | * @property-read Collection|Transaction[] $transactions |
||
21 | */ |
||
22 | final class Donator extends Model |
||
23 | { |
||
24 | public function subscriptions(): HasMany |
||
25 | { |
||
26 | $this->hasMany(Subscription::class); |
||
0 ignored issues
–
show
|
|||
27 | } |
||
28 | |||
29 | public function transactions(): HasMany |
||
30 | { |
||
31 | $this->hasMany(Transaction::class); |
||
0 ignored issues
–
show
In this branch, the function will implicitly return
null which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Relations\HasMany . Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: interface ReturnsInt {
public function returnsIntHinted(): int;
}
class MyClass implements ReturnsInt {
public function returnsIntHinted(): int
{
if (foo()) {
return 123;
}
// here: null is implicitly returned
}
}
![]() |
|||
32 | } |
||
33 | } |
||
34 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: