php8.5
Home/ Manual/ reflection / reflectionclass/ ReflectionClass::getInterfaces

ReflectionClass::getInterfaces

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Gets the interfaces

Description

ReflectionClass::getInterfaces(): array

Gets the interfaces.

Parameters Parameters

Return Values

An associative array of interfaces, with keys as interface names and the array values as ReflectionClass objects.

Examples

ReflectionClass::getInterfaces example

php
<?php
interface Foo { }

interface Bar { }

class Baz implements Foo, Bar { }

$rc1 = new ReflectionClass("Baz");

print_r($rc1->getInterfaces());
?>

The above example will output something similar to:

output
Array
(
    [Foo] => ReflectionClass Object
        (
            [name] => Foo
        )

    [Bar] => ReflectionClass Object
        (
            [name] => Bar
        )

)

See Also

  • ReflectionClass::getInterfaceNames

Source: reference/reflection/reflectionclass/getinterfaces.xml · from the official PHP manual (php/doc-en)