1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Optionally allow trait static calls and property access

This commit is contained in:
Daniil Gentili 2021-01-12 11:25:27 +01:00
parent 2f58c6afc8
commit e878eeb6d0
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 16 additions and 2 deletions

View File

@ -37,6 +37,8 @@
<xs:attribute name="allowFileIncludes" type="xs:boolean" default="true" />
<xs:attribute name="allowPhpStormGenerics" type="xs:boolean" default="false" />
<xs:attribute name="allowStringToStandInForClass" type="xs:boolean" default="false" />
<xs:attribute name="allowTraitStaticCall" type="xs:boolean" default="false" />
<xs:attribute name="allowTraitStaticPropertyAccess" type="xs:boolean" default="false" />
<xs:attribute name="checkForThrowsDocblock" type="xs:boolean" default="false" />
<xs:attribute name="checkForThrowsInGlobalScope" type="xs:boolean" default="false" />
<xs:attribute name="ensureArrayIntOffsetsExist" type="xs:boolean" default="false" />

View File

@ -474,6 +474,15 @@ class Config
*/
public $allow_named_arg_calls = true;
/**
* @var bool
*/
public $allow_trait_static_call = false;
/**
* @var bool
*/
public $allow_trait_static_property_access = false;
/** @var array<string, mixed> */
private $predefined_constants = [];
@ -754,6 +763,8 @@ class Config
'reportInfo' => 'report_info',
'restrictReturnTypes' => 'restrict_return_types',
'limitMethodComplexity' => 'limit_method_complexity',
'allowTraitStaticCall' => 'allow_trait_static_call',
'allowTraitStaticPropertyAccess' => 'allow_trait_static_property_access',
];
foreach ($booleanAttributes as $xmlName => $internalName) {

View File

@ -148,7 +148,7 @@ class StaticCallAnalyzer extends CallAnalyzer
: null,
$statements_analyzer->getSuppressedIssues(),
false,
false,
$codebase->config->allow_trait_static_call,
false
);
}

View File

@ -91,7 +91,8 @@ class StaticPropertyFetchAnalyzer
$context->self,
$context->calling_method_id,
$statements_analyzer->getSuppressedIssues(),
false
false,
$codebase->config->allow_trait_static_property_access
) !== true) {
return false;
}