Open
Description
Documentation for this syntax: https://psalm.dev/docs/annotating_code/typing_in_psalm/#specifying-stringint-options-aka-enums
Example code:
class Some
{
public const STATUS_FOO = 'foo';
public const STATUS_BAR = 'bar';
/**
* @return self::STATUS_*
*/
public function dummy(): string
{
return self::STATUS_FOO;
}
}
Test:
<?php
declare(strict_types=1);
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Psr16Cache;
use TheCodingMachine\GraphQLite\Reflection\CachedDocBlockFactory;
final class GithubTest extends TestCase
{
public function testGithub(): void
{
$cachedDocBlockFactory = new CachedDocBlockFactory(new Psr16Cache(new ArrayAdapter()));
$refMethod = new \ReflectionMethod($this, 'dummy');
$docBlockObj = $cachedDocBlockFactory->getDocBlock($refMethod);
$returnTag = $docBlockObj->getTagsByName('return')[0] ?? null;
$this->assertInstanceOf(Return_::class, $returnTag);
}
public const STATUS_FOO = 'foo';
public const STATUS_BAR = 'bar';
/**
* @return self::STATUS_*
*/
public function dummy(): string
{
return self::STATUS_FOO;
}
}
Current output:
Failed asserting that phpDocumentor\Reflection\DocBlock\Tags\InvalidTag Object (...) is an instance of class "phpDocumentor\Reflection\DocBlock\Tags\Return_".
/.../tests/GithubTest.php:24
Metadata
Metadata
Assignees
Labels
No labels