[ticket/16955] Clean up storage and template classes

PHPBB3-16955
This commit is contained in:
Marc Alexander 2022-12-26 14:55:23 +01:00
parent 077ceba2a9
commit 60c165c3d0
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
13 changed files with 20 additions and 43 deletions

View file

@ -278,7 +278,7 @@ class attachment extends controller
$response->headers->set('Content-Disposition', $disposition); $response->headers->set('Content-Disposition', $disposition);
// Set expires header for browser cache // Set expires header for browser cache
$time = new \Datetime(); $time = new \DateTime();
$response->setExpires($time->modify('+1 year')); $response->setExpires($time->modify('+1 year'));
return parent::handle($attachment['physical_filename']); return parent::handle($attachment['physical_filename']);

View file

@ -107,7 +107,7 @@ class avatar extends controller
$response->headers->set('Content-Disposition', $disposition); $response->headers->set('Content-Disposition', $disposition);
$time = new \Datetime(); $time = new \DateTime();
$response->setExpires($time->modify('+1 year')); $response->setExpires($time->modify('+1 year'));
parent::prepare($response, $file); parent::prepare($response, $file);

View file

@ -43,7 +43,7 @@ class file_info
/** /**
* Constructor * Constructor
* *
* @param \Symfony\Component\DependencyInjection\ContainerInterface $adapter * @param adapter_interface $adapter
* @param string $path * @param string $path
*/ */
public function __construct(adapter_interface $adapter, $path) public function __construct(adapter_interface $adapter, $path)

View file

@ -403,7 +403,7 @@ class storage
* *
* @param string $path The file * @param string $path The file
* *
* @throws \phpbb\storage\exception\not_implemented When the adapter doesnt implement the method * @throws \phpbb\storage\exception\exception When the adapter doesnt implement the method
* When the file doesn't exist * When the file doesn't exist
* *
* @return \phpbb\storage\file_info Returns file_info object * @return \phpbb\storage\file_info Returns file_info object

View file

@ -15,14 +15,6 @@ namespace phpbb\template;
interface template interface template
{ {
/**
* Clear the cache
*
* @return \phpbb\template\template
*/
public function clear_cache();
/** /**
* Sets the template filenames for handles. * Sets the template filenames for handles.
* *

View file

@ -53,7 +53,7 @@ class extension extends \Twig\Extension\AbstractExtension
/** /**
* Returns the token parser instance to add to the existing list. * Returns the token parser instance to add to the existing list.
* *
* @return array An array of \Twig\TokenParser\AbstractTokenParser instances * @return \Twig\TokenParser\TokenParserInterface[] An array of \Twig\TokenParser\AbstractTokenParser instances
*/ */
public function getTokenParsers() public function getTokenParsers()
{ {
@ -69,7 +69,7 @@ class extension extends \Twig\Extension\AbstractExtension
/** /**
* Returns a list of filters to add to the existing list. * Returns a list of filters to add to the existing list.
* *
* @return array An array of filters * @return \Twig\TwigFilter[] An array of filters
*/ */
public function getFilters() public function getFilters()
{ {
@ -85,7 +85,7 @@ class extension extends \Twig\Extension\AbstractExtension
/** /**
* Returns a list of global functions to add to the existing list. * Returns a list of global functions to add to the existing list.
* *
* @return array An array of global functions * @return \Twig\TwigFunction[] An array of global functions
*/ */
public function getFunctions() public function getFunctions()
{ {
@ -100,7 +100,7 @@ class extension extends \Twig\Extension\AbstractExtension
/** /**
* Returns a list of operators to add to the existing list. * Returns a list of operators to add to the existing list.
* *
* @return array An array of operators * @return array[] An array of operators
*/ */
public function getOperators() public function getOperators()
{ {

View file

@ -30,9 +30,9 @@ class avatar extends AbstractExtension
/** /**
* Returns a list of global functions to add to the existing list. * Returns a list of global functions to add to the existing list.
* *
* @return array An array of global functions * @return \Twig\TwigFunction[] An array of global functions
*/ */
public function getFunctions() public function getFunctions(): array
{ {
return array( return array(
new \Twig\TwigFunction('avatar', array($this, 'get_avatar')), new \Twig\TwigFunction('avatar', array($this, 'get_avatar')),

View file

@ -43,9 +43,9 @@ class config extends AbstractExtension
/** /**
* Returns a list of global functions to add to the existing list. * Returns a list of global functions to add to the existing list.
* *
* @return array An array of global functions * @return \Twig\TwigFunction[] An array of global functions
*/ */
public function getFunctions() public function getFunctions(): array
{ {
return array( return array(
new \Twig\TwigFunction('config', array($this, 'get_config')), new \Twig\TwigFunction('config', array($this, 'get_config')),

View file

@ -22,7 +22,7 @@ use Twig\TwigFunction;
class routing extends AbstractExtension class routing extends AbstractExtension
{ {
/** @var \phpbb\controller\helper */ /** @var \phpbb\routing\helper */
protected $helper; protected $helper;
/** /**

View file

@ -28,14 +28,12 @@ class username extends AbstractExtension
} }
/** /**
* Returns a list of global functions to add to the existing list. * {@inheritDoc}
*
* @return array An array of global functions
*/ */
public function getFunctions() public function getFunctions()
{ {
return array( return array(
new \Twig\TwigFunction('username', array($this, 'get_username')), new \Twig\TwigFunction('username', [$this, 'get_username']),
); );
} }

View file

@ -21,7 +21,7 @@ class event extends \Twig\Node\Node
*/ */
protected $listener_directory = 'event/'; protected $listener_directory = 'event/';
/** @var \Twig\Environment */ /** @var \phpbb\template\twig\environment */
protected $environment; protected $environment;
public function __construct(\Twig\Node\Expression\AbstractExpression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null) public function __construct(\Twig\Node\Expression\AbstractExpression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null)

View file

@ -23,7 +23,7 @@ class defineparser extends \Twig\TokenParser\AbstractTokenParser
* *
* @return \Twig\Node\Node A Twig\Node instance * @return \Twig\Node\Node A Twig\Node instance
* @throws \Twig\Error\SyntaxError * @throws \Twig\Error\SyntaxError
* @throws \phpbb\template\twig\node\definenode * @returns \phpbb\template\twig\node\definenode
*/ */
public function parse(\Twig\Token $token) public function parse(\Twig\Token $token)
{ {

View file

@ -92,27 +92,14 @@ class twig extends \phpbb\template\base
} }
// Add admin namespace // Add admin namespace
if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) if ($this->path_helper->get_adm_relative_path() !== null
&& is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')
&& $this->loader instanceof \Twig\Loader\FilesystemLoader)
{ {
$this->loader->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); $this->loader->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin');
} }
} }
/**
* Clear the cache
*
* @return \phpbb\template\template
*/
public function clear_cache()
{
if (is_dir($this->cachepath))
{
$this->twig->clearCacheFiles();
}
return $this;
}
/** /**
* Get the style tree of the style preferred by the current user * Get the style tree of the style preferred by the current user
* *