TypeError
(PHP 7, PHP 8)
소개
다음과 같은 경우 TypeError가 발생할 수 있습니다.
- 클래스 속성에 대해 설정되는 값이 속성의 해당 선언된 유형과 일치하지 않습니다.
- 함수에 전달되는 인수 유형이 해당 선언된 매개변수 유형과 일치하지 않습니다.
- 함수에서 반환되는 값이 선언된 함수 반환 유형과 일치하지 않습니다.
클래스 개요
class TypeError extends Error {
/* Inherited properties */
protected string $message;
protected int $code;
protected string $file;
protected int $line;
/* Inherited methods */
final public Error::getMessage(): string
final public Error::getPrevious(): ?Throwable
final public Error::getCode(): int
final public Error::getFile(): string
final public Error::getLine(): int
final public Error::getTrace(): array
final public Error::getTraceAsString(): string
public Error::__toString(): string
final private Error::__clone(): void
}
변경 로그
Version | Description |
---|---|
7.1.0 | A TypeError is no longer thrown when an invalid number of arguments are passed to a built-in PHP function in strict mode. Instead, an ArgumentCountError is raised. |