1
0
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:
Brown 2019-06-10 14:41:21 -04:00
parent 7af21b80a9
commit c21e9917fa
2 changed files with 11 additions and 0 deletions

View File

@ -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);
}

View File

@ -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 = [];