2021-07-06 16:28:37 +02:00
|
|
|
Feature: Database Builder types
|
2020-05-21 09:18:36 +02:00
|
|
|
Illuminate\Database\Builder has type support
|
|
|
|
|
|
|
|
Background:
|
|
|
|
Given I have the following config
|
|
|
|
"""
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<psalm totallyTyped="true">
|
|
|
|
<projectFiles>
|
|
|
|
<directory name="."/>
|
|
|
|
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
|
|
|
|
</projectFiles>
|
|
|
|
<plugins>
|
|
|
|
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
|
|
|
|
</plugins>
|
|
|
|
</psalm>
|
|
|
|
"""
|
|
|
|
|
|
|
|
Scenario: Models can call database query builder instance methods
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
2020-06-07 04:26:46 +02:00
|
|
|
use Tests\Psalm\LaravelPlugin\Models\User;
|
2020-05-21 09:18:36 +02:00
|
|
|
|
|
|
|
final class UserRepository
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param \Illuminate\Database\Eloquent\Builder<User> $builder
|
|
|
|
*/
|
|
|
|
public function firstFromDatabaseBuilderInstance(\Illuminate\Database\Eloquent\Builder $builder): ?User {
|
|
|
|
return $builder->first();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see no errors
|