Skip to content
PHP Ecosystem
Explore

ExpectedState

API reference › Scaffold › Scaffold › ExpectedState

final readonly classPHPForge\Scaffold\Scaffold\ExpectedState
Sourcesrc/Scaffold/ExpectedState.php

Represents the file mappings that the allowed and installed providers ship now, merged with the rule of ScaffoldRunner.

PropertyTypeDescriptionDefined by
$warnings readonly constructorlist<string>Messages about provider roots and manifests, prefixed with [scaffold]. Default: [].ExpectedState
MethodDescriptionDefined 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() staticLoads 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
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

ParameterTypeDescription
$mappingsarray<array-key, PHPForge\Scaffold\Manifest\FileMapping>Expected mappings keyed by destination.
$failedProviderslist<string>Allowed and installed providers whose manifest could not be loaded.
$warningslist<string>Messages about provider roots and manifests, prefixed with [scaffold].
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.

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())): self

Loads the manifests of every allowed and installed provider, in allowed-packages order.

Parameters

ParameterTypeDescription
$contextPHPForge\Scaffold\Config\ProjectContextProject whose providers are loaded.
$lockProvidersarray<string, mixed>providers map of scaffold-lock.json, used for recorded paths.
$loaderPHPForge\Scaffold\Manifest\ManifestLoaderLoads the provider manifests into file mappings.

Returns

self: Merged mappings, the providers whose manifest failed to load, and their warnings.

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.

public function hasFailed(string $provider): bool

Returns whether the manifest of $provider could not be loaded.

Parameters

ParameterTypeDescription
$providerstringProvider package name.

Returns

bool: true when the provider manifest failed to load, false otherwise.

public function mapping(string $destination): PHPForge\Scaffold\Manifest\FileMapping|null

Returns the expected mapping of $destination, or null when no allowed and installed provider ships it.

Parameters

ParameterTypeDescription
$destinationstringDestination path relative to the project root.

Returns

PHPForge\Scaffold\Manifest\FileMapping|null: Expected mapping, or null when no allowed and installed provider ships it.

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

ParameterTypeDescription
$filesarray<array-key, array<array-key, mixed>>files map of scaffold-lock.json.

Returns

list<string>: Lines prefixed with [scaffold]; empty when there is no orphan.

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

ParameterTypeDescription
$filesarray<array-key, PHPForge\Scaffold\Scaffold\TEntry>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.