diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 39f7643c7..a2a68368e 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -351,8 +351,7 @@ class Twig_Environment * * This method should not be used as a generic way to load templates. * - * @param string $name The template name - * @param int $index The index if it is an embedded template + * @param string $template The template name * * @return Twig_Template A template instance representing the given template name * @@ -483,7 +482,7 @@ class Twig_Environment /** * Sets the Lexer instance. * - * @param Twig_LexerInterface A Twig_LexerInterface instance + * @param Twig_LexerInterface $lexer A Twig_LexerInterface instance */ public function setLexer(Twig_LexerInterface $lexer) { @@ -522,7 +521,7 @@ class Twig_Environment /** * Sets the Parser instance. * - * @param Twig_ParserInterface A Twig_ParserInterface instance + * @param Twig_ParserInterface $parser A Twig_ParserInterface instance */ public function setParser(Twig_ParserInterface $parser) { @@ -1271,11 +1270,11 @@ class Twig_Environment if (false === @mkdir($dir, 0777, true)) { clearstatcache(false, $dir); if (!is_dir($dir)) { - throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir)); + throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir)); } } } elseif (!is_writable($dir)) { - throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir)); + throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir)); } $tmpFile = tempnam($dir, basename($file)); diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index fa9fa35e8..8fc834613 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -315,7 +315,7 @@ class Twig_ExpressionParser { switch ($name) { case 'parent': - $args = $this->parseArguments(); + $this->parseArguments(); if (!count($this->parser->getBlockStack())) { throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename()); } @@ -468,6 +468,10 @@ class Twig_ExpressionParser * * @param bool $namedArguments Whether to allow named arguments or not * @param bool $definition Whether we are parsing arguments for a function definition + * + * @return Twig_Node + * + * @throws Twig_Error_Syntax */ public function parseArguments($namedArguments = false, $definition = false) { diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 346006d32..fd3b11718 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -921,7 +921,9 @@ function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false /** * Sorts an array. * - * @param array $array An array + * @param array $array + * + * @return array */ function twig_sort_filter($array) { @@ -952,6 +954,8 @@ function twig_in_filter($value, $compare) * @param string $strategy The escaping strategy * @param string $charset The charset * @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false) + * + * @return string */ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false) { @@ -1398,15 +1402,17 @@ function twig_test_iterable($value) /** * Renders a template. * - * @param string|array $template The template to render or an array of templates to try consecutively - * @param array $variables The variables to pass to the template - * @param bool $with_context Whether to pass the current context variables or not - * @param bool $ignore_missing Whether to ignore missing templates or not - * @param bool $sandboxed Whether to sandbox the template or not + * @param Twig_Environment $env + * @param array $context + * @param string|array $template The template to render or an array of templates to try consecutively + * @param array $variables The variables to pass to the template + * @param bool $withContext + * @param bool $ignoreMissing Whether to ignore missing templates or not + * @param bool $sandboxed Whether to sandbox the template or not * * @return string The rendered template */ -function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false) +function twig_include(Twig_Environment $env, array $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false) { $alreadySandboxed = false; $sandbox = null; diff --git a/lib/Twig/Extension/Escaper.php b/lib/Twig/Extension/Escaper.php index 0edf563ab..cf2020eec 100644 --- a/lib/Twig/Extension/Escaper.php +++ b/lib/Twig/Extension/Escaper.php @@ -104,6 +104,8 @@ class Twig_Extension_Escaper extends Twig_Extension * Marks a variable as being safe. * * @param string $string A PHP variable + * + * @return string */ function twig_raw_filter($string) { diff --git a/lib/Twig/LoaderInterface.php b/lib/Twig/LoaderInterface.php index b87058e67..9cd45e2a2 100644 --- a/lib/Twig/LoaderInterface.php +++ b/lib/Twig/LoaderInterface.php @@ -42,7 +42,8 @@ interface Twig_LoaderInterface * Returns true if the template is still fresh. * * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * @param int $time Timestamp of the last modification time of the + * cached template * * @return bool true if the template is fresh, false otherwise * diff --git a/lib/Twig/Node.php b/lib/Twig/Node.php index 515d81bb5..1c78e7b27 100644 --- a/lib/Twig/Node.php +++ b/lib/Twig/Node.php @@ -122,7 +122,7 @@ class Twig_Node implements Twig_NodeInterface /** * Returns true if the attribute is defined. * - * @param string The attribute name + * @param string $name The attribute name * * @return bool true if the attribute is defined, false otherwise */ @@ -132,11 +132,11 @@ class Twig_Node implements Twig_NodeInterface } /** - * Gets an attribute. + * Gets an attribute value by name. * - * @param string The attribute name + * @param string $name * - * @return mixed The attribute value + * @return mixed */ public function getAttribute($name) { @@ -148,10 +148,10 @@ class Twig_Node implements Twig_NodeInterface } /** - * Sets an attribute. + * Sets an attribute by name to a value. * - * @param string The attribute name - * @param mixed The attribute value + * @param string $name + * @param mixed $value */ public function setAttribute($name, $value) { @@ -159,9 +159,9 @@ class Twig_Node implements Twig_NodeInterface } /** - * Removes an attribute. + * Removes an attribute by name. * - * @param string The attribute name + * @param string $name */ public function removeAttribute($name) { @@ -169,11 +169,11 @@ class Twig_Node implements Twig_NodeInterface } /** - * Returns true if the node with the given identifier exists. + * Returns true if the node with the given name exists. * - * @param string The node name + * @param string $name * - * @return bool true if the node with the given name exists, false otherwise + * @return bool */ public function hasNode($name) { @@ -183,9 +183,9 @@ class Twig_Node implements Twig_NodeInterface /** * Gets a node by name. * - * @param string The node name + * @param string $name * - * @return Twig_Node A Twig_Node instance + * @return Twig_Node */ public function getNode($name) { @@ -199,8 +199,8 @@ class Twig_Node implements Twig_NodeInterface /** * Sets a node. * - * @param string The node name - * @param Twig_Node A Twig_Node instance + * @param string $name + * @param Twig_Node $node */ public function setNode($name, $node = null) { @@ -210,7 +210,7 @@ class Twig_Node implements Twig_NodeInterface /** * Removes a node by name. * - * @param string The node name + * @param string $name */ public function removeNode($name) { diff --git a/lib/Twig/Node/SandboxedPrint.php b/lib/Twig/Node/SandboxedPrint.php index 91872cccc..823e7acc7 100644 --- a/lib/Twig/Node/SandboxedPrint.php +++ b/lib/Twig/Node/SandboxedPrint.php @@ -47,6 +47,8 @@ class Twig_Node_SandboxedPrint extends Twig_Node_Print * This is mostly needed when another visitor adds filters (like the escaper one). * * @param Twig_Node $node A Node + * + * @return Twig_Node */ protected function removeNodeFilter($node) { diff --git a/lib/Twig/NodeTraverser.php b/lib/Twig/NodeTraverser.php index 8178a55c0..6024e65d0 100644 --- a/lib/Twig/NodeTraverser.php +++ b/lib/Twig/NodeTraverser.php @@ -54,6 +54,8 @@ class Twig_NodeTraverser * Traverses a node and calls the registered visitors. * * @param Twig_NodeInterface $node A Twig_NodeInterface instance + * + * @return Twig_NodeInterface */ public function traverse(Twig_NodeInterface $node) { diff --git a/lib/Twig/NodeVisitor/Optimizer.php b/lib/Twig/NodeVisitor/Optimizer.php index b9f9a5bfa..b206e9ad3 100644 --- a/lib/Twig/NodeVisitor/Optimizer.php +++ b/lib/Twig/NodeVisitor/Optimizer.php @@ -129,6 +129,8 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface * * @param Twig_NodeInterface $node A Node * @param Twig_Environment $env The current Twig environment + * + * @return Twig_NodeInterface */ protected function optimizePrintNode(Twig_NodeInterface $node, Twig_Environment $env) { @@ -153,6 +155,8 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface * * @param Twig_NodeInterface $node A Node * @param Twig_Environment $env The current Twig environment + * + * @return Twig_NodeInterface */ protected function optimizeRawFilter(Twig_NodeInterface $node, Twig_Environment $env) { diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index caf96428b..477a7b9fe 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -58,6 +58,8 @@ abstract class Twig_Template implements Twig_TemplateInterface * This method is for internal use only and should never be called * directly. * + * @param array $context + * * @return Twig_TemplateInterface|false The parent template or false if there is no parent */ public function getParent(array $context) @@ -352,7 +354,7 @@ abstract class Twig_Template implements Twig_TemplateInterface * @param string $item The variable to return from the context * @param bool $ignoreStrictCheck Whether to ignore the strict variable check or not * - * @return The content of the context variable + * @return mixed The content of the context variable * * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode */ diff --git a/lib/Twig/TokenParser.php b/lib/Twig/TokenParser.php index decebd5ee..57b1825bd 100644 --- a/lib/Twig/TokenParser.php +++ b/lib/Twig/TokenParser.php @@ -24,7 +24,7 @@ abstract class Twig_TokenParser implements Twig_TokenParserInterface /** * Sets the parser associated with this token parser * - * @param $parser A Twig_Parser instance + * @param Twig_Parser $parser A Twig_Parser instance */ public function setParser(Twig_Parser $parser) { diff --git a/lib/Twig/TokenParser/Block.php b/lib/Twig/TokenParser/Block.php index 81e6b1cff..0a46200a1 100644 --- a/lib/Twig/TokenParser/Block.php +++ b/lib/Twig/TokenParser/Block.php @@ -47,7 +47,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser $value = $token->getValue(); if ($value != $name) { - throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); + throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename()); } } } else { diff --git a/lib/Twig/TokenParser/Macro.php b/lib/Twig/TokenParser/Macro.php index 87a299d82..ad910b537 100644 --- a/lib/Twig/TokenParser/Macro.php +++ b/lib/Twig/TokenParser/Macro.php @@ -42,7 +42,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser $value = $token->getValue(); if ($value != $name) { - throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); + throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename()); } } $this->parser->popLocalScope(); diff --git a/lib/Twig/TokenParser/Set.php b/lib/Twig/TokenParser/Set.php index 84f7e94cb..0b419095f 100644 --- a/lib/Twig/TokenParser/Set.php +++ b/lib/Twig/TokenParser/Set.php @@ -48,13 +48,13 @@ class Twig_TokenParser_Set extends Twig_TokenParser $stream->expect(Twig_Token::BLOCK_END_TYPE); if (count($names) !== count($values)) { - throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignments.", $stream->getCurrent()->getLine(), $stream->getFilename()); + throw new Twig_Error_Syntax('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getFilename()); } } else { $capture = true; if (count($names) > 1) { - throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $stream->getCurrent()->getLine(), $stream->getFilename()); + throw new Twig_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getFilename()); } $stream->expect(Twig_Token::BLOCK_END_TYPE); diff --git a/lib/Twig/TokenParserInterface.php b/lib/Twig/TokenParserInterface.php index 31e8d5d5e..17e394b2a 100644 --- a/lib/Twig/TokenParserInterface.php +++ b/lib/Twig/TokenParserInterface.php @@ -19,7 +19,7 @@ interface Twig_TokenParserInterface /** * Sets the parser associated with this token parser * - * @param $parser A Twig_Parser instance + * @param Twig_Parser $parser A Twig_Parser instance */ public function setParser(Twig_Parser $parser); diff --git a/test/Twig/Tests/EnvironmentTest.php b/test/Twig/Tests/EnvironmentTest.php index ee127e01e..d0ada964e 100644 --- a/test/Twig/Tests/EnvironmentTest.php +++ b/test/Twig/Tests/EnvironmentTest.php @@ -56,7 +56,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase // globals can be modified after runtime init $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); - $globals = $twig->getGlobals(); + $twig->getGlobals(); $twig->initRuntime(); $twig->addGlobal('foo', 'bar'); $globals = $twig->getGlobals(); @@ -91,7 +91,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase // globals cannot be added after runtime init $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); - $globals = $twig->getGlobals(); + $twig->getGlobals(); $twig->initRuntime(); try { $twig->addGlobal('bar', 'bar'); @@ -103,7 +103,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase // globals cannot be added after extensions init $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); - $globals = $twig->getGlobals(); + $twig->getGlobals(); $twig->getFunctions(); try { $twig->addGlobal('bar', 'bar'); @@ -115,7 +115,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase // globals cannot be added after extensions and runtime init $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); - $globals = $twig->getGlobals(); + $twig->getGlobals(); $twig->getFunctions(); $twig->initRuntime(); try { diff --git a/test/Twig/Tests/LexerTest.php b/test/Twig/Tests/LexerTest.php index c4d708312..4ef58e5d3 100644 --- a/test/Twig/Tests/LexerTest.php +++ b/test/Twig/Tests/LexerTest.php @@ -144,7 +144,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase $lexer = new Twig_Lexer(new Twig_Environment()); $stream = $lexer->tokenize($template); - $node = $stream->next(); + $stream->next(); $node = $stream->next(); $this->assertEquals("922337203685477580700", $node->getValue()); } diff --git a/test/Twig/Tests/Node/ModuleTest.php b/test/Twig/Tests/Node/ModuleTest.php index 5facc55a4..5688af8cc 100644 --- a/test/Twig/Tests/Node/ModuleTest.php +++ b/test/Twig/Tests/Node/ModuleTest.php @@ -130,7 +130,7 @@ class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b785 EOF , $twig); - $set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant("foo", 4))), 4); + $set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4); $body = new Twig_Node(array($set)); $extends = new Twig_Node_Expression_Conditional( new Twig_Node_Expression_Constant(true, 2), diff --git a/test/Twig/Tests/TemplateTest.php b/test/Twig/Tests/TemplateTest.php index 9010f28e1..b66930608 100644 --- a/test/Twig/Tests/TemplateTest.php +++ b/test/Twig/Tests/TemplateTest.php @@ -509,7 +509,7 @@ class Twig_TemplateMagicPropertyObjectWithException { public function __isset($key) { - throw new Exception("Hey! Don't try to isset me!"); + throw new Exception('Hey! Don\'t try to isset me!'); } } diff --git a/test/Twig/Tests/escapingTest.php b/test/Twig/Tests/escapingTest.php index b28d3cda0..dfa9d438e 100644 --- a/test/Twig/Tests/escapingTest.php +++ b/test/Twig/Tests/escapingTest.php @@ -226,7 +226,8 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase /** * Convert a Unicode Codepoint to a literal UTF-8 character. * - * @param int $codepoint Unicode codepoint in hex notation + * @param int $codepoint Unicode codepoint in hex notation + * * @return string UTF-8 literal string */ protected function codepointToUtf8($codepoint)