1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +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:
vrana 2012-03-30 04:14:39 -07:00
parent 62053a39e3
commit 3c19e5b133

View file

@ -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());