65 $coreVersion, $phpVersion, array $phpExtensions,
66 array $abilities = [], array $abilityErrors = []
68 $this->versionParser =
new VersionParser();
69 $this->setCoreVersion( $coreVersion );
70 $this->setPhpVersion( $phpVersion );
71 $this->phpExtensions = $phpExtensions;
72 $this->abilities = $abilities;
73 $this->abilityErrors = $abilityErrors;
148 foreach ( $extDependencies as $extension => $dependencies ) {
149 foreach ( $dependencies as $dependencyType => $values ) {
150 switch ( $dependencyType ) {
152 $mwError = $this->handleDependency(
156 if ( $mwError !==
false ) {
159 "{$extension} is not compatible with the current MediaWiki "
160 .
"core (version {$this->coreVersion->getPrettyString()}), "
161 .
"it requires: $values.",
162 'type' =>
'incompatible-core',
167 foreach ( $values as $dependency => $constraint ) {
168 if ( $dependency ===
'php' ) {
170 $phpError = $this->handleDependency(
174 if ( $phpError !==
false ) {
177 "{$extension} is not compatible with the current PHP "
178 .
"version {$this->phpVersion->getPrettyString()}), "
179 .
"it requires: $constraint.",
180 'type' =>
'incompatible-php',
183 } elseif ( str_starts_with( $dependency,
'ext-' ) ) {
185 $phpExtension = substr( $dependency, 4 );
186 if ( $constraint !==
'*' ) {
187 throw new UnexpectedValueException(
'Version constraints for '
188 .
'PHP extensions are not supported in ' . $extension );
190 if ( !in_array( $phpExtension, $this->phpExtensions,
true ) ) {
193 "{$extension} requires {$phpExtension} PHP extension "
194 .
"to be installed.",
195 'type' =>
'missing-phpExtension',
196 'missing' => $phpExtension,
199 } elseif ( str_starts_with( $dependency,
'ability-' ) ) {
201 $ability = substr( $dependency, 8 );
202 if ( !isset( $this->abilities[$ability] ) ) {
203 throw new UnexpectedValueException(
'Dependency type '
204 . $dependency .
' unknown in ' . $extension );
206 if ( !is_bool( $constraint ) ) {
207 throw new UnexpectedValueException(
'Only booleans are '
208 .
'allowed to to indicate the presence of abilities '
209 .
'in ' . $extension );
213 $this->abilities[$ability] !==
true
217 if ( isset( $this->abilityErrors[$ability] ) ) {
218 $customMessage =
': ' . $this->abilityErrors[$ability];
223 "{$extension} requires \"{$ability}\" ability"
225 'type' =>
'missing-ability',
226 'missing' => $ability,
231 throw new UnexpectedValueException(
'Dependency type ' . $dependency .
232 ' unknown in ' . $extension );
238 foreach ( $values as $dependency => $constraint ) {
239 $extError = $this->handleExtensionDependency(
240 $dependency, $constraint, $extension, $dependencyType
242 if ( $extError !==
false ) {
243 $errors[] = $extError;
248 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
249 ' unknown in ' . $extension );
291 private function handleExtensionDependency( $dependencyName, $constraint, $checkedExt,