Usephul

Type : string
in package
uses EnumDynamicity

Possible types as returned by {@see gettype()}.

Table of Contents

Cases

Array  = 'array'
An array in PHP is actually an ordered map. A map is a type that associates values to keys.
Boolean  = 'boolean'
The boolean type only has two values, and is used to express a truth value. It can be either TRUE or FALSE.
ClosedResource  = 'resource (closed)'
Closed resources are reported as "resource (closed)".
Float  = 'double'
A {@link https://www.php.net/types.float float} is a floating point number, also known as a "double", or "real number".
Integer  = 'integer'
An integer is a number of the set ℤ = {..., -2, -1, 0, 1, 2, ...}.
Null  = 'NULL'
The null type is PHP's unit type, i.e. it has only one value: NULL.
Object  = 'object'
An object is an instance of a class or an enumeration.
Resource  = 'resource'
A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions.
String  = 'string'
A string is a series of characters, where a character is the same as a byte.
Unknown  = 'unknown type'
A value of an unknown type.

Methods

is()  : bool
Checks whether the type of provided value matches this {@see Type}.
of()  : self
Returns the Type instance of the provided value.
tryOf()  : self|null
Returns the Type of the provided value. If the value is of an unknown type, it will return NULL.

Cases

Null

The null type is PHP's unit type, i.e. it has only one value: NULL.

Undefined and unset() variables will also resolve to the value NULL.

Boolean

The boolean type only has two values, and is used to express a truth value. It can be either TRUE or FALSE.

Integer

An integer is a number of the set ℤ = {..., -2, -1, 0, 1, 2, ...}.

Float

A {@link https://www.php.net/types.float float} is a floating point number, also known as a "double", or "real number".

String

A string is a series of characters, where a character is the same as a byte.

Array

An array in PHP is actually an ordered map. A map is a type that associates values to keys.

This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible.

Object

An object is an instance of a class or an enumeration.

Resource

A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions.

See the appendix for a listing of all these functions and the corresponding resource types.

See also the get_resource_type() function.

ClosedResource

Closed resources are reported as "resource (closed)".

Unknown

A value of an unknown type.

Methods

is()

Checks whether the type of provided value matches this {@see Type}.

public is(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

of()

Returns the Type instance of the provided value.

public static of(mixed $value) : self
Parameters
$value : mixed

The value for which to deduce the type.

Return values
self

A Type case instance.

tryOf()

Returns the Type of the provided value. If the value is of an unknown type, it will return NULL.

public static tryOf(mixed $value) : self|null
Parameters
$value : mixed
Return values
self|null

        
On this page

Search results