mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Only add pure to functions with params
This commit is contained in:
parent
9100c26439
commit
1ec0f35011
@ -584,6 +584,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
||||
&& !$this->inferred_impure
|
||||
&& ($this->function instanceof Function_
|
||||
|| $this->function instanceof ClassMethod)
|
||||
&& $storage->params
|
||||
) {
|
||||
$manipulator = FunctionDocblockManipulator::getForFunction(
|
||||
$project_analyzer,
|
||||
|
8
src/Psalm/Issue/ImpureVariable.php
Normal file
8
src/Psalm/Issue/ImpureVariable.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class ImpureVariable extends CodeIssue
|
||||
{
|
||||
const ERROR_LEVEL = -1;
|
||||
const SHORTCODE = 235;
|
||||
}
|
@ -116,6 +116,33 @@ class PureAnnotationAdditionTest extends FileManipulationTest
|
||||
['MissingPureAnnotation'],
|
||||
true,
|
||||
],
|
||||
'dontAddWhenReferencingThis' => [
|
||||
'<?php
|
||||
class A {
|
||||
public int $a = 5;
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function foo() : self {
|
||||
return $this;
|
||||
}
|
||||
}',
|
||||
'<?php
|
||||
class A {
|
||||
public int $a = 5;
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function foo() : self {
|
||||
return $this;
|
||||
}
|
||||
}',
|
||||
'7.4',
|
||||
['MissingPureAnnotation'],
|
||||
true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user