1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-01 12:05:37 +02:00

[ticket/11768] Updated phpbb\textformatter\s9e\factory::regenerate()

Returns an associative array rather than a numerically-indexed array. Feels
cleaner and more extensible.

PHPBB3-11768
This commit is contained in:
JoshyPHP 2015-02-15 03:08:36 +01:00
parent f6e3e41717
commit 6bd86a8e8a
6 changed files with 8 additions and 8 deletions

View File

@ -294,7 +294,7 @@ class factory implements \phpbb\textformatter\cache
/**
* Regenerate and cache a new parser and renderer
*
* @return array Array with two elements: an instance of the parser, an instance of the renderer
* @return array Associative array with at least two elements: "parser" and "renderer"
*/
public function regenerate()
{
@ -315,7 +315,7 @@ class factory implements \phpbb\textformatter\cache
);
$this->cache->put($this->cache_key_renderer, $renderer_data);
return array($parser, $renderer);
return array('parser' => $parser, 'renderer' => $renderer);
}
/**

View File

@ -48,7 +48,7 @@ class parser extends \phpbb\textformatter\parser
$parser = $cache->get($key);
if (!$parser)
{
list($parser) = $factory->regenerate();
extract($factory->regenerate());
}
$this->parser = $parser;

View File

@ -80,7 +80,7 @@ class renderer extends \phpbb\textformatter\renderer
if (!isset($renderer))
{
list(, $renderer) = $factory->regenerate();
extract($factory->regenerate());
}
$this->renderer = $renderer;

View File

@ -84,7 +84,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
public function test_regenerate()
{
list($parser, $renderer) = $this->get_factory()->regenerate();
extract($this->get_factory()->regenerate());
$this->assertInstanceOf('s9e\\TextFormatter\\Parser', $parser);
$this->assertInstanceOf('s9e\\TextFormatter\\Renderer', $renderer);
@ -113,7 +113,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
touch($old_file);
// Create a current renderer
list($parser, $renderer) = $factory->regenerate();
extract($factory->regenerate());
$new_file = $this->get_cache_dir() . get_class($renderer) . '.php';
// Tidy the cache

View File

@ -82,7 +82,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
->getMock();
$factory->expects($this->once())
->method('regenerate')
->will($this->returnValue(array($mock, false)));
->will($this->returnValue(array('parser' => $mock)));
$parser = new \phpbb\textformatter\s9e\parser(
new phpbb_mock_cache,

View File

@ -61,7 +61,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
->getMock();
$factory->expects($this->once())
->method('regenerate')
->will($this->returnValue(array($mock, false)));
->will($this->returnValue(array('parser' => $mock)));
$renderer = new \phpbb\textformatter\s9e\renderer(
$cache,