argo-php / types
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
Requires
- php: 8.3.*|8.4.*|8.5.*
Requires (Dev)
- laravel/pint: ^1.25
- mockery/mockery: ^1.6
- phpunit/phpunit: ^11.0
- roave/security-advisories: dev-latest
- vimeo/psalm: ^6.13
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 typeBoolType- bool typeCallable- callable typeClassType- type for all non-anonymous classesFloatType- float typeIntType- int typeMixedType- mixed typeNeverType- never typeNotType- a special type for aliases that represents the negation of the typeNullType- null typeObjectType- object typeResourceType- resource typeStringType- string typeVoidType- 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)