76 $coreVersion, $phpVersion, array $phpExtensions,
77 array $abilities = [], array $abilityErrors = []
79 $this->versionParser =
new VersionParser();
80 $this->setCoreVersion( $coreVersion );
81 $this->setPhpVersion( $phpVersion );
82 $this->phpExtensions = $phpExtensions;
83 $this->abilities = $abilities;
84 $this->abilityErrors = $abilityErrors;
156 foreach ( $extDependencies as $extension => $dependencies ) {
157 foreach ( $dependencies as $dependencyType => $values ) {
158 switch ( $dependencyType ) {
159 case ExtensionRegistry::MEDIAWIKI_CORE:
160 $mwError = $this->handleDependency(
165 if ( $mwError !==
false ) {
168 "{$extension} is not compatible with the current MediaWiki "
169 .
"core (version {$this->coreVersion->getPrettyString()}), "
170 .
"it requires: $values."
172 'type' =>
'incompatible-core',
177 foreach ( $values as $dependency => $constraint ) {
178 if ( $dependency ===
'php' ) {
180 $phpError = $this->handleDependency(
185 if ( $phpError !==
false ) {
188 "{$extension} is not compatible with the current PHP "
189 .
"version {$this->phpVersion->getPrettyString()}), "
190 .
"it requires: $constraint."
192 'type' =>
'incompatible-php',
195 } elseif ( substr( $dependency, 0, 4 ) ===
'ext-' ) {
197 $phpExtension = substr( $dependency, 4 );
198 if ( $constraint !==
'*' ) {
199 throw new UnexpectedValueException(
'Version constraints for '
200 .
'PHP extensions are not supported in ' . $extension );
202 if ( !in_array( $phpExtension, $this->phpExtensions,
true ) ) {
205 "{$extension} requires {$phpExtension} PHP extension "
208 'type' =>
'missing-phpExtension',
209 'missing' => $phpExtension,
212 } elseif ( substr( $dependency, 0, 8 ) ===
'ability-' ) {
214 $ability = substr( $dependency, 8 );
215 if ( !isset( $this->abilities[$ability] ) ) {
216 throw new UnexpectedValueException(
'Dependency type '
217 . $dependency .
' unknown in ' . $extension );
219 if ( !is_bool( $constraint ) ) {
220 throw new UnexpectedValueException(
'Only booleans are '
221 .
'allowed to to indicate the presence of abilities '
222 .
'in ' . $extension );
226 $this->abilities[$ability] !==
true
230 if ( isset( $this->abilityErrors[$ability] ) ) {
231 $customMessage =
': ' . $this->abilityErrors[$ability];
236 "{$extension} requires \"{$ability}\" ability"
239 'type' =>
'missing-ability',
240 'missing' => $ability,
245 throw new UnexpectedValueException(
'Dependency type ' . $dependency .
246 ' unknown in ' . $extension );
252 foreach ( $values as $dependency => $constraint ) {
253 $extError = $this->handleExtensionDependency(
254 $dependency, $constraint, $extension, $dependencyType
256 if ( $extError !==
false ) {
257 $errors[] = $extError;
262 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
263 ' unknown in ' . $extension );
304 private function handleExtensionDependency( $dependencyName, $constraint, $checkedExt,