Skip to content

Commit

Permalink
Fix static call specialisation via annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jun 22, 2020
1 parent bee10a2 commit fc8212e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ private static function taintReturnType(
? ($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,
Expand Down
32 changes: 32 additions & 0 deletions tests/TaintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1717,4 +1717,36 @@ public function testImplodeExplode() : void

$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());
}
}

0 comments on commit fc8212e

Please sign in to comment.