array |
function foo(array $bar) | PHP 5.1+ | example |
function foo(array $bar = null) | PHP 5.1+ | example |
function foo(?array $bar) | PHP 7.1+ | example |
function foo(): array | PHP 7.0+ | example |
function foo(): ?array | PHP 7.1+ | example |
bool |
function foo(bool $bar) | PHP 7.0+ | example |
function foo(bool $bar = null) | PHP 7.0+ | example |
function foo(?bool $bar) | PHP 7.1+ | example |
function foo(): bool | PHP 7.0+ | example |
function foo(): ?bool | PHP 7.1+ | example |
callable |
function foo(callable $bar) | PHP 5.4+ | example |
function foo(callable $bar = null) | PHP 5.4+ | example |
function foo(?callable $bar) | PHP 7.1+ | example |
function foo(): callable | PHP 7.0+ | example |
function foo(): ?callable | PHP 7.1+ | example |
float |
function foo(float $bar) | PHP 7.0+ | example |
function foo(float $bar = null) | PHP 7.0+ | example |
function foo(?float $bar) | PHP 7.1+ | example |
function foo(): float | PHP 7.0+ | example |
function foo(): ?float | PHP 7.1+ | example |
int |
function foo(int $bar) | PHP 7.0+ | example |
function foo(int $bar = null) | PHP 7.0+ | example |
function foo(?int $bar) | PHP 7.1+ | example |
function foo(): int | PHP 7.0+ | example |
function foo(): ?int | PHP 7.1+ | example |
iterable |
function foo(iterable $bar) | PHP 7.1+ | example |
function foo(iterable $bar = null) | PHP 7.1+ | example |
function foo(?iterable $bar) | PHP 7.1+ | example |
function foo(): iterable | PHP 7.1+ | example |
function foo(): ?iterable | PHP 7.1+ | example |
object |
function foo(object $bar) | PHP 7.2+ | example |
function foo(object $bar = null) | PHP 7.2+ | example |
function foo(?object $bar) | PHP 7.2+ | example |
function foo(): object | PHP 7.2+ | example |
function foo(): ?object | PHP 7.2+ | example |
self |
function foo(self $bar) | PHP 5.0+ | example |
function foo(self $bar = null) | PHP 5.1+ | example |
function foo(?self $bar) | PHP 7.1+ | example |
function foo(): self | PHP 7.0+ | example |
function foo(): ?self | PHP 7.1+ | example |
static |
function foo(static $bar) | never | example |
function foo(static $bar = null) | never | example |
function foo(?static $bar) | never | example |
function foo(): static | PHP 8.0+ | example |
function foo(): ?static | PHP 8.0+ | example |
string |
function foo(string $bar) | PHP 7.0+ | example |
function foo(string $bar = null) | PHP 7.0+ | example |
function foo(?string $bar) | PHP 7.1+ | example |
function foo(): string | PHP 7.0+ | example |
function foo(): ?string | PHP 7.1+ | example |
class names |
function foo(ClassName $bar) | PHP 5.0+ | example |
function foo(ClassName $bar = null) | PHP 5.1+ | example |
function foo(?ClassName $bar) | PHP 7.1+ | example |
function foo(): ClassName | PHP 7.0+ | example |
function foo(): ?ClassName | PHP 7.1+ | example |
void |
function foo(): void | PHP 7.1+ | example |
boolean, double, integer, resource |
Never recognized as valid for type hinting | example |