Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. File.php

function File::findImplementedInterfaceNames

Returns the names of the interfaces that the specified class or enum implements.

Returns FALSE on error or if there are no implemented interface names.

Parameters

int $stackPtr The stack position of the class or enum token.:

Return value

array|false

File

vendor/squizlabs/php_codesniffer/src/Files/File.php, line 2908

Class

File

Namespace

PHP_CodeSniffer\Files

Code

public function findImplementedInterfaceNames($stackPtr) {
    // Check for the existence of the token.
    if (isset($this->tokens[$stackPtr]) === false) {
        return false;
    }
    if ($this->tokens[$stackPtr]['code'] !== T_CLASS && $this->tokens[$stackPtr]['code'] !== T_ANON_CLASS && $this->tokens[$stackPtr]['code'] !== T_ENUM) {
        return false;
    }
    if (isset($this->tokens[$stackPtr]['scope_closer']) === false) {
        return false;
    }
    $classOpenerIndex = $this->tokens[$stackPtr]['scope_opener'];
    $implementsIndex = $this->findNext(T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
    if ($implementsIndex === false) {
        return false;
    }
    $find = [
        T_NS_SEPARATOR,
        T_STRING,
        T_WHITESPACE,
        T_COMMA,
    ];
    $end = $this->findNext($find, $implementsIndex + 1, $classOpenerIndex + 1, true);
    $name = $this->getTokensAsString($implementsIndex + 1, $end - $implementsIndex - 1);
    $name = trim($name);
    if ($name === '') {
        return false;
    }
    else {
        $names = explode(',', $name);
        $names = array_map('trim', $names);
        return $names;
    }
}
RSS feed
Powered by Drupal