class ConfigSourceResolver

internal  
 

Finds what a booted application loads into its configuration besides its own config files: the framework defaults, the package files providers merge, and the keys that providers and bootstrappers write. ConfigParser composes these into config types.

Provider sources are read from their syntax trees and the booted providers' metadata. No provider or configuration code runs.

Traits

Constants

CONFIG_FILE_PATTERN

The names of the files a config directory loads, as a directory dependency pattern.

private MERGE_METHODS

Whether each merge method replaces recursively, keyed by lowercase name.

private WRITE_METHODS

The repository methods that write a key, keyed by lowercase name, with the name of the parameter holding the key.

private READ_METHODS

The repository methods that only read.

Properties

protected Container|null $container from  HasContainer
bool $returns

Methods

void
setContainer(Container $container)

Set the container used for resolution.

getContainer()

Return the current container.

mixed
resolve(string $abstract)

Resolve the given type from the container.

__construct(FileHelper $fileHelper, Parser $parser, ReflectionProvider $reflectionProvider, array $configuredDirectories, string|null $singleReflectionFile = null, string|null $singleReflectionInsteadOfFile = null)

Create a new resolver instance.

array
getConfigDirectories()

Get the application's config directories, highest priority first.

array
getBootedConfigDirectories()

Get the config directories the booted application loaded, highest priority first.

array
getKeySources(string $key, array $directories)

Get the paths whose contents can change a config key's loaded value, each mapped to whether it is a directory of config files.

array
getAllSources(array $directories)

Get the paths whose contents can change any loaded config value, each mapped to whether it is a directory of config files: the config directories, the framework's config directory and the package files merged into the configuration.

bool
shouldMergeFrameworkConfiguration()

Determine whether the framework's config files are merged beneath the application's.

array
getMergeableOptions(string $name)

Get the named-entry options LoadConfiguration merges for a framework config file.

array
getMerges()

Get the package config files providers merge, in registration order.

array
getWrittenKeys()

Get the config keys that providers and bootstrappers write.

bool
hasUnknownWrites()

Determine whether a provider writes config keys that cannot be found statically.

bool
isConfigFile(string $file)

Determine whether the analyzed file is a config file.

bool
isPackageConfigFile(string $path)

Determine whether the file is a package config file: one that a provider merges, or one that a provider publishes into the config directory.

int|null
enterNode(Node $node)

No description

Details

in HasContainer at line 19
void setContainer(Container $container)

Set the container used for resolution.

Parameters

Container $container

Return Value

void

in HasContainer at line 27
Container getContainer()

Return the current container.

Return Value

Container

in HasContainer at line 35
mixed resolve(string $abstract)

Resolve the given type from the container.

Parameters

string $abstract

Return Value

mixed

at line 165
__construct(FileHelper $fileHelper, Parser $parser, ReflectionProvider $reflectionProvider, array $configuredDirectories, string|null $singleReflectionFile = null, string|null $singleReflectionInsteadOfFile = null)

Create a new resolver instance.

The single reflection files are PHPStan's normalized --tmp-file and --instead-of paths, which are set in editor mode.

Parameters

FileHelper $fileHelper
Parser $parser
ReflectionProvider $reflectionProvider
array $configuredDirectories
string|null $singleReflectionFile
string|null $singleReflectionInsteadOfFile

at line 187
array getConfigDirectories()

Get the application's config directories, highest priority first.

Configured directories replace the booted config path. Testbench's workbench config directory overlays the booted path when its config discovery is on.

Return Value

array

at line 206
array getBootedConfigDirectories()

Get the config directories the booted application loaded, highest priority first.

Testbench's workbench config directory overlays the config path when its config discovery is on.

Return Value

array

at line 237
array getKeySources(string $key, array $directories)

Get the paths whose contents can change a config key's loaded value, each mapped to whether it is a directory of config files.

In each config directory, these are the file of every prefix of the key, existing or not, and the directory below the key, whose files make its value a merged one. Then the framework's file for the key and the package files merged into an overlapping key.

Parameters

string $key
array $directories

the config directories the value loads from

Return Value

array

at line 271
array getAllSources(array $directories)

Get the paths whose contents can change any loaded config value, each mapped to whether it is a directory of config files: the config directories, the framework's config directory and the package files merged into the configuration.

Parameters

array $directories

the config directories the values load from

Return Value

array

at line 291
bool shouldMergeFrameworkConfiguration()

Determine whether the framework's config files are merged beneath the application's.

Return Value

bool

at line 301
array getMergeableOptions(string $name)

Get the named-entry options LoadConfiguration merges for a framework config file.

Parameters

string $name

Return Value

array

at line 316
array getMerges()

Get the package config files providers merge, in registration order.

A merge is definite when every boot runs it; other merges may or may not run. The options are the provider's named-entry options for the key.

Return Value

array

at line 326
array getWrittenKeys()

Get the config keys that providers and bootstrappers write.

Return Value

array

at line 334
bool hasUnknownWrites()

Determine whether a provider writes config keys that cannot be found statically.

Return Value

bool

at line 347
bool isConfigFile(string $file)

Determine whether the analyzed file is a config file.

Besides the application's config directories, the framework's config and config:publish stub directories and package config files are config files: those providers merge, and those they publish into the config directory. In editor mode PHPStan analyzes a temporary file, which stands in for the edited one.

Parameters

string $file

Return Value

bool

at line 375
bool isPackageConfigFile(string $path)

Determine whether the file is a package config file: one that a provider merges, or one that a provider publishes into the config directory.

Parameters

string $path

Return Value

bool

at line 1073
int|null enterNode(Node $node)

No description

Parameters

Node $node

Return Value

int|null