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

Breadcrumb

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

class ExcludeList

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Util/ExcludeList.php \PHPUnit\Util\ExcludeList

Hierarchy

  • class \SebastianBergmann\GlobalState\ExcludeList

Expanded class hierarchy of ExcludeList

1 file declares its use of ExcludeList
TestCase.php in vendor/phpunit/phpunit/src/Framework/TestCase.php

File

vendor/sebastian/global-state/src/ExcludeList.php, line 16

Namespace

SebastianBergmann\GlobalState
View source
final class ExcludeList {
    private array $globalVariables = [];
    private array $classes = [];
    private array $classNamePrefixes = [];
    private array $parentClasses = [];
    private array $interfaces = [];
    private array $staticProperties = [];
    public function addGlobalVariable(string $variableName) : void {
        $this->globalVariables[$variableName] = true;
    }
    public function addClass(string $className) : void {
        $this->classes[] = $className;
    }
    public function addSubclassesOf(string $className) : void {
        $this->parentClasses[] = $className;
    }
    public function addImplementorsOf(string $interfaceName) : void {
        $this->interfaces[] = $interfaceName;
    }
    public function addClassNamePrefix(string $classNamePrefix) : void {
        $this->classNamePrefixes[] = $classNamePrefix;
    }
    public function addStaticProperty(string $className, string $propertyName) : void {
        if (!isset($this->staticProperties[$className])) {
            $this->staticProperties[$className] = [];
        }
        $this->staticProperties[$className][$propertyName] = true;
    }
    public function isGlobalVariableExcluded(string $variableName) : bool {
        return isset($this->globalVariables[$variableName]);
    }
    
    /**
     * @psalm-param class-string $className
     */
    public function isStaticPropertyExcluded(string $className, string $propertyName) : bool {
        if (in_array($className, $this->classes, true)) {
            return true;
        }
        foreach ($this->classNamePrefixes as $prefix) {
            if (str_starts_with($className, $prefix)) {
                return true;
            }
        }
        $class = new ReflectionClass($className);
        foreach ($this->parentClasses as $type) {
            if ($class->isSubclassOf($type)) {
                return true;
            }
        }
        foreach ($this->interfaces as $type) {
            if ($class->implementsInterface($type)) {
                return true;
            }
        }
        return isset($this->staticProperties[$className][$propertyName]);
    }

}

Members

Title Sort descending Modifiers Object type Summary
ExcludeList::$classes private property
ExcludeList::$classNamePrefixes private property
ExcludeList::$globalVariables private property
ExcludeList::$interfaces private property
ExcludeList::$parentClasses private property
ExcludeList::$staticProperties private property
ExcludeList::addClass public function
ExcludeList::addClassNamePrefix public function
ExcludeList::addGlobalVariable public function
ExcludeList::addImplementorsOf public function
ExcludeList::addStaticProperty public function
ExcludeList::addSubclassesOf public function
ExcludeList::isGlobalVariableExcluded public function
ExcludeList::isStaticPropertyExcluded public function @psalm-param class-string $className
RSS feed
Powered by Drupal