Skip to content

Add support for never keyword #130

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 2 commits into from
Sep 17, 2021
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
1 change: 1 addition & 0 deletions src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ final class TypeResolver
'static' => Types\Static_::class,
'parent' => Types\Parent_::class,
'iterable' => Types\Iterable_::class,
'never' => Types\Never_::class,
];

/**
Expand Down
35 changes: 35 additions & 0 deletions src/Types/Never_.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/**
* 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
*/

namespace phpDocumentor\Reflection\Types;

use phpDocumentor\Reflection\Type;

/**
* Value Object representing the return-type 'never'.
*
* Never is generally only used when working with return types as it signifies that the method that only
* ever throw or exit.
*
* @psalm-immutable
*/
final class Never_ implements Type
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString(): string
{
return 'never';
}
}
2 changes: 1 addition & 1 deletion src/Types/Void_.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use phpDocumentor\Reflection\Type;

/**
* Value Object representing the pseudo-type 'void'.
* Value Object representing the return-type 'void'.
*
* Void is generally only used when working with return types as it signifies that the method intentionally does not
* return any value.
Expand Down
1 change: 1 addition & 0 deletions tests/unit/TypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ public function provideKeywords(): array
['self', Types\Self_::class],
['parent', Types\Parent_::class],
['iterable', Types\Iterable_::class],
['never', Types\Never_::class],
];
}

Expand Down