psalm-plugin-laravel/tests/acceptance/ExceptionHandler.feature
Martin Zurowietz f6193ad5cb Replace deprecated totallyTyped attribute
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
2022-02-21 10:15:13 +01:00

57 lines
1.6 KiB
Gherkin

Feature: ExceptionHandler
If an exception is thrown while psalm analyzes the codebase, the status code returned will not be 0
Background:
Given I have the following config
"""
<?xml version="1.0"?>
<psalm errorLevel="1">
<projectFiles>
<directory name="."/>
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
</projectFiles>
<plugins>
<plugin filename="somefile.php" />
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
</plugins>
</psalm>
"""
Scenario:
Given I have the following code
"""
<?php
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\StatementsSource;
use Psalm\Plugin\PluginEntryPointInterface;
use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
class FailingPlugin implements PluginEntryPointInterface, FunctionReturnTypeProviderInterface {
public function __invoke(\Psalm\Plugin\RegistrationInterface $registration, ?\SimpleXMLElement $config = null) {
return;
}
public static function getFunctionIds(): array
{
return ['foo'];
}
public static function getFunctionReturnType(StatementsSource $statements_source, string $function_id, array $call_args, Context $context, CodeLocation $code_location): ?Union
{
if ($function_id === 'foo') {
throw new \InvalidArgumentException('expected runtime exception');
}
return null;
}
}
function foo() {
}
foo();
"""
When I run Psalm
Then I see exit code 1