diff --git a/.gitignore b/.gitignore index d5a5bd7..263233c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ /build +composer.lock diff --git a/src/Mage/MageApplication.php b/src/Mage/MageApplication.php index 13ae34a..fc99b3b 100644 --- a/src/Mage/MageApplication.php +++ b/src/Mage/MageApplication.php @@ -21,6 +21,7 @@ use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Application; use Symfony\Component\Yaml\Yaml; +use ReflectionClass; use Mage\Runtime\Exception\RuntimeException; /** @@ -96,11 +97,13 @@ class MageApplication extends Application foreach ($finder as $file) { $class = substr('\\Mage\\Command\\BuiltIn\\' . str_replace('/', '\\', $file->getRelativePathname()), 0, -4); if (class_exists($class)) { - $command = new $class(); - - if ($command instanceof AbstractCommand) { - $command->setRuntime($this->runtime); - $this->add($command); + $reflex = new ReflectionClass($class); + if ($reflex->isInstantiable()) { + $command = new $class(); + if ($command instanceof AbstractCommand) { + $command->setRuntime($this->runtime); + $this->add($command); + } } } } diff --git a/src/Mage/Task/TaskFactory.php b/src/Mage/Task/TaskFactory.php index d1d7af4..a459b31 100644 --- a/src/Mage/Task/TaskFactory.php +++ b/src/Mage/Task/TaskFactory.php @@ -14,6 +14,7 @@ use Mage\Runtime\Runtime; use Mage\Runtime\Exception\RuntimeException; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; +use ReflectionClass; /** * Task Factory @@ -78,11 +79,14 @@ class TaskFactory $task->setOptions($options); return $task; } elseif (class_exists($name)) { - $task = new $name(); - if ($task instanceof AbstractTask) { - $task->setOptions($options); - $this->add($task); - return $task; + $reflex = new ReflectionClass($name); + if ($reflex->isInstantiable()) { + $task = new $name(); + if ($task instanceof AbstractTask) { + $task->setOptions($options); + $this->add($task); + return $task; + } } } @@ -101,10 +105,12 @@ class TaskFactory foreach ($finder as $file) { $class = substr('\\Mage\\Task\\BuiltIn\\' . str_replace('/', '\\', $file->getRelativePathname()), 0, -4); if (class_exists($class)) { - $task = new $class(); - - if ($task instanceof AbstractTask) { - $this->add($task); + $reflex = new ReflectionClass($class); + if ($reflex->isInstantiable()) { + $task = new $class(); + if ($task instanceof AbstractTask) { + $this->add($task); + } } } }