mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2121 - no internal error on funk assertion syntax
This commit is contained in:
parent
ae46c9e132
commit
264131c211
@ -48,6 +48,7 @@ use Psalm\Type\Atomic\TTemplateParam;
|
||||
use Psalm\Type\Atomic\TTrue;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
use Psalm\Issue\InvalidDocblock;
|
||||
|
||||
class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
{
|
||||
@ -585,7 +586,23 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
}
|
||||
}
|
||||
|
||||
$new_type_part = Atomic::create($assertion, null, $template_type_map);
|
||||
try {
|
||||
$new_type_part = Atomic::create($assertion, null, $template_type_map);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
$new_type_part = new TMixed();
|
||||
|
||||
if ($code_location) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidDocblock(
|
||||
$assertion . ' cannot be used in an assertion',
|
||||
$code_location
|
||||
),
|
||||
$suppressed_issues
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($new_type_part instanceof TNamedObject
|
||||
&& ((
|
||||
|
@ -888,6 +888,22 @@ class AssertTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'TypeDoesNotContainType',
|
||||
],
|
||||
'noExceptionOnMalformedAssertion' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param mixed[] $a
|
||||
*/
|
||||
function one(array $a): void {
|
||||
isInts($a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-assert int[] $value
|
||||
* @param mixed $value
|
||||
*/
|
||||
function isInts($value): void {}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user