From 430c5d7db4dff117fe6d444df68775d9317ff8ac Mon Sep 17 00:00:00 2001 From: TANT Julien Date: Mon, 16 Dec 2013 22:38:06 +0100 Subject: [PATCH 1/2] Test if model class is instanciable to handle abstract classes, interfaces... --- src/Barryvdh/LaravelIdeHelper/ModelsCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php index 6063758..eacc336 100644 --- a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php +++ b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php @@ -141,7 +141,12 @@ class ModelsCommand extends Command { $this->properties = array(); $this->methods = array(); 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(); $this->getPropertiesFromTable($model); $this->getPropertiesFromMethods($model); From 7ee52d7e61a57237e0d2e21eefd6b6e0ddfe285d Mon Sep 17 00:00:00 2001 From: TANT Julien Date: Tue, 17 Dec 2013 11:53:02 +0100 Subject: [PATCH 2/2] restore the try { statement --- src/Barryvdh/LaravelIdeHelper/ModelsCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php index eacc336..3e728db 100644 --- a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php +++ b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php @@ -141,6 +141,7 @@ class ModelsCommand extends Command { $this->properties = array(); $this->methods = array(); if(class_exists($name)){ + try { // handle abstract classes, interfaces, ... $reflectionClass = new \ReflectionClass($name); if (!$reflectionClass->IsInstantiable()) {