ServiceMapResultCacheValueExtension
API reference › PHPStan › ServiceMapResultCacheValueExtension
Exposes the Yii configuration values that drive inferred types to the PHPStan result cache.
Extensions record a value dependency (trackValueDependency()) on one of the keys built by this class whenever they
read the configuration on behalf of analysed code, including when the configuration has no entry for the requested
id. On the next run PHPStan compares getValue() with the recorded value and re-analyses only the files whose
values changed, which also covers configuration composed from several files through require.
ResultCacheValueExtension for PHPStan result cache value extension contract.
ServiceMap for service and component map for Yii Application static analysis.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Initializes configuration value tracking with the configured generic component map. | ServiceMapResultCacheValueExtension |
behaviorsKey() static | Returns the key for the behaviors attached to the given class. | ServiceMapResultCacheValueExtension |
componentKey() static | Returns the key for the application component with the given id. | ServiceMapResultCacheValueExtension |
getValue() | Returns the current configuration value for the given key. | ServiceMapResultCacheValueExtension |
keyFromResultCache() | Returns the key unchanged, since keys hold ids and class names rather than file paths. | ServiceMapResultCacheValueExtension |
keyToResultCache() | Returns the key unchanged, since keys hold ids and class names rather than file paths. | ServiceMapResultCacheValueExtension |
serviceKey() static | Returns the key for the DI container definition or singleton with the given id. | ServiceMapResultCacheValueExtension |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
APPLICATION_KEY | 'application' | Key of the configured application class. | ServiceMapResultCacheValueExtension |
MISSING | 'missing' | Value returned for keys whose id has no configuration entry. | ServiceMapResultCacheValueExtension |
PARAMS_KEY | 'params' | Key of the array shape inferred for the application params. | ServiceMapResultCacheValueExtension |
UNRESOLVED | 'unresolved' | Value returned for a component or service defined in the configuration whose class can’t be determined. | ServiceMapResultCacheValueExtension |
UNSUPPORTED | 'unsupported' | Value returned for keys this class doesn’t build, such as keys stored by another version of the extension. | ServiceMapResultCacheValueExtension |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(yii2\extensions\phpstan\ServiceMap $serviceMap, array<string, string> $genericComponents = [])Initializes configuration value tracking with the configured generic component map.
Parameters
| Parameter | Type | Description |
|---|---|---|
$serviceMap | ServiceMap | Service and component map for Yii Application static analysis. |
$genericComponents | array<string, | Map of component id to the definition key holding its generic type argument (yii2.component_generics). |
behaviorsKey()
Section titled “behaviorsKey() ”public static function behaviorsKey(string $className): stringReturns the key for the behaviors attached to the given class.
Parameters
| Parameter | Type | Description |
|---|---|---|
$className | string | Fully qualified class name the behaviors are configured for. |
Returns
string
componentKey()
Section titled “componentKey() ”public static function componentKey(string $id): stringReturns the key for the application component with the given id.
Parameters
| Parameter | Type | Description |
|---|---|---|
$id | string | Component id. |
Returns
string
getValue()
Section titled “getValue() ”public function getValue(string $key): stringReturns the current configuration value for the given key.
Each value covers exactly what the extensions derive types from:
application: the configured application class.params: a hash of the params shape built byParamsTypeBuilder, orMISSINGwhen no params are configured.component:<id>: a hash of the component class and its generic type argument,UNRESOLVEDwhen the component is defined with a class that can’t be determined, orMISSING.service:<id>: the configured service class,UNRESOLVEDwhen the service is defined with a class that can’t be determined, orMISSING.behaviors:<class>: a hash of the ordered behavior classes, orMISSINGwhen none are attached.
Any other key yields UNSUPPORTED, so a result cache written by another version of the extension
re-analyses the files depending on it instead of failing the run.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Key built by this class. |
Returns
string: Value compared with the one recorded by the previous analysis.
keyFromResultCache()
Section titled “keyFromResultCache() ”public function keyFromResultCache(string $storedKey): stringReturns the key unchanged, since keys hold ids and class names rather than file paths.
Parameters
| Parameter | Type | Description |
|---|---|---|
$storedKey | string |
Returns
string
keyToResultCache()
Section titled “keyToResultCache() ”public function keyToResultCache(string $key): stringReturns the key unchanged, since keys hold ids and class names rather than file paths.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
Returns
string
serviceKey()
Section titled “serviceKey() ”public static function serviceKey(string $id): stringReturns the key for the DI container definition or singleton with the given id.
Parameters
| Parameter | Type | Description |
|---|---|---|
$id | string | Service id. |
Returns
string