php8.5
Home/ Manual/ language / predefined/ TypeError

TypeError

A TypeError may be thrown when: The value being set for a class property does not match the property's corresponding declared type. The argument type being passed to a function does not match its corresponding declared parameter type. A value being returned from a function does not match the declared function return type.

Intro

A TypeError may be thrown when:

  • The value being set for a class property does not match the property's corresponding declared type.
  • The argument type being passed to a function does not match its corresponding declared parameter type.
  • A value being returned from a function does not match the declared function return type.

Class synopsis

extends Error { }

Changelog

VersionDescription
7.1.0In strict mode, passing an incorrect number of arguments to a built-in PHP function no longer results in a generic TypeError. Instead, a more specific ArgumentCountError, which extends TypeError, is thrown.

Source: language/predefined/typeerror.xml · from the official PHP manual (php/doc-en)