Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration option to disable @psalm-suppress all #7431

Merged
merged 1 commit into from Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions config.xsd
Expand Up @@ -109,6 +109,7 @@
<xs:attribute name="reportInfo" type="xs:boolean" default="true" />
<xs:attribute name="restrictReturnTypes" type="xs:boolean" default="false" />
<xs:attribute name="limitMethodComplexity" type="xs:boolean" default="false" />
<xs:attribute name="disableSuppressAll" type="xs:boolean" default="false" />
<xs:attribute name="triggerErrorExits" type="TriggerErrorExitsType" default="default" />
</xs:complexType>

Expand Down
9 changes: 9 additions & 0 deletions docs/running_psalm/configuration.md
Expand Up @@ -154,6 +154,15 @@ This flag is deprecated and will be removed in Psalm 5
```
When `true`, strings can be used as classes, meaning `$some_string::someMethod()` is allowed. If `false`, only class constant strings (of the form `Foo\Bar::class`) can stand in for classes, otherwise an `InvalidStringClass` issue is emitted. Defaults to `false`.

#### disableSuppressAll

```xml
<psalm
disableSuppressAll="[bool]"
>
```
When `true`, disables wildcard suppression of all issues with `@psalm-suppress all`. Defaults to `false`.

#### memoizeMethodCallResults

```xml
Expand Down
6 changes: 6 additions & 0 deletions src/Psalm/Config.php
Expand Up @@ -326,6 +326,11 @@ class Config
*/
public $allow_string_standin_for_class = false;

/**
* @var bool
*/
public $disable_suppress_all = false;

/**
* @var bool
*/
Expand Down Expand Up @@ -910,6 +915,7 @@ private static function fromXmlAndPaths(
'rememberPropertyAssignmentsAfterCall' => 'remember_property_assignments_after_call',
'allowPhpStormGenerics' => 'allow_phpstorm_generics',
'allowStringToStandInForClass' => 'allow_string_standin_for_class',
'disableSuppressAll' => 'disable_suppress_all',
'usePhpDocMethodsWithoutMagicCall' => 'use_phpdoc_method_without_magic_or_parent',
'usePhpDocPropertiesWithoutMagicCall' => 'use_phpdoc_property_without_magic_or_parent',
'memoizeMethodCallResults' => 'memoize_method_calls',
Expand Down
4 changes: 3 additions & 1 deletion src/Psalm/IssueBuffer.php
Expand Up @@ -212,7 +212,9 @@ public static function isSuppressed(CodeIssue $e, array $suppressed_issues = [])
}
}

$suppress_all_position = array_search('all', $suppressed_issues);
$suppress_all_position = $config->disable_suppress_all
? false
: array_search('all', $suppressed_issues);

if ($suppress_all_position !== false) {
if (is_int($suppress_all_position)) {
Expand Down