mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Only add pure when not overriding upstream
This commit is contained in:
parent
fe5fd82a93
commit
596492a95a
@ -585,6 +585,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
||||
&& ($this->function instanceof Function_
|
||||
|| $this->function instanceof ClassMethod)
|
||||
&& $storage->params
|
||||
&& !$overridden_method_ids
|
||||
) {
|
||||
$manipulator = FunctionDocblockManipulator::getForFunction(
|
||||
$project_analyzer,
|
||||
|
@ -141,6 +141,75 @@ class PureAnnotationAdditionTest extends FileManipulationTest
|
||||
['MissingPureAnnotation'],
|
||||
true,
|
||||
],
|
||||
'dontAddInChildMethod' => [
|
||||
'<?php
|
||||
class A {
|
||||
public int $a = 5;
|
||||
|
||||
public function foo(string $s) : string {
|
||||
return $string . $this->a;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
public function foo(string $s) : string {
|
||||
return $string;
|
||||
}
|
||||
}',
|
||||
'<?php
|
||||
class A {
|
||||
public int $a = 5;
|
||||
|
||||
public function foo(string $s) : string {
|
||||
return $string . $this->a;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
public function foo(string $s) : string {
|
||||
return $string;
|
||||
}
|
||||
}',
|
||||
'7.4',
|
||||
['MissingPureAnnotation'],
|
||||
true,
|
||||
],
|
||||
'doAddInOtherMethod' => [
|
||||
'<?php
|
||||
class A {
|
||||
public int $a = 5;
|
||||
|
||||
public function foo(string $s) : string {
|
||||
return $string . $this->a;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
public function bar(string $s) : string {
|
||||
return $string;
|
||||
}
|
||||
}',
|
||||
'<?php
|
||||
class A {
|
||||
public int $a = 5;
|
||||
|
||||
public function foo(string $s) : string {
|
||||
return $string . $this->a;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
/**
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function bar(string $s) : string {
|
||||
return $string;
|
||||
}
|
||||
}',
|
||||
'7.4',
|
||||
['MissingPureAnnotation'],
|
||||
true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user