From 825af557ae97687ed4bfd417f25e3a24eec04d02 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 6 Oct 2014 16:09:56 +0200 Subject: [ticket/13124] Also trim spaces in front of comments except for first line PHPBB3-13124 --- phpBB/phpbb/event/php_exporter.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index badbbb48fd..35144eeeec 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -253,7 +253,7 @@ class php_exporter public function get_event_name($event_line, $is_dispatch) { $event_text_line = $this->file_lines[$event_line]; - $event_text_line = ltrim($event_text_line, "\t"); + $event_text_line = ltrim($event_text_line, "\t "); if ($is_dispatch) { @@ -389,7 +389,7 @@ class php_exporter $found_comment_end = false; while (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t") !== '/**') { - if (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t") === '*/') + if (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t ") === '*/') { $found_comment_end = true; } @@ -471,7 +471,7 @@ class php_exporter { $find_tag_line = 0; $found_comment_end = false; - while (strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t"), '* @' . $find_tag . ' ') !== 0) + while (strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t "), '* @' . $find_tag . ' ') !== 0) { if ($found_comment_end && ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '/**') { @@ -482,7 +482,7 @@ class php_exporter foreach ($disallowed_tags as $disallowed_tag) { - if ($found_comment_end && strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t"), '* @' . $disallowed_tag) === 0) + if ($found_comment_end && strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t "), '* @' . $disallowed_tag) === 0) { // Found @var after the @since throw new \LogicException("Found '@{$disallowed_tag}' information after '@{$find_tag}' for event " @@ -490,7 +490,7 @@ class php_exporter } } - if (ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '*/') + if (ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t ") === '*/') { $found_comment_end = true; } @@ -550,7 +550,7 @@ class php_exporter public function validate_since($line) { $match = array(); - preg_match('#^\* @since (\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?)$#', ltrim($line, "\t"), $match); + preg_match('#^\* @since (\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?)$#', ltrim($line, "\t "), $match); if (!isset($match[1])) { throw new \LogicException("Invalid '@since' information for event " @@ -570,7 +570,7 @@ class php_exporter */ public function validate_event($event_name, $line) { - $event = substr(ltrim($line, "\t"), strlen('* @event ')); + $event = substr(ltrim($line, "\t "), strlen('* @event ')); if ($event !== trim($event)) { -- cgit v1.2.1 From 7bcf6a621f17a0072346d3d6cbe09abbc33bb511 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 6 Oct 2014 16:53:20 +0200 Subject: [ticket/13124] Fix tests for event exporter PHPBB3-13124 --- tests/event/php_exporter_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index b52d68e305..7038725e51 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -119,6 +119,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array('* @since 3.1.0-b3', '3.1.0-b3'), array(' * @since 3.1.0-b3', '3.1.0-b3'), array('* @since 3.1.0-RC2', '3.1.0-RC2'), + array(' * @since 3.1.0-a1', '3.1.0-a1'), ); } @@ -133,7 +134,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case static public function validate_since_throws_data() { return array( - array(' * @since 3.1.0-a1'), array('* @since 3.1.0-a1 '), array('* @since 3.1.0-a1 bertie is cool'), array('bertie* @since 3.1.0-a1'), @@ -156,6 +156,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case return array( array('test.event', '* @event test.event', 'test.event'), array('test.event2', ' * @event test.event2', 'test.event2'), + array('test.event', ' * @event test.event', 'test.event'), ); } @@ -170,7 +171,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case static public function validate_event_throws_data() { return array( - array('test.event', ' * @event test.event', 1), array('test.event', '* @event test.event bertie is cool', 2), array('test.event', 'bertie* @event test.event', 2), ); -- cgit v1.2.1 From a9ed32663ac0eeb4254a54f4fbc7db6971007d03 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 9 Oct 2014 13:30:10 -0400 Subject: [ticket/13124] Add another test case as requested PHPBB3-13124 --- tests/event/fixtures/trigger_wspace.test | 15 +++++++++++++++ tests/event/php_exporter_test.php | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/event/fixtures/trigger_wspace.test diff --git a/tests/event/fixtures/trigger_wspace.test b/tests/event/fixtures/trigger_wspace.test new file mode 100644 index 0000000000..0334a9c80b --- /dev/null +++ b/tests/event/fixtures/trigger_wspace.test @@ -0,0 +1,15 @@ +trigger_event('core.trigger', compact($vars))); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 7038725e51..692a57f93c 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -61,6 +61,18 @@ class phpbb_event_php_exporter_test extends phpbb_test_case ), ), ), + array( + 'trigger_wspace.test', + array( + 'core.trigger' => array( + 'event' => 'core.trigger', + 'file' => 'trigger_wspace.test', + 'arguments' => array('cp_row', 'current_row_number', 'end', 'row', 'start'), + 'since' => '3.1.0-a3', + 'description' => 'Event after the post data has been assigned to the template', + ), + ), + ), array( 'trigger_many_vars.test', array( -- cgit v1.2.1