mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 22:01:48 +01:00
Merge pull request #9392 from weirdan/report-docblock-issues-on-traits-and-interfaces
This commit is contained in:
commit
1b2598c33a
@ -127,6 +127,10 @@ class InterfaceAnalyzer extends ClassLikeAnalyzer
|
|||||||
$class_storage->suppressed_issues + $this->getSuppressedIssues(),
|
$class_storage->suppressed_issues + $this->getSuppressedIssues(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foreach ($class_storage->docblock_issues as $docblock_issue) {
|
||||||
|
IssueBuffer::maybeAdd($docblock_issue);
|
||||||
|
}
|
||||||
|
|
||||||
$member_stmts = [];
|
$member_stmts = [];
|
||||||
foreach ($this->class->stmts as $stmt) {
|
foreach ($this->class->stmts as $stmt) {
|
||||||
if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod) {
|
if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod) {
|
||||||
|
@ -5,6 +5,7 @@ namespace Psalm\Internal\Analyzer;
|
|||||||
use PhpParser\Node\Stmt\Trait_;
|
use PhpParser\Node\Stmt\Trait_;
|
||||||
use Psalm\Aliases;
|
use Psalm\Aliases;
|
||||||
use Psalm\Context;
|
use Psalm\Context;
|
||||||
|
use Psalm\IssueBuffer;
|
||||||
|
|
||||||
use function assert;
|
use function assert;
|
||||||
|
|
||||||
@ -80,5 +81,9 @@ class TraitAnalyzer extends ClassLikeAnalyzer
|
|||||||
AttributesAnalyzer::TARGET_CLASS,
|
AttributesAnalyzer::TARGET_CLASS,
|
||||||
$storage->suppressed_issues + $statements_analyzer->getSuppressedIssues(),
|
$storage->suppressed_issues + $statements_analyzer->getSuppressedIssues(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foreach ($storage->docblock_issues as $docblock_issue) {
|
||||||
|
IssueBuffer::maybeAdd($docblock_issue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -876,6 +876,89 @@ class TypeAnnotationTest extends TestCase
|
|||||||
class C implements B {}',
|
class C implements B {}',
|
||||||
'error_message' => 'UndefinedDocblockClass',
|
'error_message' => 'UndefinedDocblockClass',
|
||||||
],
|
],
|
||||||
|
'duplicateKeyInArrayShapeOnInterfaceIsReported' => [
|
||||||
|
'code' => <<<'PHP'
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-type Attributes = array{
|
||||||
|
* name: string,
|
||||||
|
* email: string,
|
||||||
|
* email: string,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
interface A {
|
||||||
|
/**
|
||||||
|
* @return Attributes
|
||||||
|
*/
|
||||||
|
public function getAttributes(): array;
|
||||||
|
}
|
||||||
|
PHP,
|
||||||
|
'error_message' => 'InvalidDocblock',
|
||||||
|
],
|
||||||
|
'duplicateKeyInArrayShapeOnAClassIsReported' => [
|
||||||
|
'code' => <<<'PHP'
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-type Attributes = array{
|
||||||
|
* name: string,
|
||||||
|
* email: string,
|
||||||
|
* email: string,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
class A {
|
||||||
|
/**
|
||||||
|
* @return Attributes
|
||||||
|
*/
|
||||||
|
public function getAttributes(): array {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PHP,
|
||||||
|
'error_message' => 'InvalidDocblock',
|
||||||
|
],
|
||||||
|
'duplicateKeyInArrayShapeOnATraitIsReported' => [
|
||||||
|
'code' => <<<'PHP'
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-type Attributes = array{
|
||||||
|
* name: string,
|
||||||
|
* email: string,
|
||||||
|
* email: string,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
trait A {
|
||||||
|
/**
|
||||||
|
* @return Attributes
|
||||||
|
*/
|
||||||
|
public function getAttributes(): array {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PHP,
|
||||||
|
'error_message' => 'InvalidDocblock',
|
||||||
|
],
|
||||||
|
'duplicateKeyInArrayShapeOnAnEnumIsReported' => [
|
||||||
|
'code' => <<<'PHP'
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @psalm-type Attributes = array{
|
||||||
|
* name: string,
|
||||||
|
* email: string,
|
||||||
|
* email: string,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
enum A {
|
||||||
|
case FOO;
|
||||||
|
}
|
||||||
|
PHP,
|
||||||
|
'error_message' => 'InvalidDocblock',
|
||||||
|
'ignored_issues' => [],
|
||||||
|
'php_version' => '8.1',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user