Skip to content
docsv0.8.0

CapabilitySuggestion

A `suggests` capability record — an OPTIONAL dependency. A missing suggested capability MUST NOT fail boot; `fallback` names the graceful-degradation path (e.g. "noop" / a null-object strategy). Legacy bare-FQCN declarations are accepted via {@see fromInterface()}. The primary constructor validates exactly like {@see fromArray()} does: `id` and `interface` must be non-empty. There is no "trusted, pre-validated" construction path — hand-building a record is validated identically to parsing one from a manifest.

CapabilitySuggestion::__construct()

public function __construct(string $id, string $interface, string $constraint = '*', ?string $fallback = null):

Parameters

Parameters of __construct()
NameTypeDescription
$idstring
$interfacestring
$constraintstring
$fallback?string

Throws

\InvalidArgumentException If `id` or `interface` is empty.

CapabilitySuggestion::fromArray()

public static function fromArray(array $record): self

Build a suggestion record from a decoded `suggests` manifest entry. Coerces raw (possibly untyped) array values to their expected shape — defaulting `constraint` to `*` and normalizing an empty `fallback` to null; validation of the result (`id`/`interface` non-empty) happens in the constructor, not here.

Parameters

Parameters of fromArray()
NameTypeDescription
$recordarray<string, mixed>

Throws

\InvalidArgumentException If `id` or `interface` is empty.

CapabilitySuggestion::fromInterface()

public static function fromInterface(string $interface): self

Wrap a legacy bare-FQCN declaration as an any-version suggestion.

Parameters

Parameters of fromInterface()
NameTypeDescription
$interfacestring

CapabilitySuggestion::parse()

public static function parse(array|string $record): self

Parse a `suggests` manifest entry in either the legacy bare-FQCN string form or the structured-record array form, dispatching to {@see fromInterface()} or {@see fromArray()}.

Parameters

Parameters of parse()
NameTypeDescription
$record(string | array<string, mixed>)