+ } elseif ( substr( $dependency, 0, 4 ) === 'ext-' ) {
+ // PHP extensions
+ $phpExtension = substr( $dependency, 4 );
+ if ( $constraint !== '*' ) {
+ throw new UnexpectedValueException( 'Version constraints for '
+ . 'PHP extensions are not supported in ' . $extension );
+ }
+ if ( !in_array( $phpExtension, $this->phpExtensions, true ) ) {
+ $errors[] = [
+ 'msg' =>
+ "{$extension} requires {$phpExtension} PHP extension "
+ . "to be installed."
+ ,
+ 'type' => 'missing-phpExtension',
+ 'missing' => $phpExtension,
+ ];
+ }
+ } elseif ( substr( $dependency, 0, 8 ) === 'ability-' ) {
+ // Other abilities the environment might provide.
+ $ability = substr( $dependency, 8 );
+ if ( !isset( $this->abilities[$ability] ) ) {
+ throw new UnexpectedValueException( 'Dependency type '
+ . $dependency . ' unknown in ' . $extension );
+ }
+ if ( !is_bool( $constraint ) ) {
+ throw new UnexpectedValueException( 'Only booleans are '
+ . 'allowed to to indicate the presence of abilities '
+ . 'in ' . $extension );
+ }
+
+ if ( $constraint === true &&
+ $this->abilities[$ability] !== true
+ ) {
+ // add custom error message for missing ability if specified
+ $customMessage = '';
+ if ( isset( $this->abilityErrors[$ability] ) ) {
+ $customMessage = ': ' . $this->abilityErrors[$ability];
+ }
+
+ $errors[] = [
+ 'msg' =>
+ "{$extension} requires \"{$ability}\" ability"
+ . $customMessage
+ ,
+ 'type' => 'missing-ability',
+ 'missing' => $ability,
+ ];
+ }