Skip to content

Commit

Permalink
Move nonnull type to public namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Jun 9, 2024
1 parent 99a1dd6 commit df747f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Psl/Internal/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ final class Loader
'Psl\\Type\\Internal\\IterableType' => 'Psl/Type/Internal/IterableType.php',
'Psl\\Type\\Internal\\MixedType' => 'Psl/Type/Internal/MixedType.php',
'Psl\\Type\\Internal\\NullType' => 'Psl/Type/Internal/NullType.php',
'Psl\\Type\\Internal\\NonNullType' => 'Psl/Type/Internal/NonNullType.php',
'Psl\\Type\\NonNullType' => 'Psl/Type/Internal/NonNullType.php',
'Psl\\Type\\Internal\\NullableType' => 'Psl/Type/Internal/NullableType.php',
'Psl\\Type\\Internal\\OptionalType' => 'Psl/Type/Internal/OptionalType.php',
'Psl\\Type\\Internal\\PositiveIntType' => 'Psl/Type/Internal/PositiveIntType.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

declare(strict_types=1);

namespace Psl\Type\Internal;
namespace Psl\Type;

use Psl\Type;
use Psl\Type\Exception\AssertException;
use Psl\Type\Exception\CoercionException;

/**
* This type is not marked as internal, cause the class is being leaked by the nonnull() function.
* This is necessary to get coerce and assert narrow down the type without psalm having a TNonNull type.
*
* @ara-extends Type\Type<nonnull>
*
* @extends Type\Type<mixed>
*
* @internal
*/
final readonly class NonNullType extends Type\Type
{
Expand Down
6 changes: 2 additions & 4 deletions src/Psl/Type/nonnull.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Psl\Type;

use Psl\Type\Internal\NonNullType;

/**
* @psalm-pure
*
Expand All @@ -17,8 +15,8 @@
*/
function nonnull(): TypeInterface
{
/** @var Internal\NonNullType $instance */
static $instance = new Internal\NonNullType();
/** @var NonNullType $instance */
static $instance = new NonNullType();

return $instance;
}

0 comments on commit df747f2

Please sign in to comment.