Skip to content

Tag reference

@expectedException

The @expectedException tag declares the Throwable a test method is expected to throw. It is an old PHPUnit-era convention that predates the expectException() method call and is unrelated to PhpStorm itself.

Grammar

"@expectedException" <Type> [ <Description> ]

Examples

A test expected to throw.
/**
* @expectedException InvalidArgumentException
*/
public function testRejectsNegativeAmount(): void

Names by platform

phpstorm
@expectedException

Parsing a @expectedException tag produces a ExpectedExceptionTag instance, carrying the parsed $type alongside the $name and optional $description every Tag already provides.

final class ExpectedExceptionTag extends TypedTag {}

A historical PHPUnit convention, not a PhpStorm tag.