wiki.techinc.nl/includes/registration/ExtensionDependencyError.php
Daimona Eaytoy bd5b6f98ba Fix new phan errors, part 3
These are almost only doc changes, with two exceptions:
1-In LinkHolderArray, int-alike array keys are now cast to int, to be uniform with what we do in other code paths
2-In ExtensionRegistration, changed a line to throw an Exception
immediately, instead of an ExtensionDependencyError. This is because the
latter takes an array with msg and type, but we were passing it a plain
string (and in fact the code was bugged).

Bug: T231636
Change-Id: I8b0ef50d279c2a87490dde6a467a4e22c0710afd
2019-10-12 10:35:22 +00:00

105 lines
2.4 KiB
PHP

<?php
/**
* Copyright (C) 2018 Kunal Mehta <legoktm@member.fsf.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
/**
* @since 1.31
*/
class ExtensionDependencyError extends Exception {
/**
* @var string[]
*/
public $missingExtensions = [];
/**
* @var string[]
*/
public $missingSkins = [];
/**
* @var string[]
*/
public $incompatibleExtensions = [];
/**
* @var string[]
*/
public $incompatibleSkins = [];
/**
* @var bool
*/
public $incompatibleCore = false;
/**
* @var bool
*/
public $incompatiblePhp = false;
/**
* @var string[]
*/
public $missingPhpExtensions = [];
/**
* @var string[]
*/
public $missingAbilities = [];
/**
* @param array[] $errors Each error has a 'msg' and 'type' key at minimum
*/
public function __construct( array $errors ) {
$msg = '';
foreach ( $errors as $info ) {
$msg .= $info['msg'] . "\n";
switch ( $info['type'] ) {
case 'incompatible-core':
$this->incompatibleCore = true;
break;
case 'incompatible-php':
$this->incompatiblePhp = true;
break;
case 'missing-phpExtension':
$this->missingPhpExtensions[] = $info['missing'];
break;
case 'missing-ability':
$this->missingAbilities[] = $info['missing'];
break;
case 'missing-skins':
$this->missingSkins[] = $info['missing'];
break;
case 'missing-extensions':
$this->missingExtensions[] = $info['missing'];
break;
case 'incompatible-skins':
$this->incompatibleSkins[] = $info['incompatible'];
break;
case 'incompatible-extensions':
$this->incompatibleExtensions[] = $info['incompatible'];
break;
// default: continue
}
}
parent::__construct( $msg );
}
}