Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Analyser/FileAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public function analyseFile(
}
if ($node instanceof InTraitNode) {
$traitNode = $node->getOriginalNode();
$linesToIgnore[$scope->getFileDescription()] = $this->getLinesToIgnoreFromTokens([$traitNode]);
$fileDescription = $scope->getFileDescription();
$linesToIgnore[$fileDescription] ??= [];
$linesToIgnore[$fileDescription] += $this->getLinesToIgnoreFromTokens([$traitNode]);
}

if ($scope->isInTrait()) {
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,12 @@ public function testBug13980(): void
$this->assertNoErrors($errors);
}

public function testBug13945(): void
{
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13945.php');
$this->assertNoErrors($errors);
}

/**
* @param string[]|null $allAnalysedFiles
* @return list<Error>
Expand Down
18 changes: 18 additions & 0 deletions tests/PHPStan/Analyser/data/bug-13945.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types = 1);

namespace Bug13945;

trait Foo {
public function baz(): void {
$this->myProperty = "a"; // @phpstan-ignore property.notFound
}
}

trait Baz {
}

class HelloWorld
{
use Foo;
use Baz;
}
Loading