Types

This document provides a non-exhaustive list of PHP and docblock types and indicates if Phpactor supports them or not. For more information about these types see:

Basic Types

Name

Example

PHP

Phpactor

Array

array

*

Boolean

bool

*

Float

float

*

Int

int

*

Resource

(internal type)

*

String

string

*

Self

self

*

Parent

parent

*

🤷 mostly

Callable

callable

*

Iterable

iterable

7.1

Nullable

?Foor

7.1

Object

object

7.2

Union

Foo|Bar

8.0

Mixed

mixed

8.0

Intersection

Foo&Bar

8.1

Return Only Types

Name

Example

PHP

Phpactor

Notes

Void

void

7.4+

Static

static

8.0

Never

never

8.1+

False

false

8.2+

Pseudo-type before 8.2

Null

null

8.2+

Docblock Types

Name

Example

Phpactor

Array Key

array-key

Array Literal

array{string,int}

Array Shape

array{foo:string,baz:int}

Class String

class-string<T>

🤷

Closure

Closure(string, int): void

Float Literal

1234.12

Generics

Foobar<Barfoo>

Int Literal

1234

List

list<string>

Parenthesized

(Foo&Bar)|object

String Literal

"hello"

This

$this (same as static)

Integer Types

Example

PHP

Supported

Description

123

*

Integer

0b0110

*

Binary type

0x1a

*

Hexidecimal

0123

*

Octal

123_123

7.4

Decimal

0o123

8.1

Octal

Conditional Types

Phpactor undestands conditional return types of the form:

/**
 * @return (
 *     $array is array<int>
 *     ? int
 *     : ($array is array<float>
 *         ? float
 *         : float|int
 *     )
 * )
 */
function array_some(array $array) {
    return array_sum($array);
}