mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Test if model class is instanciable
to handle abstract classes, interfaces...
This commit is contained in:
@@ -141,7 +141,12 @@ class ModelsCommand extends Command {
|
|||||||
$this->properties = array();
|
$this->properties = array();
|
||||||
$this->methods = array();
|
$this->methods = array();
|
||||||
if(class_exists($name)){
|
if(class_exists($name)){
|
||||||
try{
|
// handle abstract classes, interfaces, ...
|
||||||
|
$reflectionClass = new \ReflectionClass($name);
|
||||||
|
if (!$reflectionClass->IsInstantiable()) {
|
||||||
|
throw new \Exception($name . ' is not instanciable.');
|
||||||
|
}
|
||||||
|
|
||||||
$model = new $name();
|
$model = new $name();
|
||||||
$this->getPropertiesFromTable($model);
|
$this->getPropertiesFromTable($model);
|
||||||
$this->getPropertiesFromMethods($model);
|
$this->getPropertiesFromMethods($model);
|
||||||
|
|||||||
Reference in New Issue
Block a user