-
-
Notifications
You must be signed in to change notification settings - Fork 0
ComposerJsonInterface
Defines the contract for reading and exposing normalized metadata from a
Composer composer.json file.
This interface provides convenient accessors for commonly used package metadata, including identification, descriptive attributes, licensing, authorship, support channels, funding declarations, autoload mappings, configuration entries, scripts, and additional package-specific sections.
Implementations of this interface MUST read data from a Composer-compatible source and SHALL expose that data through stable, predictable, typed accessors. When a given field is optional in Composer metadata and not declared by the package, implementations SHOULD return an appropriate empty value, nullable value, or default representation as described by each method contract.
Returned values SHOULD preserve the semantic meaning of the underlying
composer.json document. Implementations MAY normalize values for
interoperability and developer convenience, provided that such normalization
does not materially alter the intended meaning of the original metadata.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this interface are to be interpreted as described in RFC 2119.
- Full name:
\FastForward\DevTools\Composer\Json\ComposerJsonInterface
Returns the package name declared in the Composer file.
public getName(): stringThe package name SHOULD follow the conventional Composer vendor/package notation when defined. Implementations MAY return an empty string when the name field is absent or cannot be resolved.
Return Value:
the package name, or an empty string when undefined
Returns the package description declared in the Composer file.
public getDescription(): stringImplementations SHOULD return a human-readable summary of the package purpose. When the description field is not defined, an empty string SHOULD be returned.
Return Value:
the package description, or an empty string when undefined
Returns the package version declared in the Composer file.
public getVersion(): stringImplementations SHOULD return the version string exactly as declared or as normalized by the underlying Composer metadata source. When no version is explicitly declared, implementations MAY return an empty string.
Return Value:
the package version, or an empty string when undefined
Returns the package type declared in the Composer file.
public getType(): stringThis value typically identifies how Composer or consuming tools SHOULD
interpret the package, such as library, project, or another valid
Composer package type. Implementations MAY return an empty string when
the type field is absent.
Return Value:
the package type, or an empty string when undefined
Returns the package keywords declared in the Composer file.
public getKeywords(): array<int,string>Keywords SHOULD be returned in declaration order whenever practical. When the package does not define any keywords, implementations SHOULD return an empty array.
Return Value:
the package keywords, or an empty array when undefined
Returns the package homepage URL declared in the Composer file.
public getHomepage(): stringImplementations SHOULD return a fully qualified URL when one is available. When the homepage field is not defined, an empty string SHOULD be returned.
Return Value:
the homepage URL, or an empty string when undefined
Returns the readme path or readme reference declared in the Composer file.
public getReadme(): stringImplementations SHOULD return the value exactly as represented by the underlying metadata source whenever possible. When the readme field is absent, an empty string SHOULD be returned.
Return Value:
the readme value, or an empty string when undefined
Returns the package time metadata as an immutable date-time instance.
public getTime(): \DateTimeImmutable|nullThis value SHOULD represent the package release or metadata timestamp associated with the Composer file. Implementations MUST return a DateTimeImmutable instance.
Return Value:
the package time metadata as an immutable date-time value
Returns the package license when it can be resolved to a single value.
public getLicense(): string|nullIf the underlying Composer metadata contains a single license identifier, this method SHOULD return that identifier. If the metadata contains no license or multiple license values that cannot be reduced to a single unambiguous result, this method MUST return null.
Return Value:
the resolved license identifier, or null when no single license value can be determined
Returns the package authors declared in the Composer file.
public getAuthors(bool $onlyFirstAuthor = false): \FastForward\DevTools\Composer\Json\Schema\AuthorInterface|iterable<int,\FastForward\DevTools\Composer\Json\Schema\AuthorInterface>Implementations SHOULD preserve declaration order whenever practical.
When $onlyFirstAuthor is set to true, this method MUST return the first
declared author. If no author is declared, the implementation SHOULD handle
that condition consistently with its contract and MUST NOT silently return an
invalid author representation.
When $onlyFirstAuthor is set to false, this method MUST return all
declared authors as an iterable. If the Composer file does not declare any
authors, an empty iterable MUST be returned.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$onlyFirstAuthor |
bool | determines whether only the first declared |
| author SHALL be returned instead of the full | ||
| author list |
Return Value:
the first declared
author when
$onlyFirstAuthor
is true, or the full
authors list when
$onlyFirstAuthor
is false
Returns the support metadata declared in the Composer file.
public getSupport(): \FastForward\DevTools\Composer\Json\Schema\SupportInterfaceImplementations MUST return an object implementing SupportInterface. When the support section is absent, the returned object SHOULD represent an empty support definition rather than causing failure.
Return Value:
the support metadata object
Returns the funding entries declared in the Composer file.
public getFunding(): array<int,mixed>Each returned element SHOULD represent a single funding definition from
the optional Composer funding section. When no funding entries are
declared, implementations SHOULD return an empty array.
Return Value:
the funding entries, or an empty array when undefined
Returns the autoload configuration for the requested autoload type.
public getAutoload(string|null $type = null): array<string,mixed>The requested type typically refers to an autoload mapping section such as
psr-4, psr-0, classmap, or files. When no type is provided,
implementations SHOULD use the default Composer autoload type expected by
the implementation, which is commonly psr-4.
If the requested autoload type does not exist, implementations SHOULD return an empty array.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$type |
string|null | The autoload mapping type to retrieve. This |
defaults to psr-4 when null. |
Return Value:
the autoload configuration for the requested type, or an empty array when unavailable
Returns the development autoload configuration for the requested type.
public getAutoloadDev(string|null $type = null): array<string,mixed>The requested type typically refers to an autoload-dev mapping section
such as psr-4, psr-0, classmap, or files. When no type is
provided, implementations SHOULD use the default autoload-dev type
expected by the implementation, which is commonly psr-4.
If the requested development autoload type does not exist, implementations SHOULD return an empty array.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$type |
string|null | The development autoload mapping type to |
retrieve. This defaults to psr-4 when null. |
Return Value:
the autoload-dev configuration for the requested type, or an empty array when unavailable
Returns the minimum stability declared in the Composer file.
public getMinimumStability(): stringImplementations SHOULD return the configured Composer minimum stability
value, such as stable, RC, beta, alpha, or dev. When the field
is not explicitly defined, implementations MAY return an empty string or
a normalized default value according to implementation policy.
Return Value:
the minimum stability value
Returns configuration data from the Composer config section.
public getConfig(string|null $config): array<string,mixed>|stringWhen a specific configuration key is provided, implementations SHOULD resolve and return the matching configuration value whenever possible. When the key is null, implementations MAY return the complete configuration structure. The returned value MAY therefore be either an array or a scalar string according to the accessed configuration entry.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$config |
string|null | the configuration key to retrieve, or null to |
| retrieve the complete config section |
Return Value:
the requested config value or the full config structure, depending on the requested key
Returns the scripts declared in the Composer file.
public getScripts(): array<string,mixed>Implementations SHOULD return the Composer scripts section as a
structured array. When no scripts are declared, an empty array SHOULD
be returned.
Return Value:
the Composer scripts configuration
Returns the extra configuration section declared in the Composer file.
public getExtra(string|null $extra = null): array<string,mixed>When a specific extra key is provided, implementations SHOULD return the matching extra configuration subset when available. When the key is null, implementations SHOULD return the complete extra section. If the section or requested key is not defined, an empty array SHOULD be returned.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$extra |
string|null | the extra configuration key to retrieve, or |
| null to retrieve the complete extra section |
Return Value:
the extra configuration data, or an empty array when undefined
Returns the executable binary declarations from the Composer file.
public getBin(): string|array<int,string>Composer bin entries MAY be declared as a single string or as a list of
strings. Implementations MUST therefore return either a string or an
array, preserving the semantic shape expected by the consumer.
Return Value:
the declared binary path or paths
Returns the package suggestions declared in the Composer file.
public getSuggest(): array<string,string>The returned array SHOULD represent the Composer suggest section, where
keys typically correspond to package names and values describe why the
suggested package may be useful. When no suggestions are declared,
implementations SHOULD return an empty array.
Return Value:
the package suggestion map
Returns comment metadata associated with the Composer file.
public getComments(): array<int|string,mixed>This method SHOULD expose any parsed or implementation-specific comment data that is associated with the source Composer document. When no such comments are available, implementations SHOULD return an empty array.
Return Value:
the comment metadata, or an empty array when unavailable