1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-05 20:48:45 +01:00
psalm/src/Psalm/Internal/Taint/Taintable.php

48 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace Psalm\Internal\Taint;
use Psalm\CodeLocation;
2019-08-14 06:47:57 +02:00
abstract class Taintable
{
/** @var string */
public $id;
/** @var ?CodeLocation */
public $code_location;
/** @var int */
public $taint;
public function __construct(string $id, ?CodeLocation $code_location, int $taint = 0)
{
$this->id = $id;
$this->code_location = $code_location;
$this->taint = $taint;
}
2019-08-14 06:47:57 +02:00
/**
* @return static
*/
public static function getForMethodArgument(
string $method_id,
int $argument_offset,
?CodeLocation $code_location,
?CodeLocation $function_location = null
2019-08-14 06:47:57 +02:00
) {
$function_id = $method_id . '#' . ($argument_offset + 1);
if ($function_location) {
2019-08-06 23:29:44 +02:00
$function_id .= '-' . $function_location->file_name . ':' . $function_location->raw_file_start;
}
2019-08-14 06:47:57 +02:00
return new static(\strtolower($function_id), $code_location);
}
public function __toString()
{
return $this->id;
}
}