ExpectedState
API reference › Scaffold › Scaffold › ExpectedState
Represents the file mappings that the allowed and installed providers ship now, merged with the rule of
ScaffoldRunner.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$warnings readonly constructor | list<string> | Messages about provider roots and manifests, prefixed with [scaffold]. Default: []. | ExpectedState |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates an expected state from merged mappings and provider diagnostics. | ExpectedState |
all() | Returns every expected mapping keyed by destination, in allowed-packages and manifest order. | ExpectedState |
build() static | Loads the manifests of every allowed and installed provider, in allowed-packages order. | ExpectedState |
failedProviders() | Returns the allowed and installed providers whose manifest could not be loaded. | ExpectedState |
hasFailed() | Returns whether the manifest of $provider could not be loaded. | ExpectedState |
mapping() | Returns the expected mapping of $destination, or null when no allowed and installed provider ships it. | ExpectedState |
orphanReport() | Returns the stderr lines that announce the orphans of $files: a header with the count and the prune hint, at most ten destinations with their provider, and the number of the others. | ExpectedState |
orphans() | Returns the lock entries that no allowed and installed provider ships anymore; ejected entries and entries of a provider whose manifest could not be loaded are never orphans. | ExpectedState |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(array<array-key, PHPForge\Scaffold\Manifest\FileMapping> $mappings, list<string> $failedProviders = [], list<string> $warnings = [])Creates an expected state from merged mappings and provider diagnostics.
Parameters
| Parameter | Type | Description |
|---|---|---|
$mappings | array<array-key, PHPForge\> | Expected mappings keyed by destination. |
$failedProviders | list<string> | Allowed and installed providers whose manifest could not be loaded. |
$warnings | list<string> | Messages about provider roots and manifests, prefixed with [scaffold]. |
all()
Section titled “all() ”public function all(): array<array-key, PHPForge\Scaffold\Manifest\FileMapping>Returns every expected mapping keyed by destination, in allowed-packages and manifest order.
Returns
array<array-key, PHPForge\Scaffold\Manifest\FileMapping>: Mappings keyed by destination; integer-like destinations ("123") are integer keys.
build()
Section titled “build() ”public static function build(PHPForge\Scaffold\Config\ProjectContext $context, array<string, mixed> $lockProviders, PHPForge\Scaffold\Manifest\ManifestLoader $loader = new \PHPForge\Scaffold\Manifest\ManifestLoader(new \PHPForge\Scaffold\Manifest\ManifestSchema(), new \PHPForge\Scaffold\Manifest\ManifestExpander())): selfLoads the manifests of every allowed and installed provider, in allowed-packages order.
Parameters
| Parameter | Type | Description |
|---|---|---|
$context | PHPForge\ | Project whose providers are loaded. |
$lockProviders | array<string, | providers map of scaffold-lock.json, used for recorded paths. |
$loader | PHPForge\ | Loads the provider manifests into file mappings. |
Returns
self: Merged mappings, the providers whose manifest failed to load, and their warnings.
failedProviders()
Section titled “failedProviders() ”public function failedProviders(): list<string>Returns the allowed and installed providers whose manifest could not be loaded.
Returns
list<string>: Provider names in allowed-packages order.
hasFailed()
Section titled “hasFailed() ”public function hasFailed(string $provider): boolReturns whether the manifest of $provider could not be loaded.
Parameters
| Parameter | Type | Description |
|---|---|---|
$provider | string | Provider package name. |
Returns
bool: true when the provider manifest failed to load, false otherwise.
mapping()
Section titled “mapping() ”public function mapping(string $destination): PHPForge\Scaffold\Manifest\FileMapping|nullReturns the expected mapping of $destination, or null when no allowed and installed provider ships it.
Parameters
| Parameter | Type | Description |
|---|---|---|
$destination | string | Destination path relative to the project root. |
Returns
PHPForge\Scaffold\Manifest\FileMapping|null: Expected mapping, or null when no allowed and installed provider ships it.
orphanReport()
Section titled “orphanReport() ”public function orphanReport(array<array-key, array<array-key, mixed>> $files): list<string>Returns the stderr lines that announce the orphans of $files: a header with the count and the prune hint,
at most ten destinations with their provider, and the number of the others.
Parameters
| Parameter | Type | Description |
|---|---|---|
$files | array<array-key, | files map of scaffold-lock.json. |
Returns
list<string>: Lines prefixed with [scaffold]; empty when there is no orphan.
orphans()
Section titled “orphans() ”public function orphans(array<array-key, PHPForge\Scaffold\Scaffold\TEntry> $files): array<array-key, PHPForge\Scaffold\Scaffold\TEntry>Returns the lock entries that no allowed and installed provider ships anymore; ejected entries and entries of a provider whose manifest could not be loaded are never orphans.
Parameters
| Parameter | Type | Description |
|---|---|---|
$files | array<array-key, | files map of scaffold-lock.json. |
Returns
array<array-key, PHPForge\Scaffold\Scaffold\TEntry>: Orphan entries keyed by destination, in lock order; integer-like destinations ("123") are integer keys.