mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-30 04:39:01 +01:00
f6193ad5cb
totallyTyped was deprecated in Psalm v4.21.0 [1]. totallyTyped="true" is equivalent to errorLevel="1" and totallyTyped="false" is equivalent to errorLevel="2" plus reportMixedIssues="false" [2]. [1] https://github.com/vimeo/psalm/releases/tag/4.21.0 [2] https://psalm.dev/docs/running_psalm/configuration/#totallytyped
52 lines
1.1 KiB
Gherkin
52 lines
1.1 KiB
Gherkin
Feature: abort_if()
|
|
The global abort_if helper is supported
|
|
|
|
Background:
|
|
Given I have the following config
|
|
"""
|
|
<?xml version="1.0"?>
|
|
<psalm errorLevel="1">
|
|
<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);
|
|
"""
|
|
|
|
Scenario: abort asserts not null
|
|
Given I have the following code
|
|
"""
|
|
/**
|
|
* @param string|null $nullable
|
|
*/
|
|
function test($nullable): string {
|
|
if (!$nullable) {
|
|
abort(422);
|
|
}
|
|
|
|
return $nullable;
|
|
}
|
|
"""
|
|
|
|
Scenario: abort_if asserts not null
|
|
Given I have the following code
|
|
"""
|
|
/**
|
|
* @param string|null $nullable
|
|
*/
|
|
function abortIfNullable($nullable): string {
|
|
abort_if(is_null($nullable), 422);
|
|
|
|
return $nullable;
|
|
}
|
|
"""
|
|
When I run Psalm
|
|
Then I see no errors
|