mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-12-03 10:07:49 +01:00
e836b89901
* feature: hack in support for optional. Remove meta stub provider Co-authored-by: Claas Augner <github@caugner.de>
45 lines
1.0 KiB
Gherkin
45 lines
1.0 KiB
Gherkin
Feature: helpers
|
|
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>
|
|
"""
|
|
And I have the following code preamble
|
|
"""
|
|
<?php declare(strict_types=1);
|
|
|
|
use Tests\Psalm\LaravelPlugin\Models\User;
|
|
use Illuminate\Support\Optional;
|
|
"""
|
|
|
|
Scenario: env can be pulled off the app
|
|
Given I have the following code
|
|
"""
|
|
if (app()->environment('production')) {
|
|
// do something
|
|
}
|
|
"""
|
|
When I run Psalm
|
|
Then I see no errors
|
|
|
|
Scenario: optional support
|
|
Given I have the following code
|
|
"""
|
|
function test(?Throwable $user): ?string
|
|
{
|
|
return optional($user)->getMessage();
|
|
}
|
|
|
|
"""
|
|
When I run Psalm
|
|
Then I see no errors
|