diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-10-16 16:38:22 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-10-16 16:38:22 +0200 |
commit | 91eeebfb07e416d21d9c4fe57e0387f3b075024d (patch) | |
tree | 6589ecfbed6b67ecade235a0a0455ea35aefb89a /phpBB/develop | |
parent | 3c9a8a3788f4dda1ef16430f16d6392a9e6f8dad (diff) | |
download | forums-91eeebfb07e416d21d9c4fe57e0387f3b075024d.tar forums-91eeebfb07e416d21d9c4fe57e0387f3b075024d.tar.gz forums-91eeebfb07e416d21d9c4fe57e0387f3b075024d.tar.bz2 forums-91eeebfb07e416d21d9c4fe57e0387f3b075024d.tar.xz forums-91eeebfb07e416d21d9c4fe57e0387f3b075024d.zip |
[ticket/11924] Remove duplicated code
PHPBB3-11924
Diffstat (limited to 'phpBB/develop')
-rw-r--r-- | phpBB/develop/export_events_for_wiki.php | 76 |
1 files changed, 22 insertions, 54 deletions
diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index 48eb4224b0..cce5939f48 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -109,6 +109,7 @@ function check_for_events($file) $lines = explode("\n", $content); for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) { + $event_line = 0; if ($found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->trigger_event('")) { $event_line = $i; @@ -116,23 +117,6 @@ function check_for_events($file) $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->trigger_event('")); $event_name = substr($event_name, 0, strpos($event_name, "'")); - // Validate @event name - $find_event_line = 1; - while (strpos($lines[$event_line - $find_event_line], '* @event ') === false) - { - $find_event_line++; - - if ($find_event_line > min(50, $event_line)) - { - throw new LogicException('Can not find @event tag for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $event_name_tag = substr(trim($lines[$event_line - $find_event_line]), strlen('* @event ')); - if ($event_name_tag !== $event_name) - { - throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $file . '"'); - } - // Find $vars array lines $find_varsarray_line = 1; while (strpos($lines[$event_line - $find_varsarray_line], "vars = array('") === false) @@ -168,54 +152,28 @@ function check_for_events($file) { throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); } - - // Find @since - $find_since_line = 1; - while (strpos($lines[$event_line - $find_since_line], '* @since ') === false) - { - $find_since_line++; - - if ($find_since_line > min(50, $event_line)) - { - throw new LogicException('Can not find @since tag for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $since = substr(trim($lines[$event_line - $find_since_line]), strlen('* @since ')); - $since = ($since == '3.1-A1') ? '3.1.0-a1' : $since; - - // Find event description line - $find_description_line = 3; - while (strpos(trim($lines[$event_line - $find_description_line]), '*') === 0) - { - $find_description_line++; - - if ($find_description_line > min(50, $event_line)) - { - throw new LogicException('Can not find description-line for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $description = substr(trim($lines[$event_line - $find_description_line + 1]), strlen('* ')); - - $events[$event_name] = array( - 'event' => $event_name, - 'file' => $file, - 'arguments' => $arguments, - 'since' => $since, - 'description' => $description, - ); } - if ($found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->dispatch('")) + else if ($found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->dispatch('")) { $event_line = $i; $event_name = $lines[$event_line]; $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->dispatch('")); $event_name = substr($event_name, 0, strpos($event_name, "'")); + $arguments = array(); + } + if ($event_line) + { // Validate @event name $find_event_line = 1; while (strpos($lines[$event_line - $find_event_line], '* @event ') === false) { $find_event_line++; + + if ($find_event_line > min(50, $event_line)) + { + throw new LogicException('Can not find @event tag for event "' . $event_name . '" in file "' . $file . '"'); + } } $event_name_tag = substr(trim($lines[$event_line - $find_event_line]), strlen('* @event ')); if ($event_name_tag !== $event_name) @@ -228,6 +186,11 @@ function check_for_events($file) while (strpos($lines[$event_line - $find_since_line], '* @since ') === false) { $find_since_line++; + + if ($find_since_line > min(50, $event_line)) + { + throw new LogicException('Can not find @since tag for event "' . $event_name . '" in file "' . $file . '"'); + } } $since = substr(trim($lines[$event_line - $find_since_line]), strlen('* @since ')); $since = ($since == '3.1-A1') ? '3.1.0-a1' : $since; @@ -237,13 +200,18 @@ function check_for_events($file) while (strpos(trim($lines[$event_line - $find_description_line]), '*') === 0) { $find_description_line++; + + if ($find_description_line > min(50, $event_line)) + { + throw new LogicException('Can not find description-line for event "' . $event_name . '" in file "' . $file . '"'); + } } $description = substr(trim($lines[$event_line - $find_description_line + 1]), strlen('* ')); $events[$event_name] = array( 'event' => $event_name, 'file' => $file, - 'arguments' => array(), + 'arguments' => $arguments, 'since' => $since, 'description' => $description, ); |