mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-12-03 10:07:49 +01:00
40 lines
1.1 KiB
Gherkin
40 lines
1.1 KiB
Gherkin
|
Feature: Database Builder Types
|
||
|
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);
|
||
|
|
||
|
final class User extends \Illuminate\Database\Eloquent\Model {
|
||
|
protected $table = 'users';
|
||
|
};
|
||
|
|
||
|
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
|