ClassDiscovery
in package
Registry that based find results on class existence.
Tags
Table of Contents
Properties
- $cache : array<string|int, mixed>
- Discovery cache to make the second time we use discovery faster.
- $deprecatedStrategies : mixed
- $strategies : array<string|int, DiscoveryStrategy>
- A list of strategies to find classes.
Methods
- appendStrategy() : mixed
- Append a strategy at the end of the strategy queue.
- clearCache() : mixed
- getStrategies() : array<string|int, string>
- Returns the currently configured discovery strategies as fully qualified class names.
- prependStrategy() : mixed
- Prepend a strategy at the beginning of the strategy queue.
- safeClassExists() : bool
- We need a "safe" version of PHP's "class_exists" because Magento has a bug (or they call it a "feature"). Magento is throwing an exception if you do class_exists() on a class that ends with "Factory" and if that file does not exits.
- setStrategies() : mixed
- Set new strategies and clear the cache.
- evaluateCondition() : bool
- Evaluates conditions to boolean.
- findOneByType() : string|Closure
- Finds a class.
- instantiateClass() : object
- Get an instance of the $class.
- getFromCache() : string|null
- Get a value from cache.
- storeInCache() : mixed
- Store a value in cache.
Properties
$cache
Discovery cache to make the second time we use discovery faster.
private
static array<string|int, mixed>
$cache
= []
$deprecatedStrategies
private
static mixed
$deprecatedStrategies
= [\Http\Discovery\Strategy\PuliBetaStrategy::class => true]
$strategies
A list of strategies to find classes.
private
static array<string|int, DiscoveryStrategy>
$strategies
= [\Http\Discovery\Strategy\GeneratedDiscoveryStrategy::class, \Http\Discovery\Strategy\CommonClassesStrategy::class, \Http\Discovery\Strategy\CommonPsr17ClassesStrategy::class, \Http\Discovery\Strategy\PuliBetaStrategy::class]
Methods
appendStrategy()
Append a strategy at the end of the strategy queue.
public
static appendStrategy(string $strategy) : mixed
Parameters
- $strategy : string
-
Fully qualified class name of a DiscoveryStrategy
clearCache()
public
static clearCache() : mixed
getStrategies()
Returns the currently configured discovery strategies as fully qualified class names.
public
static getStrategies() : array<string|int, string>
Return values
array<string|int, string>prependStrategy()
Prepend a strategy at the beginning of the strategy queue.
public
static prependStrategy(string $strategy) : mixed
Parameters
- $strategy : string
-
Fully qualified class name to a DiscoveryStrategy
safeClassExists()
We need a "safe" version of PHP's "class_exists" because Magento has a bug (or they call it a "feature"). Magento is throwing an exception if you do class_exists() on a class that ends with "Factory" and if that file does not exits.
public
static safeClassExists(string $class) : bool
This function catches all potential exceptions and makes sure to always return a boolean.
Parameters
- $class : string
Return values
boolsetStrategies()
Set new strategies and clear the cache.
public
static setStrategies(array<string|int, string> $strategies) : mixed
Parameters
- $strategies : array<string|int, string>
-
list of fully qualified class names that implement DiscoveryStrategy
evaluateCondition()
Evaluates conditions to boolean.
protected
static evaluateCondition(mixed $condition) : bool
Parameters
- $condition : mixed
Return values
boolfindOneByType()
Finds a class.
protected
static findOneByType(string $type) : string|Closure
Parameters
- $type : string
Tags
Return values
string|ClosureinstantiateClass()
Get an instance of the $class.
protected
static instantiateClass(string|Closure $class) : object
Parameters
- $class : string|Closure
-
a FQCN of a class or a closure that instantiate the class
Tags
Return values
objectgetFromCache()
Get a value from cache.
private
static getFromCache(string $type) : string|null
Parameters
- $type : string
Return values
string|nullstoreInCache()
Store a value in cache.
private
static storeInCache(string $type, string $class) : mixed
Parameters
- $type : string
- $class : string