argo-php/types

There is no license information available for the latest version (v1.0.0) of this package.

Extended type system for PHP

Installs: 3

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:package

pkg:composer/argo-php/types

v1.0.0 2025-11-25 19:16 UTC

This package is auto-updated.

Last update: 2025-11-25 19:41:11 UTC


README

Extended PHP type definition system.

Allows for more complete description of types in PHP, taking into account not only built-in types but also extended phpstan/psalm types, described in PHPDoc. This package itself only provides classes with type descriptions.

Argo\Types\TypeInterface

A common interface for all types. Provides several common methods:

public function isNullable(): bool;

Checks that the specified type is nullable (that is, it allows null to be used as a value).

public function setNullable(): TypeInterface;

Returns a new instance of the type that is nullable. If the type was already nullable, it returns itself.

public function __toString(): string;

Returns a string representation of the type. This returns a full description of the type, suitable for PHPDoc.

public function toNativeTypeString(): string;

Returns a string representation of a native PHP type.

public function isContravariantTo(TypeInterface $type): bool;

Checks whether the given type is contravariant with respect to the passed $type.

Argo\Types\NamedTypeInterface

An interface implemented by all non-generic or complex types. It provides no additional methods.

Argo\Types\Atomic*

This namespace contains basic PHP types:

  • ArrayType - array type
  • BoolType - bool type
  • Callable - callable type
  • ClassType - type for all non-anonymous classes
  • FloatType - float type
  • IntType - int type
  • MixedType - mixed type
  • NeverType - never type
  • NotType - a special type for aliases that represents the negation of the type
  • NullType - null type
  • ObjectType - object type
  • ResourceType - resource type
  • StringType - string type
  • VoidType - void type

Argo\Types\Alias*

Special aliases for types:

  • ArrayKeyType - array-key (int|string)
  • CallableStringType - callable-string (string)
  • ClassStringType - class-string (string)
  • FalseType - false (bool)
  • FloatConstType - constant float (e.g. 1.23)
  • IntConstType - constant int (e.g. 123)
  • IntMaskOfType - int-mask-of (int)
  • IntMaskType - int-mask (int)
  • IntRangeType - int<min,max> (int)
  • IterableType - iterable (array|\Traversable)
  • ListType - list (array)
  • NegativeIntType - negative-int (int)
  • NonEmptyArrayType - non-empty-array (array)
  • NonEmptyListType - non-empty-list (array)
  • NonEmptyStringType - non-empty-string (string)
  • NonFalsyStringType - non-falsy-string (string)
  • NonNegativeIntType - non-negative-int (int)
  • NonPositiveIntType - non-positive-int (int)
  • NumericStringType - numeric-string (string)
  • NumericType - numeric (int|float|numeric-string)
  • PositiveIntType - positive-int (int)
  • ScalarType - scalar (string|int|float|bool)
  • StringConstType - constant string (e.g. "hello")
  • TraitStringType - trait-string (string)
  • TrueType - true (bool)
  • TruthyStringType - truthy-string (string)

Argo\Types\Complex*

Complex types:

  • IntersectType - intersection type of several types (intersect)
  • UnionType - union type of several types (union)