1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Add better defaults and documentation

This commit is contained in:
Matthew Brown 2020-02-18 20:30:37 -05:00
parent c9494c43a3
commit 2e4154d76e
3 changed files with 21 additions and 7 deletions

View File

@ -62,7 +62,7 @@
<xs:attribute name="throwExceptionOnError" type="xs:boolean" default="false" />
<xs:attribute name="totallyTyped" type="xs:boolean" default="false" />
<xs:attribute name="errorLevel" type="xs:integer" default="1" />
<xs:attribute name="suppressMixedIssues" type="xs:boolean" default="false" />
<xs:attribute name="reportMixedIssues" type="xs:boolean" default="true" />
<xs:attribute name="useAssertForType" type="xs:boolean" default="true" />
<xs:attribute name="useDocblockTypes" type="xs:boolean" default="true" />
<xs:attribute name="useDocblockPropertyTypes" type="xs:boolean" default="false" />

View File

@ -47,6 +47,15 @@ Configuration file may be split into several files using [XInclude](https://www.
```
This corresponds to Psalms [error-detection level](error_levels.md).
#### reportMixedIssues
```xml
<psalm
reportMixedIssues="[bool]"
/>
```
Setting this to `"false"` hides all issues with `Mixed` types in Psalms output. If not given, this defaults to `"false"` when `errorLevel` is 3 or higher, and `"true"` when the error level is 1 or 2.
#### totallyTyped
```xml
@ -54,7 +63,10 @@ This corresponds to Psalms [error-detection level](error_levels.md).
totallyTyped="[bool]"
/>
```
Enabling this will make Psalm very strict, such that it needs to be able to evaluate the type of every single statement, and emitting a bevy of `Mixed*` issues if the types cannot be determined. Defaults to `false`.
\(Deprecated\) Setting `totallyTyped` to `"true"` is equivalent to setting `errorLevel` to `"1"`. Setting `totallyTyped` to `"false"` is equivalent to setting `errorLevel` to `"2"` and `reportMixedIssues` to `"false"`
#### resolveFromConfigFile

View File

@ -248,7 +248,7 @@ class Config
/**
* @var ?bool
*/
public $suppress_mixed_issues = null;
public $show_mixed_issues = null;
/** @var bool */
public $strict_binary_operands = false;
@ -764,7 +764,7 @@ class Config
'loadXdebugStub' => 'load_xdebug_stub',
'ensureArrayStringOffsetsExist' => 'ensure_array_string_offsets_exist',
'ensureArrayIntOffsetsExist' => 'ensure_array_int_offsets_exist',
'suppressMixedIssues' => 'suppress_mixed_issues',
'reportMixedIssues' => 'show_mixed_issues',
];
foreach ($booleanAttributes as $xmlName => $internalName) {
@ -849,8 +849,8 @@ class Config
} else {
$config->level = 2;
if ($config->suppress_mixed_issues === null) {
$config->suppress_mixed_issues = true;
if ($config->show_mixed_issues === null) {
$config->show_mixed_issues = false;
}
}
} else {
@ -1264,7 +1264,9 @@ class Config
*/
public function reportIssueInFile($issue_type, $file_path)
{
if (($this->suppress_mixed_issues || $this->level > 2) && in_array($issue_type, self::MIXED_ISSUES, true)) {
if (($this->show_mixed_issues === false || $this->level > 2)
&& in_array($issue_type, self::MIXED_ISSUES, true)
) {
return false;
}