diff --git a/Makefile b/Makefile index 763adce..f3e88f2 100644 --- a/Makefile +++ b/Makefile @@ -19,14 +19,14 @@ phpcs: 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 -.PHONY: psaml +.PHONY: psalm psalm: docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/psalm + .PHONY: test test: docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/phpunit diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 1cb3002..82280e1 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,6 +1,6 @@ - The coding standard for phpDocumentor. + The coding standard for phpDocumentor. src tests/unit @@ -13,4 +13,9 @@ */src/*/Abstract*.php + + + */src/PseudoTypes/False_.php + */src/PseudoTypes/True_.php + diff --git a/src/PseudoType.php b/src/PseudoType.php new file mode 100644 index 0000000..f94cff5 --- /dev/null +++ b/src/PseudoType.php @@ -0,0 +1,19 @@ + Types\Scalar::class, 'callback' => Types\Callable_::class, 'callable' => Types\Callable_::class, - 'false' => Types\False_::class, - 'true' => Types\True_::class, + 'false' => PseudoTypes\False_::class, + 'true' => PseudoTypes\True_::class, 'self' => Types\Self_::class, '$this' => Types\This::class, 'static' => Types\Static_::class, diff --git a/src/Types/False_.php b/src/Types/False_.php deleted file mode 100644 index 39666fb..0000000 --- a/src/Types/False_.php +++ /dev/null @@ -1,29 +0,0 @@ -assertInstanceOf(Boolean::class, $false->underlyingType()); + } + + /** + * @covers ::__toString + */ + public function testFalseStringifyCorrectly() : void + { + $false = new False_(); + + $this->assertSame('false', (string) $false); + } + + /** + * @covers \phpDocumentor\Reflection\PseudoTypes\False_ + */ + public function testCanBeInstantiatedUsingDeprecatedFqsen() : void + { + $false = new \phpDocumentor\Reflection\Types\False_(); + + $this->assertSame('false', (string) $false); + $this->assertInstanceOf(False_::class, $false); + $this->assertInstanceOf(\phpDocumentor\Reflection\Types\False_::class, $false); + } +} diff --git a/tests/unit/PseudoTypes/TrueTest.php b/tests/unit/PseudoTypes/TrueTest.php new file mode 100644 index 0000000..d1d5b16 --- /dev/null +++ b/tests/unit/PseudoTypes/TrueTest.php @@ -0,0 +1,55 @@ +assertInstanceOf(Boolean::class, $true->underlyingType()); + } + + /** + * @covers ::__toString + */ + public function testTrueStringifyCorrectly() : void + { + $true = new True_(); + + $this->assertSame('true', (string) $true); + } + + /** + * @covers \phpDocumentor\Reflection\PseudoTypes\True_ + */ + public function testCanBeInstantiatedUsingDeprecatedFqsen() : void + { + $true = new \phpDocumentor\Reflection\Types\True_(); + + $this->assertSame('true', (string) $true); + $this->assertInstanceOf(True_::class, $true); + $this->assertInstanceOf(\phpDocumentor\Reflection\Types\True_::class, $true); + } +} diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 3dfbffb..10d1d64 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -704,9 +704,9 @@ public function provideKeywords() : array ['bool', Types\Boolean::class], ['boolean', Types\Boolean::class], ['true', Types\Boolean::class], - ['true', Types\True_::class], + ['true', PseudoTypes\True_::class], ['false', Types\Boolean::class], - ['false', Types\False_::class], + ['false', PseudoTypes\False_::class], ['resource', Types\Resource_::class], ['null', Types\Null_::class], ['callable', Types\Callable_::class], diff --git a/tests/unit/Types/BooleanTest.php b/tests/unit/Types/BooleanTest.php new file mode 100644 index 0000000..9e2b0e2 --- /dev/null +++ b/tests/unit/Types/BooleanTest.php @@ -0,0 +1,32 @@ +assertSame('bool', (string) $type); + } +}