mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Only add pure when not overriding upstream
This commit is contained in:
parent
6103cf0f51
commit
94cec15598
@ -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