Skip to content

Commit

Permalink
Merge pull request #108 from phpDocumentor/feature/true-false-support
Browse files Browse the repository at this point in the history
Add support to True false pseudo types
  • Loading branch information
jaapio authored Jun 19, 2020
2 parents 7025ab6 + a1d5cf0 commit 30441f2
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 3 deletions.
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

0 comments on commit 30441f2

Please sign in to comment.