diff --git a/examples/psalm.default.xml b/examples/psalm.default.xml index 0d770bdcc..01bfdac2e 100644 --- a/examples/psalm.default.xml +++ b/examples/psalm.default.xml @@ -3,21 +3,13 @@ name="Example Psalm config with recommended defaults" stopOnFirstError="false" useDocblockTypes="true" + totallyTyped="false" > - - - - - - - - - diff --git a/psalm.xml b/psalm.xml index 328be4a12..3d1e640be 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,6 +3,7 @@ name="Psalm for Psalm" stopOnFirstError="false" useDocblockTypes="true" + totallyTyped="true" > diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index 4c4899177..94ecc3cff 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -22,6 +22,21 @@ class Config self::REPORT_SUPPRESS ]; + /** + * @var array + */ + protected static $MIXED_ISSUES = [ + 'MixedArgument', + 'MixedArrayAccess', + 'MixedArrayOffset', + 'MixedAssignment', + 'MixedInferredReturnType', + 'MixedMethodCall', + 'MixedPropertyFetch', + 'MixedPropertyAssignment', + 'MixedStringOffsetAssignment' + ]; + /** * @var self|null */ @@ -114,6 +129,9 @@ class Config /** @var bool */ public $allow_includes = true; + /** @var bool */ + public $totally_typed = false; + /** * Psalm plugins * @@ -195,6 +213,11 @@ class Config $config->allow_includes = $attribute_text === 'true' || $attribute_text === '1'; } + if (isset($config_xml['totallyTyped'])) { + $attribute_text = (string) $config_xml['totallyTyped']; + $config->totally_typed = $attribute_text === 'true' || $attribute_text === '1'; + } + if (isset($config_xml->inspectFiles)) { $config->inspect_files = FileFilter::loadFromXML($config_xml->inspectFiles, true); } @@ -349,6 +372,10 @@ class Config */ public function excludeIssueInFile($issue_type, $file_name) { + if (!$this->totally_typed && in_array($issue_type, self::$MIXED_ISSUES)) { + return true; + } + if ($this->getReportingLevel($issue_type) === self::REPORT_SUPPRESS) { return true; } diff --git a/tests/TestConfig.php b/tests/TestConfig.php index 61e73fdb0..ad31d123d 100644 --- a/tests/TestConfig.php +++ b/tests/TestConfig.php @@ -11,5 +11,6 @@ class TestConfig extends Config $this->throw_exception = true; $this->use_docblock_types = true; + $this->totally_typed = true; } }