CapabilityRequirement
A `requires` capability record. Declares a HARD dependency on a contract: at least one installed provider must satisfy `interface` within the semver `constraint` range. `oneOf` optionally lists provider capability ids any of which satisfies the requirement. 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.
CapabilityRequirement::__construct()
public function __construct(string $id, string $interface, string $constraint = '*', array $oneOf = []):Parameters
| Name | Type | Description |
|---|---|---|
| $id | string | |
| $interface | string | |
| $constraint | string | |
| $oneOf | list<string> |
Throws
\InvalidArgumentException If `id` or `interface` is empty.
CapabilityRequirement::fromArray()
public static function fromArray(array $record): selfBuild a requirement record from a decoded `requires` manifest entry. Coerces raw (possibly untyped) array values to their expected shape — defaulting `constraint` to `*` and normalizing `oneOf` to a list of non-empty strings; validation of the result (`id`/`interface` non-empty) happens in the constructor, not here.
Parameters
| Name | Type | Description |
|---|---|---|
| $record | array<string, mixed> |
Throws
\InvalidArgumentException If `id` or `interface` is empty.
CapabilityRequirement::fromInterface()
public static function fromInterface(string $interface): selfWrap a legacy bare-FQCN declaration as an any-version requirement.
Parameters
| Name | Type | Description |
|---|---|---|
| $interface | string |
CapabilityRequirement::parse()
public static function parse(array|string $record): selfParse a `requires` manifest entry in either the legacy bare-FQCN string form or the structured-record array form, dispatching to {@see fromInterface()} or {@see fromArray()}.
Parameters
| Name | Type | Description |
|---|---|---|
| $record | (string | array<string, mixed>) |