Skip to content

Commit

Permalink
Add better defaults and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Feb 19, 2020
1 parent c9494c4 commit 2e4154d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
14 changes: 13 additions & 1 deletion docs/running_psalm/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,26 @@ Configuration file may be split into several files using [XInclude](https://www.
```
This corresponds to Psalm‘s [error-detection level](error_levels.md).

#### reportMixedIssues

```xml
<psalm
reportMixedIssues="[bool]"
/>
```
Setting this to `"false"` hides all issues with `Mixed` types in Psalm’s 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
<psalm
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

Expand Down
12 changes: 7 additions & 5 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -764,7 +764,7 @@ private static function fromXmlAndPaths(string $base_dir, string $file_contents,
'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) {
Expand Down Expand Up @@ -849,8 +849,8 @@ private static function fromXmlAndPaths(string $base_dir, string $file_contents,
} 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 {
Expand Down Expand Up @@ -1264,7 +1264,9 @@ public function shortenFileName($file_name)
*/
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;
}

Expand Down

0 comments on commit 2e4154d

Please sign in to comment.