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:
parent
9177ad5ce0
commit
2afbf58324
@ -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
|
||||
|
@ -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,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user