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

Breadcrumb

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

class CachingParser

@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

@internal This class is not covered by the backward compatibility promise for PHPUnit

Hierarchy

  • class \PHPUnit\Metadata\Parser\CachingParser implements \PHPUnit\Metadata\Parser\Parser

Expanded class hierarchy of CachingParser

File

vendor/phpunit/phpunit/src/Metadata/Parser/CachingParser.php, line 22

Namespace

PHPUnit\Metadata\Parser
View source
final class CachingParser implements Parser {
    private readonly Parser $reader;
    private array $classCache = [];
    private array $methodCache = [];
    private array $classAndMethodCache = [];
    public function __construct(Parser $reader) {
        $this->reader = $reader;
    }
    
    /**
     * @psalm-param class-string $className
     */
    public function forClass(string $className) : MetadataCollection {
        assert(class_exists($className));
        if (isset($this->classCache[$className])) {
            return $this->classCache[$className];
        }
        $this->classCache[$className] = $this->reader
            ->forClass($className);
        return $this->classCache[$className];
    }
    
    /**
     * @psalm-param class-string $className
     * @psalm-param non-empty-string $methodName
     */
    public function forMethod(string $className, string $methodName) : MetadataCollection {
        assert(class_exists($className));
        assert(method_exists($className, $methodName));
        $key = $className . '::' . $methodName;
        if (isset($this->methodCache[$key])) {
            return $this->methodCache[$key];
        }
        $this->methodCache[$key] = $this->reader
            ->forMethod($className, $methodName);
        return $this->methodCache[$key];
    }
    
    /**
     * @psalm-param class-string $className
     * @psalm-param non-empty-string $methodName
     */
    public function forClassAndMethod(string $className, string $methodName) : MetadataCollection {
        $key = $className . '::' . $methodName;
        if (isset($this->classAndMethodCache[$key])) {
            return $this->classAndMethodCache[$key];
        }
        $this->classAndMethodCache[$key] = $this->forClass($className)
            ->mergeWith($this->forMethod($className, $methodName));
        return $this->classAndMethodCache[$key];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
CachingParser::$classAndMethodCache private property
CachingParser::$classCache private property
CachingParser::$methodCache private property
CachingParser::$reader private property
CachingParser::forClass public function @psalm-param class-string $className Overrides Parser::forClass
CachingParser::forClassAndMethod public function @psalm-param class-string $className
@psalm-param non-empty-string $methodName
Overrides Parser::forClassAndMethod
CachingParser::forMethod public function @psalm-param class-string $className
@psalm-param non-empty-string $methodName
Overrides Parser::forMethod
CachingParser::__construct public function
RSS feed
Powered by Drupal