Home
My Account
About us
Products
Support Services
Buy online
Downloads
Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
PHP Manual
Predefined Exceptions
Exception
ErrorException
ClosedGeneratorException
Error
ArgumentCountError
ArithmeticError
AssertionError
DivisionByZeroError
CompileError
ParseError
TypeError
ValueError
UnhandledMatchError
FiberError
RequestParseBodyException
ParseError
ValueError
Predefined Exceptions
Last updated: Mon, 26 Oct 2026
TypeError
(PHP 7, PHP 8)
Introduction
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
class
TypeError
extends
Error
{
/* Inherited properties */
protected
string
$
message
= ""
;
private
string
$
string
= ""
;
protected
int
$
code
;
protected
string
$
file
= ""
;
protected
int
$
line
;
private
array
$
trace
= []
;
private
?
Throwable
$
previous
= null
;
/* Inherited methods */
public
function
Error::__construct
(
string
$message
= ""
,
int
$code
= 0
,
?
Throwable
$previous
=
null
)
final
public
function
Error::getMessage
():
string
final
public
function
Error::getPrevious
():
?
Throwable
final
public
function
Error::getCode
():
int
final
public
function
Error::getFile
():
string
final
public
function
Error::getLine
():
int
final
public
function
Error::getTrace
():
array
final
public
function
Error::getTraceAsString
():
string
public
function
Error::__toString
():
string
private
function
Error::__clone
():
void
}
Changelog
Version
Description
7.1.0
In 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.
ParseError
ValueError
Predefined Exceptions
Last updated: Mon, 26 Oct 2026