ReflectionClass::isAbstract

(PHP 5, PHP 7, PHP 8)

ReflectionClass::isAbstractChecks if class is abstract

Description

public ReflectionClass::isAbstract(): bool

Checks if the class is abstract.

Parameters

This function has no parameters.

Return Values

Returns true on success or false on failure.

Examples

Example #1 ReflectionClass::isAbstract() example

<?php
class          TestClass { }
abstract class 
TestAbstractClass { }

$testClass     = new ReflectionClass('TestClass');
$abstractClass = new ReflectionClass('TestAbstractClass');

var_dump($testClass->isAbstract());
var_dump($abstractClass->isAbstract());
?>

The above example will output:

bool(false)
bool(true)

See Also

add a note add a note

User Contributed Notes 1 note

up
1
baptiste at pillot dot fr
7 years ago
For interfaces and traits :

<?php
interface TestInterface { }
trait    
TestTrait { }

$interfaceClass = new ReflectionClass('TestInterface');
$traitClass     = new ReflectionClass('TestTrait');

var_dump($interfaceClass->isAbstract());
var_dump($traitClass->isAbstract());
?>

Using PHP versions 5.4- to 5.6, the above example will output:

bool(false)
bool(true)

Using PHP versions 7.0+, the above example will output:

bool(false)
bool(false)
To Top