Skip to content

Commit 4fc5976

Browse files
committed
add support for literal-string
1 parent 4b3579f commit 4fc5976

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ psalm:
2929

3030
.PHONY: test
3131
test:
32-
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/phpunit
32+
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.3 tools/phpunit
3333

3434
.PHONY: pre-commit-test
3535
pre-commit-test: test phpcs phpstan psalm

src/PseudoTypes/LiteralString.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link http://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Reflection\PseudoTypes;
15+
16+
use phpDocumentor\Reflection\PseudoType;
17+
use phpDocumentor\Reflection\Type;
18+
use phpDocumentor\Reflection\Types\String_;
19+
20+
/**
21+
* Value Object representing the type 'string'.
22+
*
23+
* @psalm-immutable
24+
*/
25+
final class LiteralString extends String_ implements PseudoType
26+
{
27+
public function underlyingType(): Type
28+
{
29+
return new String_();
30+
}
31+
32+
/**
33+
* Returns a rendered output of the Type as it would be used in a DocBlock.
34+
*/
35+
public function __toString(): string
36+
{
37+
return 'literal-string';
38+
}
39+
}

src/TypeResolver.php

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ final class TypeResolver
102102
'callable-string' => PseudoTypes\CallableString::class,
103103
'false' => PseudoTypes\False_::class,
104104
'true' => PseudoTypes\True_::class,
105+
'literal-string' => PseudoTypes\LiteralString::class,
105106
'self' => Types\Self_::class,
106107
'$this' => Types\This::class,
107108
'static' => Types\Static_::class,

tests/unit/TypeResolverTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ public function provideKeywords(): array
758758
['parent', Types\Parent_::class],
759759
['iterable', Types\Iterable_::class],
760760
['never', Types\Never_::class],
761+
['literal-string', PseudoTypes\LiteralString::class],
761762
];
762763
}
763764

0 commit comments

Comments
 (0)