mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 09:48:39 +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');
|
self::writeHeader('CONFIG CLASSES');
|
||||||
foreach (PhabricatorEnv::getRequiredClasses() as $key => $class) {
|
foreach (PhabricatorEnv::getRequiredClasses() as $key => $instanceof) {
|
||||||
if (!PhabricatorEnv::getEnvConfig($key)) {
|
$config = PhabricatorEnv::getEnvConfig($key);
|
||||||
|
if (!$config) {
|
||||||
self::writeNote("'$key' is not set.");
|
self::writeNote("'$key' is not set.");
|
||||||
} else {
|
} else {
|
||||||
try {
|
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) {
|
} catch (Exception $ex) {
|
||||||
self::writeFailure();
|
self::writeFailure();
|
||||||
self::write("Setup failure! ".$ex->getMessage());
|
self::write("Setup failure! ".$ex->getMessage());
|
||||||
|
|
Loading…
Add table
Reference in a new issue