From f8c6ec95f6fad2f406ec70d6748945dd6de0f218 Mon Sep 17 00:00:00 2001 From: Andrew Ellis Date: Fri, 19 Aug 2016 12:20:34 -0600 Subject: [PATCH 1/5] allow a user to define the type overrides --- config/ide-helper.php | 19 ++++++++++++++++--- src/Console/ModelsCommand.php | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/config/ide-helper.php b/config/ide-helper.php index e575923..5c567da 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -1,4 +1,4 @@ - 'Monolog\Logger::addEmergency', ) ), - + /* |-------------------------------------------------------------------------- | Interface implementations @@ -81,7 +81,7 @@ return array( | are detected by the helpers, others can be listed below. | */ - + 'interfaces' => array( ), @@ -142,4 +142,17 @@ return array( */ 'model_camel_case_properties' => false, + /* + |-------------------------------------------------------------------------- + | Property Casts + |-------------------------------------------------------------------------- + | + | Cast the given "real type" to the given "type". + | + */ + 'type_overrides' => array( + // 'integer' => 'int', + // 'boolean' => 'bool', + ) + ); diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index d1324fc..6b47d5b 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -279,11 +279,24 @@ class ModelsCommand extends Command if (!isset($this->properties[$name])) { continue; } else { - $this->properties[$name]['type'] = $realType; + $this->properties[$name]['type'] = $this->getTypeOverride($realType); } } } + /** + * Returns the overide type for the give type. + * + * @param string $type + * @return string + */ + protected function getTypeOverride($type) + { + $typeOverrides = $this->laravel['config']->get('ide-helper.type_overrides', array()); + + return isset($typeOverrides[$type]) ? $typeOverrides[$type] : $type; + } + /** * Load the properties from the database table. * From e938cd3a31072bdc09e9a106eb5fe8dc5ecba6d0 Mon Sep 17 00:00:00 2001 From: Andrew Ellis Date: Fri, 19 Aug 2016 12:25:22 -0600 Subject: [PATCH 2/5] added missing comma --- config/ide-helper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/ide-helper.php b/config/ide-helper.php index 5c567da..e60a909 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -153,6 +153,5 @@ return array( 'type_overrides' => array( // 'integer' => 'int', // 'boolean' => 'bool', - ) - + ), ); From f3a3533b2dfcdb49e4eeb4e7591a3a580a780f22 Mon Sep 17 00:00:00 2001 From: Andrew Ellis Date: Fri, 19 Aug 2016 12:37:17 -0600 Subject: [PATCH 3/5] fixed blank line errors for travis-ci build --- src/Console/ModelsCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 6b47d5b..1cb817f 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -212,7 +212,6 @@ class ModelsCommand extends Command } return $output; - } From ad800d197f27e8d81749e118468131c21fc4a8a9 Mon Sep 17 00:00:00 2001 From: Andrew Ellis Date: Fri, 19 Aug 2016 12:39:16 -0600 Subject: [PATCH 4/5] and one more blank line fix for travis-ci --- src/Generator.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index c403e24..693f682 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -118,7 +118,7 @@ class Generator { $defaultUserModel = config('auth.providers.users.model', config('auth.model', 'App\User')); $this->interfaces['\Illuminate\Contracts\Auth\Authenticatable'] = $defaultUserModel; - + try { if (class_exists('Auth') && is_a('Auth', '\Illuminate\Support\Facades\Auth', true)) { if (class_exists('\Illuminate\Foundation\Application')) { @@ -182,7 +182,6 @@ class Generator } } catch (\Exception $e) { } - } /** @@ -200,7 +199,7 @@ class Generator if ($facade == 'Illuminate\Support\Facades\Redis' && !class_exists('Predis\Client')) { continue; } - + $magicMethods = array_key_exists($name, $this->magic) ? $this->magic[$name] : array(); $alias = new Alias($name, $facade, $magicMethods, $this->interfaces); if ($alias->isValid()) { @@ -246,7 +245,7 @@ class Generator 'Storage' => 'Illuminate\Support\Facades\Storage', //'Validator' => 'Illuminate\Support\Facades\Validator', ]; - + $facades = array_merge($facades, $this->config->get('app.aliases', [])); // Only return the ones that actually exist From b75f879383e3f28f31b91bab0b30efd9e5840a8a Mon Sep 17 00:00:00 2001 From: Andrew Ellis Date: Wed, 24 Aug 2016 14:23:02 -0600 Subject: [PATCH 5/5] uncommented defaults --- config/ide-helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/ide-helper.php b/config/ide-helper.php index e60a909..24a6e28 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -151,7 +151,7 @@ return array( | */ 'type_overrides' => array( - // 'integer' => 'int', - // 'boolean' => 'bool', + 'integer' => 'int', + 'boolean' => 'bool', ), );