1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix static call specialisation via annotation

This commit is contained in:
Brown 2020-06-22 18:40:35 -04:00
parent bee10a2eb4
commit fc8212e207
2 changed files with 33 additions and 1 deletions

View File

@ -1368,7 +1368,7 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
? ($method_storage->signature_return_type_location ?: $method_storage->location)
: null;
if ($method_storage && $method_storage->pure) {
if ($method_storage && $method_storage->specialize_call) {
$method_source = TaintNode::getForMethodReturn(
(string) $method_id,
$cased_method_id,

View File

@ -1717,4 +1717,36 @@ class TaintTest extends TestCase
$this->analyzeFile('somefile.php', new Context());
}
public function testSpecializeStaticMethod() : void
{
$this->project_analyzer->trackTaintedInputs();
$this->addFile(
'somefile.php',
'<?php
StringUtility::foo($_GET["c"]);
class StringUtility {
/**
* @psalm-taint-specialize
*/
public static function foo(string $str) : string
{
return $str;
}
/**
* @psalm-taint-specialize
*/
public static function slugify(string $url) : string {
return self::foo($url);
}
}
echo StringUtility::slugify("hello");'
);
$this->analyzeFile('somefile.php', new Context());
}
}