mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-27 07:50:57 +01:00
Avoid warning in checking config classes in setup
Summary: Current code emits warning for classes with constructors with parameters. It also creates the objects which is bad if constructors do some actual work. NOTE: http://svn.php.net/viewvc/phpdoc/en/trunk/reference/reflection/reflectionclass/issubclassof.xml?r1=324630&r2=324629 Test Plan: Run setup with: - correct classes - not-existing class - class with private constructor - class not implementing the required class Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D2056
This commit is contained in:
parent
62053a39e3
commit
3c19e5b133
1 changed files with 10 additions and 3 deletions
|
@ -735,12 +735,19 @@ final class PhabricatorSetup {
|
|||
}
|
||||
|
||||
self::writeHeader('CONFIG CLASSES');
|
||||
foreach (PhabricatorEnv::getRequiredClasses() as $key => $class) {
|
||||
if (!PhabricatorEnv::getEnvConfig($key)) {
|
||||
foreach (PhabricatorEnv::getRequiredClasses() as $key => $instanceof) {
|
||||
$config = PhabricatorEnv::getEnvConfig($key);
|
||||
if (!$config) {
|
||||
self::writeNote("'$key' is not set.");
|
||||
} else {
|
||||
try {
|
||||
PhabricatorEnv::newObjectFromConfig($key);
|
||||
$r = new ReflectionClass($config);
|
||||
if (!$r->isSubclassOf($instanceof)) {
|
||||
throw new Exception(
|
||||
"Config setting '$key' must be an instance of '$instanceof'.");
|
||||
} elseif (!$r->isInstantiable()) {
|
||||
throw new Exception("Config setting '$key' must be instantiable.");
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
self::writeFailure();
|
||||
self::write("Setup failure! ".$ex->getMessage());
|
||||
|
|
Loading…
Reference in a new issue