ReflectionClass::isAbstract

(PHP 5, PHP 7, PHP 8)

ReflectionClass::isAbstractChecks if class is abstract

Beschreibung

public ReflectionClass::isAbstract(): bool

Checks if the class is abstract.

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Beispiele

Beispiel #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());
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

bool(false)
bool(true)

Siehe auch

add a note add a note

User Contributed Notes 1 note

up
2
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