Skip to content

Add support to True false pseudo types #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ setup: install-phive
phpcs:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -s

.PHONY: phpcbf
phpcbf:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf


.PHONY: phpstan
phpstan:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src --no-progress --configuration phpstan.neon
Expand Down
4 changes: 2 additions & 2 deletions src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ final class TypeResolver
'scalar' => Types\Scalar::class,
'callback' => Types\Callable_::class,
'callable' => Types\Callable_::class,
'false' => Types\Boolean::class,
'true' => Types\Boolean::class,
'false' => Types\False_::class,
'true' => Types\True_::class,
'self' => Types\Self_::class,
'$this' => Types\This::class,
'static' => Types\Static_::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @psalm-immutable
*/
final class Boolean implements Type
class Boolean implements Type
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
Expand Down
29 changes: 29 additions & 0 deletions src/Types/False_.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

declare(strict_types=1);

namespace phpDocumentor\Reflection\Types;

/**
* Value Object representing a False pseudo type.
*
* @psalm-immutable
*/
class False_ extends Boolean
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
{
return 'false';
}
}
29 changes: 29 additions & 0 deletions src/Types/True_.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

declare(strict_types=1);

namespace phpDocumentor\Reflection\Types;

/**
* Value Object representing a True pseudo type.
*
* @psalm-immutable
*/
class True_ extends Boolean
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
{
return 'true';
}
}
4 changes: 4 additions & 0 deletions tests/unit/TypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ public function provideKeywords() : array
['double', Types\Float_::class],
['bool', Types\Boolean::class],
['boolean', Types\Boolean::class],
['true', Types\Boolean::class],
['true', Types\True_::class],
['false', Types\Boolean::class],
['false', Types\False_::class],
['resource', Types\Resource_::class],
['null', Types\Null_::class],
['callable', Types\Callable_::class],
Expand Down