mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Add config flag to prevent inferring property types from constructor
This commit is contained in:
parent
7af21b80a9
commit
c21e9917fa
@ -264,6 +264,11 @@ class Config
|
||||
*/
|
||||
public $ignored_exceptions_and_descendants_in_global_scope = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $infer_property_types_from_constructor = true;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
@ -725,6 +730,11 @@ class Config
|
||||
$config->parse_sql = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
if (isset($config_xml['inferPropertyTypesFromConstructor'])) {
|
||||
$attribute_text = (string) $config_xml['inferPropertyTypesFromConstructor'];
|
||||
$config->infer_property_types_from_constructor = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
if (isset($config_xml->projectFiles)) {
|
||||
$config->project_files = ProjectFileFilter::loadFromXMLElement($config_xml->projectFiles, $base_dir, true);
|
||||
}
|
||||
|
@ -1818,6 +1818,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
||||
&& $stmt->stmts
|
||||
&& $storage->params
|
||||
&& $class_storage
|
||||
&& $this->config->infer_property_types_from_constructor
|
||||
) {
|
||||
$assigned_properties = [];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user