1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00

Merge pull request #10679 from weirdan/8323-dont-show-backtrace-in-InvalidDocblock-issue-message

This commit is contained in:
Bruce Weirdan 2024-02-07 22:00:01 -04:00 committed by GitHub
commit f9a23149fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -624,7 +624,7 @@ final class FunctionLikeDocblockScanner
); );
} catch (TypeParseTreeException $e) { } catch (TypeParseTreeException $e) {
$storage->docblock_issues[] = new InvalidDocblock( $storage->docblock_issues[] = new InvalidDocblock(
'Invalid @psalm-assert union type ' . $e, 'Invalid @psalm-assert union type: ' . $e->getMessage(),
new CodeLocation($file_scanner, $stmt, null, true), new CodeLocation($file_scanner, $stmt, null, true),
); );

View File

@ -90,6 +90,33 @@ class AssertAnnotationTest extends TestCase
$this->analyzeFile('somefile.php', new Context()); $this->analyzeFile('somefile.php', new Context());
} }
public function testAssertInvalidDocblockMessageDoesNotIncludeTrace(): void
{
$this->expectException(CodeException::class);
$this->expectExceptionMessageMatches(
'!^InvalidDocblock - ' . 'somefile\\.php:10:5 - Invalid @psalm-assert union type: Invalid type \'\\$expected\'$!',
);
$this->addFile(
'somefile.php',
<<<'PHP'
<?php
/**
* Asserts that two variables are not the same.
*
* @template T
* @param T $expected
* @param mixed $actual
* @psalm-assert !=$expected $actual
*/
function assertNotSame($expected, $actual) : void {}
PHP,
);
$this->analyzeFile('somefile.php', new Context());
}
public function providerValidCodeParse(): iterable public function providerValidCodeParse(): iterable
{ {
return [ return [