1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Prevent adding trait property types

This commit is contained in:
Brown 2020-07-10 19:11:06 -04:00
parent 9177ad5ce0
commit 2afbf58324
2 changed files with 28 additions and 0 deletions

View File

@ -1670,6 +1670,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
$project_analyzer = ProjectAnalyzer::getInstance();
if ($codebase->alter_code
&& $source === $this
&& isset($project_analyzer->getIssuesToFix()['MissingPropertyType'])
&& !\in_array('MissingPropertyType', $this->getSuppressedIssues())
&& $suggested_type

View File

@ -261,6 +261,33 @@ class MissingPropertyTypeTest extends FileManipulationTest
['MissingPropertyType'],
true,
],
'dontAddMissingPropertyTypeInTrait' => [
'<?php
trait T {
public $u;
}
class A {
use T;
public function bar() {
$this->u = 5;
}
}',
'<?php
trait T {
public $u;
}
class A {
use T;
public function bar() {
$this->u = 5;
}
}',
'7.4',
['MissingPropertyType'],
true,
],
];
}
}