2016-05-15 23:06:03 -04:00
|
|
|
<?php
|
2018-11-05 21:57:36 -05:00
|
|
|
namespace Psalm\Internal\Analyzer;
|
2016-05-15 23:06:03 -04:00
|
|
|
|
|
|
|
use PhpParser;
|
2018-01-21 12:44:46 -05:00
|
|
|
use Psalm\Aliases;
|
|
|
|
use Psalm\StatementsSource;
|
2016-08-13 14:20:46 -04:00
|
|
|
|
2018-11-05 21:57:36 -05:00
|
|
|
class TraitAnalyzer extends ClassLikeAnalyzer
|
2016-05-15 23:06:03 -04:00
|
|
|
{
|
2016-11-02 02:29:00 -04:00
|
|
|
/**
|
2018-01-21 12:44:46 -05:00
|
|
|
* @var Aliases
|
2016-11-02 02:29:00 -04:00
|
|
|
*/
|
2018-01-21 12:44:46 -05:00
|
|
|
private $aliases;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $fq_class_name
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
PhpParser\Node\Stmt\Trait_ $class,
|
2018-11-05 21:57:36 -05:00
|
|
|
SourceAnalyzer $source,
|
2018-01-21 12:44:46 -05:00
|
|
|
$fq_class_name,
|
|
|
|
Aliases $aliases
|
|
|
|
) {
|
|
|
|
$this->source = $source;
|
2018-11-11 12:01:14 -05:00
|
|
|
$this->file_analyzer = $source->getFileAnalyzer();
|
2018-11-05 21:57:36 -05:00
|
|
|
$this->aliases = $source->getAliases();
|
2016-08-13 18:54:49 -04:00
|
|
|
$this->class = $class;
|
2016-11-07 17:29:51 -05:00
|
|
|
$this->fq_class_name = $fq_class_name;
|
2018-11-11 12:19:53 -05:00
|
|
|
$codebase = $source->getCodebase();
|
|
|
|
$this->storage = $codebase->classlike_storage_provider->get($fq_class_name);
|
2018-01-21 12:44:46 -05:00
|
|
|
$this->aliases = $aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-01-28 17:07:09 -05:00
|
|
|
* @return null|string
|
2018-01-21 12:44:46 -05:00
|
|
|
*/
|
|
|
|
public function getNamespace()
|
|
|
|
{
|
|
|
|
return $this->aliases->namespace;
|
|
|
|
}
|
2016-05-15 23:06:03 -04:00
|
|
|
|
2018-01-21 12:44:46 -05:00
|
|
|
/**
|
|
|
|
* @return Aliases
|
|
|
|
*/
|
|
|
|
public function getAliases()
|
|
|
|
{
|
|
|
|
return $this->aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<string, string>
|
|
|
|
*/
|
|
|
|
public function getAliasedClassesFlipped()
|
|
|
|
{
|
|
|
|
return [];
|
2016-05-15 23:06:03 -04:00
|
|
|
}
|
|
|
|
}
|