1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-16 13:52:03 +02:00

[ticket/12273] Use class properties instead of parameters

PHPBB3-12273
This commit is contained in:
Joas Schilling 2014-04-18 02:08:23 +02:00
parent 91deb4419b
commit b831e96aaf
4 changed files with 211 additions and 129 deletions

View File

@ -12,12 +12,30 @@ class event_exporter
/** @var string */
protected $root_path;
/** @var string */
protected $current_file;
/** @var string */
protected $current_event;
/** @var int */
protected $current_event_line;
/** @var array */
protected $events;
/** @var array */
protected $file_lines;
/**
* @param string $phpbb_root_path
*/
public function __construct($phpbb_root_path)
{
$this->root_path = $phpbb_root_path;
$this->events = $this->file_lines = array();
$this->current_file = $this->current_event = '';
$this->current_event_line = 0;
}
function export_from_eventsmd($filter)
@ -82,53 +100,70 @@ class event_exporter
function export_from_php()
{
$files = $this->get_file_list($this->root_path);
$events = array();
$this->events = array();
foreach ($files as $file)
{
$file_events = $this->check_for_events($file);
if (!empty($file_events))
{
$events = array_merge($events, $file_events);
}
$this->check_for_events($file);
}
ksort($events);
ksort($this->events);
foreach ($events as $event)
foreach ($this->events as $event)
{
echo '|- id="' . $event['event'] . '"' . "\n";
echo '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n";
}
}
public function get_events()
{
return $this->events;
}
public function set_current_event($name, $line)
{
$this->current_event = $name;
$this->current_event_line = $line;
}
public function set_content($content)
{
$this->file_lines = $content;
}
/**
* @param $file
* @throws LogicException
*/
public function check_for_events($file)
{
$events = array();
$content = file_get_contents($this->root_path . $file);
$this->current_file = $file;
$this->file_lines = array();
$content = file_get_contents($this->root_path . $this->current_file);
if (strpos($content, "dispatcher->trigger_event('") || strpos($content, "dispatcher->dispatch('"))
{
$lines = explode("\n", $content);
for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++)
$this->set_content(explode("\n", $content));
for ($i = 0, $num_lines = sizeof($this->file_lines); $i < $num_lines; $i++)
{
$event_line = false;
$found_trigger_event = strpos($lines[$i], "dispatcher->trigger_event('");
$found_trigger_event = strpos($this->file_lines[$i], "dispatcher->trigger_event('");
if ($found_trigger_event !== false)
{
$event_line = $i;
$event_name = $this->get_trigger_event_name($file, $lines[$event_line]);
$this->set_current_event($this->get_trigger_event_name($this->file_lines[$event_line]), $event_line);
// Find variables of the event
$arguments = $this->get_vars_from_array($file, $event_name, $lines, $event_line);
$doc_vars = $this->get_vars_from_docblock($file, $event_name, $lines, $event_line);
$this->validate_vars_docblock_array($file, $event_name, $arguments, $doc_vars);
$arguments = $this->get_vars_from_array();
$doc_vars = $this->get_vars_from_docblock();
$this->validate_vars_docblock_array($arguments, $doc_vars);
}
else
{
$found_dispatch = strpos($lines[$i], "dispatcher->dispatch('");
$found_dispatch = strpos($this->file_lines[$i], "dispatcher->dispatch('");
if ($found_dispatch !== false)
{
$event_line = $i;
$event_name = $this->get_dispatch_name($file, $lines[$event_line]);
$this->set_current_event($this->get_dispatch_name($this->file_lines[$event_line]), $event_line);
$arguments = array();
}
}
@ -136,20 +171,26 @@ class event_exporter
if ($event_line)
{
// Validate @event
$event_line_num = $this->find_event($file, $event_name, $lines, $event_line);
$this->validate_event($file, $event_name, $lines[$event_line_num]);
$event_line_num = $this->find_event();
$this->validate_event($this->current_event, $this->file_lines[$event_line_num]);
// Validate @since
$since_line_num = $this->find_since($file, $event_name, $lines, $event_line);
$since = $this->validate_since($file, $event_name, $lines[$since_line_num]);
$since_line_num = $this->find_since();
$since = $this->validate_since($this->file_lines[$since_line_num]);
// Find event description line
$description_line_num = $this->find_description($file, $event_name, $lines, $event_line);
$description = substr(trim($lines[$description_line_num]), strlen('* '));
$description_line_num = $this->find_description();
$description = substr(trim($this->file_lines[$description_line_num]), strlen('* '));
$events[$event_name] = array(
'event' => $event_name,
'file' => $file,
if (isset($this->events[$this->current_event]))
{
throw new LogicException('The event "' . $this->current_event . '" from file "' . $this->current_file
. '" already exists in file "'. $this->events[$this->current_event]['file'] . '"', 10);
}
$this->events[$this->current_event] = array(
'event' => $this->current_event,
'file' => $this->current_file,
'arguments' => $arguments,
'since' => $since,
'description' => $description,
@ -157,18 +198,16 @@ class event_exporter
}
}
}
return $events;
}
/**
* Find the name of the event inside the dispatch() line
*
* @param string $file
* @param string $event_line
* @return int Absolute line number
* @throws LogicException
*/
public function get_dispatch_name($file, $event_line)
public function get_dispatch_name($event_line)
{
$event_line = ltrim($event_line, "\t");
@ -181,7 +220,7 @@ class event_exporter
preg_match($regex, $event_line, $match);
if (!isset($match[2]))
{
throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $file . '"', 1);
throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1);
}
return $match[2];
@ -190,11 +229,11 @@ class event_exporter
/**
* Find the name of the event inside the trigger_event() line
*
* @param string $file
* @param string $event_line
* @return int Absolute line number
* @throws LogicException
*/
public function get_trigger_event_name($file, $event_line)
public function get_trigger_event_name($event_line)
{
$event_line = ltrim($event_line, "\t");
@ -207,7 +246,7 @@ class event_exporter
preg_match($regex, $event_line, $match);
if (!isset($match[2]))
{
throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $file . '"', 1);
throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1);
}
return $match[2];
@ -226,24 +265,21 @@ class event_exporter
/**
* Find the $vars array
*
* @param string $file
* @param string $event_name
* @param array $lines
* @param int $event_line Index of the event call in $lines
* @return array List of variables
* @throws LogicException
*/
public function get_vars_from_array($file, $event_name, $lines, $event_line)
public function get_vars_from_array()
{
$vars_line = ltrim($lines[$event_line - 1], "\t");
$vars_line = ltrim($this->file_lines[$this->current_event_line - 1], "\t");
if (strpos($vars_line, "\$vars = array('") !== 0 || substr($vars_line, -3) !== '\');')
{
throw new LogicException('Can not find "$vars = array();"-line for event "' . $event_name . '" in file "' . $file . '"', 1);
throw new LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1);
}
$vars_array = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');'));
if ($vars_array === '')
{
throw new LogicException('Found empty $vars array for event "' . $event_name . '" in file "' . $file . '"', 2);
throw new LogicException('Found empty $vars array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2);
}
$vars_array = explode("', '", $vars_array);
@ -252,7 +288,7 @@ class event_exporter
{
if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var))
{
throw new LogicException('Found invalid var "' . $var . '" in array for event "' . $event_name . '" in file "' . $file . '"', 3);
throw new LogicException('Found invalid var "' . $var . '" in array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3);
}
}
@ -263,59 +299,56 @@ class event_exporter
/**
* Find the $vars array
*
* @param string $file
* @param string $event_name
* @param array $lines
* @param int $event_line Index of the event call in $lines
* @return array List of variables
* @throws LogicException
*/
public function get_vars_from_docblock($file, $event_name, $lines, $event_line)
public function get_vars_from_docblock()
{
$doc_vars = array();
$current_doc_line = 1;
$found_comment_end = false;
while (ltrim($lines[$event_line - $current_doc_line], "\t") !== '/**')
while (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t") !== '/**')
{
if (ltrim($lines[$event_line - $current_doc_line], "\t") === '*/')
if (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t") === '*/')
{
$found_comment_end = true;
}
if ($found_comment_end)
{
$var_line = trim($lines[$event_line - $current_doc_line]);
$var_line = trim($this->file_lines[$this->current_event_line - $current_doc_line]);
$var_line = preg_replace('!\s+!', ' ', $var_line);
if (strpos($var_line, '* @var ') === 0)
{
$doc_line = explode(' ', $var_line, 5);
if (sizeof($doc_line) !== 5)
{
throw new LogicException('Found invalid line "' . $lines[$event_line - $current_doc_line]
. '" for event "' . $event_name . '" in file "' . $file . '"', 1);
throw new LogicException('Found invalid line "' . $this->file_lines[$this->current_event_line - $current_doc_line]
. '" for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1);
}
$doc_vars[] = $doc_line[3];
}
}
$current_doc_line++;
if ($current_doc_line > $event_line)
if ($current_doc_line > $this->current_event_line)
{
// Reached the start of the file
throw new LogicException('Can not find end of docblock for event "' . $event_name . '" in file "' . $file . '"', 2);
throw new LogicException('Can not find end of docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2);
}
}
if (empty($doc_vars))
{
// Reached the start of the file
throw new LogicException('Can not find @var lines for event "' . $event_name . '" in file "' . $file . '"', 3);
throw new LogicException('Can not find @var lines for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3);
}
foreach ($doc_vars as $var)
{
if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var))
{
throw new LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $event_name . '" in file "' . $file . '"', 4);
throw new LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 4);
}
}
@ -326,109 +359,96 @@ class event_exporter
/**
* Find the "@since" Information line
*
* @param string $file
* @param string $event_name
* @param array $lines
* @param int $event_line Index of the event call in $lines
* @return int Absolute line number
* @throws LogicException
*/
public function find_since($file, $event_name, $lines, $event_line)
public function find_since()
{
return $this->find_tag($file, $event_name, $lines, $event_line, 'since', array('event', 'var'));
return $this->find_tag('since', array('event', 'var'));
}
/**
* Find the "@event" Information line
*
* @param string $file
* @param string $event_name
* @param array $lines
* @param int $event_line Index of the event call in $lines
* @return int Absolute line number
*/
public function find_event($file, $event_name, $lines, $event_line)
public function find_event()
{
return $this->find_tag($file, $event_name, $lines, $event_line, 'event', array());
return $this->find_tag('event', array());
}
/**
* Find a "@*" Information line
*
* @param string $file
* @param string $event_name
* @param array $lines
* @param int $event_line Index of the event call in $lines
* @param string $find_tag Name of the tag we are trying to find
* @param array $disallowed_tags List of tags that must not appear between
* the tag and the actual event
* @return int Absolute line number
* @throws LogicException
*/
public function find_tag($file, $event_name, $lines, $event_line, $find_tag, $disallowed_tags)
public function find_tag($find_tag, $disallowed_tags)
{
$find_tag_line = 0;
$found_comment_end = false;
while (strpos(ltrim($lines[$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($lines[$event_line - $find_tag_line], "\t") === '/**')
if ($found_comment_end && ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '/**')
{
// Reached the start of this doc block
throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $event_name . '" in file "' . $file . '"', 1);
throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1);
}
foreach ($disallowed_tags as $disallowed_tag)
{
if ($found_comment_end && strpos(ltrim($lines[$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 "' . $event_name . '" in file "' . $file . '"', 3);
throw new LogicException('Found @' . $disallowed_tag . ' information after @' . $find_tag . ' for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3);
}
}
if (ltrim($lines[$event_line - $find_tag_line], "\t") === '*/')
if (ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '*/')
{
$found_comment_end = true;
}
$find_tag_line++;
if ($find_tag_line >= $event_line)
if ($find_tag_line >= $this->current_event_line)
{
// Reached the start of the file
throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $event_name . '" in file "' . $file . '"', 2);
throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2);
}
}
return $event_line - $find_tag_line;
return $this->current_event_line - $find_tag_line;
}
/**
* Find a "@*" Information line
*
* @param string $file
* @param string $event_name
* @param array $lines
* @param int $event_line Index of the event call in $lines
* @return int Absolute line number
* @throws LogicException
*/
public function find_description($file, $event_name, $lines, $event_line)
public function find_description()
{
$find_desc_line = 0;
while (ltrim($lines[$event_line - $find_desc_line], "\t") !== '/**')
while (ltrim($this->file_lines[$this->current_event_line - $find_desc_line], "\t") !== '/**')
{
$find_desc_line++;
if ($find_desc_line > $event_line)
if ($find_desc_line > $this->current_event_line)
{
// Reached the start of the file
throw new LogicException('Can not find a description for event "' . $event_name . '" in file "' . $file . '"', 1);
throw new LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1);
}
}
$find_desc_line = $event_line - $find_desc_line + 1;
$find_desc_line = $this->current_event_line - $find_desc_line + 1;
$desc = trim($lines[$find_desc_line]);
$desc = trim($this->file_lines[$find_desc_line]);
if (strpos($desc, '* @') === 0 || $desc[0] !== '*' || substr($desc, 1) == '')
{
// First line of the doc block is a @-line, empty or only contains "*"
throw new LogicException('Can not find a description for event "' . $event_name . '" in file "' . $file . '"', 2);
throw new LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2);
}
return $find_desc_line;
@ -437,25 +457,24 @@ class event_exporter
/**
* Validate "@since" Information
*
* @param string $file
* @param string $event_name
* @param string $line
* @return string
* @throws LogicException
*/
public function validate_since($file, $event_name, $line)
public function validate_since($line)
{
$since = substr(ltrim($line, "\t"), strlen('* @since '));
if ($since !== trim($since))
{
throw new LogicException('Invalid @since information for event "' . $event_name . '" in file "' . $file . '"', 1);
throw new LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1);
}
$since = ($since === '3.1-A1') ? '3.1.0-a1' : $since;
if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since))
{
throw new LogicException('Invalid @since information for event "' . $event_name . '" in file "' . $file . '"', 2);
throw new LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2);
}
return $since;
@ -464,23 +483,23 @@ class event_exporter
/**
* Validate "@event" Information
*
* @param string $file
* @param string $event_name
* @param string $line
* @return string
* @throws LogicException
*/
public function validate_event($file, $event_name, $line)
public function validate_event($event_name, $line)
{
$event = substr(ltrim($line, "\t"), strlen('* @event '));
if ($event !== trim($event))
{
throw new LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $file . '"', 1);
throw new LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $this->current_file . '"', 1);
}
if ($event !== $event_name)
{
throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $file . '"', 2);
throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $this->current_file . '"', 2);
}
return $event;
@ -489,13 +508,12 @@ class event_exporter
/**
* Validates that two arrays contain the same strings
*
* @param string $file
* @param string $event_name
* @param array $vars_array Variables found in the array line
* @param array $vars_docblock Variables found in the doc block
* @return null
* @throws LogicException
*/
public function validate_vars_docblock_array($file, $event_name, $vars_array, $vars_docblock)
public function validate_vars_docblock_array($vars_array, $vars_docblock)
{
$vars_array = array_unique($vars_array);
$vars_docblock = array_unique($vars_docblock);
@ -503,7 +521,7 @@ class event_exporter
if ($sizeof_vars_array !== sizeof($vars_docblock) || $sizeof_vars_array !== sizeof(array_intersect($vars_array, $vars_docblock)))
{
throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"');
throw new LogicException('$vars array does not match the list of @var tags for event "' . $this->current_event . '" in file "' . $this->current_file . '"');
}
}
@ -513,6 +531,7 @@ class event_exporter
* Works recursive with any depth
*
* @param string $dir Directory to go through
* @param string $path Path from root to $dir
* @return array List of files (including directories from within $dir
*/
function get_file_list($dir, $path = '')

View File

@ -71,7 +71,25 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_check_for_events($file, $expected)
{
$this->assertEquals($expected, $this->exporter->check_for_events($file));
$this->exporter->check_for_events($file);
$this->assertEquals($expected, $this->exporter->get_events());
}
static public function check_for_events_throws_data()
{
return array(
array('missing_var.test', null),
array('duplicate_event.test', 10),
);
}
/**
* @dataProvider check_for_events_throws_data
*/
public function test_check_for_events_throws($file, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->assertNull($this->exporter->check_for_events($file));
}
static public function validate_since_data()
@ -89,7 +107,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_since($since, $expected)
{
$this->assertEquals($expected, $this->exporter->validate_since('', '', $since));
$this->assertEquals($expected, $this->exporter->validate_since($since));
}
static public function validate_since_throws_data()
@ -111,7 +129,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_validate_since_throws($since, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->validate_since('', '', $since);
$this->exporter->validate_since($since);
}
static public function validate_event_data()
@ -127,7 +145,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_event($event_name, $event, $expected)
{
$this->assertEquals($expected, $this->exporter->validate_event('', $event_name, $event));
$this->assertEquals($expected, $this->exporter->validate_event($event_name, $event));
}
static public function validate_event_throws_data()
@ -146,7 +164,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_validate_event_throws($event_name, $event, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->validate_event('', $event_name, $event);
$this->exporter->validate_event($event_name, $event);
}
static public function validate_vars_docblock_array_data()
@ -161,7 +179,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_vars_docblock_array($vars_array, $vars_docblock)
{
$this->assertNull($this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock));
$this->assertNull($this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock));
}
static public function validate_vars_docblock_array_throws_data()
@ -181,7 +199,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock)
{
$this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock);
$this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock);
}
static public function get_dispatch_name_data()
@ -199,7 +217,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_dispatch_name($event_line, $expected)
{
$this->assertEquals($expected, $this->exporter->get_dispatch_name('', $event_line));
$this->assertEquals($expected, $this->exporter->get_dispatch_name($event_line));
}
static public function get_dispatch_name_throws_data()
@ -218,7 +236,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_dispatch_name_throws($event_line)
{
$this->exporter->get_dispatch_name('', $event_line);
$this->exporter->get_dispatch_name($event_line);
}
static public function get_trigger_event_name_data()
@ -236,7 +254,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_trigger_event_name($event_line, $expected)
{
$this->assertEquals($expected, $this->exporter->get_trigger_event_name('', $event_line));
$this->assertEquals($expected, $this->exporter->get_trigger_event_name($event_line));
}
static public function get_trigger_event_name_throws_data()
@ -259,7 +277,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_trigger_event_name_throws($event_line)
{
$this->exporter->get_trigger_event_name('', $event_line);
$this->exporter->get_trigger_event_name($event_line);
}
static public function get_vars_from_array_data()
@ -293,7 +311,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_vars_from_array($lines, $event_line, $expected)
{
$this->assertEquals($expected, $this->exporter->get_vars_from_array('', '', $lines, $event_line));
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->assertEquals($expected, $this->exporter->get_vars_from_array());
}
static public function get_vars_from_array_throws_data()
@ -349,7 +369,10 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_get_vars_from_array_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->get_vars_from_array('', '', $lines, $event_line);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->exporter->get_vars_from_array();
}
static public function get_vars_from_docblock_data()
@ -374,7 +397,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_vars_from_docblock($lines, $event_line, $expected)
{
$this->assertEquals($expected, $this->exporter->get_vars_from_docblock('', '', $lines, $event_line));
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->assertEquals($expected, $this->exporter->get_vars_from_docblock());
}
static public function get_vars_from_docblock_throws_data()
@ -429,7 +454,10 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->get_vars_from_docblock('', '', $lines, $event_line);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->exporter->get_vars_from_docblock();
}
static public function find_since_data()
@ -465,7 +493,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_find_since($lines, $event_line, $expected)
{
$this->assertEquals($expected, $this->exporter->find_since('', '', $lines, $event_line));
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->assertEquals($expected, $this->exporter->find_since());
}
static public function find_since_throws_data()
@ -527,7 +557,10 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_find_since_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->find_since('', '', $lines, $event_line);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->exporter->find_since();
}
static public function find_description_data()
@ -565,7 +598,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_find_description($lines, $event_line, $expected)
{
$this->assertEquals($expected, $this->exporter->find_description('', '', $lines, $event_line));
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->assertEquals($expected, $this->exporter->find_description());
}
static public function find_description_throws_data()
@ -623,6 +658,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_find_description_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->find_description('', '', $lines, $event_line);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
$this->exporter->find_description();
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Event after the post data has been assigned to the template
*
* @event duplicate.trigger
* @var int start Start item of this page
* @var int current_row_number Number of the post on this page
* @var int end Number of posts on this page
* @var array row Array with original post and user data
* @var array cp_row Custom profile field data of the poster
* @var array attachments List of attachments
* @var array user_poster_data Poster's data from user cache
* @var array post_row Template block array of the post
* @since 3.1.0-a3
*/
$vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');
extract($phpbb_dispatcher->trigger_event('duplicate.trigger', compact($vars)));
/**
* Event after the post data has been assigned to the template
*
* @event duplicate.trigger
* @since 3.1.0-b1
*/
$phpbb_dispatcher->dispatch('duplicate.trigger');

View File

@ -11,7 +11,6 @@
* @var array cp_row Custom profile field data of the poster
* @var array attachments List of attachments
* @var array user_poster_data Poster's data from user cache
* @var array post_row Template block array of the post
* @since 3.1.0-a3
*/
$vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');