From 92a3813ee3d1eb67b30d4e1d27f6f076f2598931 Mon Sep 17 00:00:00 2001 From: Florent Denis Date: Thu, 12 Dec 2013 18:36:35 +0100 Subject: [PATCH] Fix bugs php --- Generator/Base.php | 4 ++-- Generator/Module.php | 2 +- drush/module_builder.drush.inc | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Generator/Base.php b/Generator/Base.php index b2b3811..c97c211 100644 --- a/Generator/Base.php +++ b/Generator/Base.php @@ -176,13 +176,13 @@ abstract class BaseGenerator { * module human name based on the value the user has already entered for the * machine name. * - * @param $component_data + * @param &$component_data * The array of component data assembled so far, passed by reference. The * default value gets set at $property_name. * @param $property_name * The name of a property in $component_data. */ - function getComponentDataDefaultValue($component_data, $property_name) { + function getComponentDataDefaultValue(&$component_data, $property_name = NULL) { } /** diff --git a/Generator/Module.php b/Generator/Module.php index 0036a19..9f52ecf 100644 --- a/Generator/Module.php +++ b/Generator/Module.php @@ -113,7 +113,7 @@ class Module extends BaseGenerator { * To get the full benefit of this, it is important to call this function * in the correct order, as given by the array of values in the function. * - * @param $component_data + * @param &$component_data * The array of component data assembled so far, passed by reference. The * default value will get set at $property_name, if a default is available. * @param $property_name diff --git a/drush/module_builder.drush.inc b/drush/module_builder.drush.inc index a50a85b..4755de7 100644 --- a/drush/module_builder.drush.inc +++ b/drush/module_builder.drush.inc @@ -228,7 +228,9 @@ function drush_module_builder_callback_build_module() { } catch (ModuleBuilderException $e) { // If the problem is that the hooks need downloading, we can recover from this. - if ($e->needs_hooks_download) { + $success = !$e->needs_hooks_download; + + if (!$success) { if (drush_confirm(dt('No hook definitions found. Would you like to download them now?'))) { // Download the hooks so we can move on. $success = drush_module_builder_callback_hook_download(); @@ -241,8 +243,9 @@ function drush_module_builder_callback_build_module() { $mb_task_handler_generate = $mb_factory->getTask('Generate', 'module'); } } + // Otherwise, fail. - else { + if (!$success) { drush_set_error(DRUSH_APPLICATION_ERROR, $e->getMessage()); return; } @@ -538,7 +541,7 @@ function module_builder_build_data($commands, $mb_task_handler_generate) { // ... or the commands themselves. elseif (isset($definition['commands'])) { // A numeric value of 'commands' means take that index from the commands array. - if (is_numeric($definition['commands']) && isset($commands[$definition['commands']])) { + if (isset($commands[$definition['commands']]) && is_numeric($definition['commands'])) { $data_item_value = $commands[$definition['commands']]; unset($commands[$definition['commands']]); } @@ -548,8 +551,8 @@ function module_builder_build_data($commands, $mb_task_handler_generate) { // We take items from the filtered commands. // First, we need to know where to start searching in the array. // Special case: if the filter is NULL, it means start at the beginning. - if ($definition['filter'] == NULL) { - $index = array_shift(array_keys($commands)); + if (empty($definition['filter'])) { + $index = current($indexes = array_keys($commands)); } else { // Search for our filter marker. -- 1.7.10.4