2021-08-17 18:40:11 +02:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psalm\Tests\Internal\Codebase;
|
|
|
|
|
|
|
|
use Psalm\Internal\Codebase\ClassLikes;
|
|
|
|
use Psalm\Internal\Provider\ClassLikeStorageProvider;
|
|
|
|
use Psalm\Storage\ClassLikeStorage;
|
|
|
|
use Psalm\Tests\TestCase;
|
|
|
|
|
|
|
|
final class ClassLikesTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ClassLikes
|
|
|
|
*/
|
2021-08-17 21:46:00 +02:00
|
|
|
private $classlikes;
|
2021-08-17 18:40:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ClassLikeStorageProvider
|
|
|
|
*/
|
2021-08-17 21:46:00 +02:00
|
|
|
private $storage_provider;
|
2021-08-17 18:40:11 +02:00
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2021-08-17 21:46:00 +02:00
|
|
|
$this->classlikes = $this->project_analyzer->getCodebase()->classlikes;
|
|
|
|
$this->storage_provider = $this->project_analyzer->getCodebase()->classlike_storage_provider;
|
2021-08-17 18:40:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testWillDetectClassImplementingAliasedInterface(): void
|
|
|
|
{
|
2021-08-17 21:46:00 +02:00
|
|
|
$this->classlikes->addClassAlias('Foo', 'bar');
|
2021-08-17 18:40:11 +02:00
|
|
|
|
|
|
|
$classStorage = new ClassLikeStorage('Baz');
|
|
|
|
$classStorage->class_implements['bar'] = 'Bar';
|
|
|
|
|
2021-08-17 21:46:00 +02:00
|
|
|
$this->storage_provider->addMore(['baz' => $classStorage]);
|
2021-08-17 18:40:11 +02:00
|
|
|
|
2021-08-17 21:46:00 +02:00
|
|
|
self::assertTrue($this->classlikes->classImplements('Baz', 'Foo'));
|
2021-08-17 18:40:11 +02:00
|
|
|
}
|
|
|
|
}
|