From 8fee70e3d184d8212ceb09115072803550172d0d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 31 Dec 2010 16:45:07 +0100 Subject: [PATCH] added some missing phpdoc --- lib/Twig/Autoloader.php | 4 +- lib/Twig/CompilerInterface.php | 4 +- lib/Twig/Environment.php | 6 ++ lib/Twig/Error.php | 17 +++++ lib/Twig/Extension.php | 4 +- lib/Twig/ExtensionInterface.php | 20 +++--- lib/Twig/FilterInterface.php | 16 ++++- lib/Twig/FunctionInterface.php | 13 +++- lib/Twig/GrammarInterface.php | 6 +- lib/Twig/LexerInterface.php | 2 +- lib/Twig/LoaderInterface.php | 6 +- lib/Twig/NodeInterface.php | 6 +- lib/Twig/NodeVisitorInterface.php | 6 +- lib/Twig/Parser.php | 12 ++++ lib/Twig/ParserInterface.php | 6 +- lib/Twig/Sandbox/SecurityPolicyInterface.php | 6 +- lib/Twig/Template.php | 91 ++++++++++++++++++++++++++ lib/Twig/TemplateInterface.php | 13 +++- lib/Twig/TestInterface.php | 7 ++- lib/Twig/Token.php | 62 +++++++++++++++++- lib/Twig/TokenParser.php | 12 ++++ lib/Twig/TokenParserBroker.php | 13 ++-- lib/Twig/TokenParserBrokerInterface.php | 13 ++-- lib/Twig/TokenParserInterface.php | 18 ++++- lib/Twig/TokenStream.php | 22 +++++- 25 files changed, 318 insertions(+), 67 deletions(-) diff --git a/lib/Twig/Autoloader.php b/lib/Twig/Autoloader.php index c398d65..4d1f6e1 100644 --- a/lib/Twig/Autoloader.php +++ b/lib/Twig/Autoloader.php @@ -12,8 +12,8 @@ /** * Autoloads Twig classes. * - * @package twig - * @author Fabien Potencier + * @package twig + * @author Fabien Potencier */ class Twig_Autoloader { diff --git a/lib/Twig/CompilerInterface.php b/lib/Twig/CompilerInterface.php index 055c4af..c03407e 100644 --- a/lib/Twig/CompilerInterface.php +++ b/lib/Twig/CompilerInterface.php @@ -24,12 +24,12 @@ interface Twig_CompilerInterface * * @return Twig_Compiler The current compiler instance */ - public function compile(Twig_NodeInterface $node); + function compile(Twig_NodeInterface $node); /** * Gets the current PHP code after compilation. * * @return string The PHP code */ - public function getSource(); + function getSource(); } diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index a1aaea1..71ff017 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -9,6 +9,12 @@ * file that was distributed with this source code. */ +/** + * Stores the Twig configuration. + * + * @package twig + * @author Fabien Potencier + */ class Twig_Environment { const VERSION = '1.0.0-BETA1'; diff --git a/lib/Twig/Error.php b/lib/Twig/Error.php index 6eb9130..ae6143c 100644 --- a/lib/Twig/Error.php +++ b/lib/Twig/Error.php @@ -21,6 +21,13 @@ class Twig_Error extends Exception protected $filename; protected $rawMessage; + /** + * Constructor. + * + * @param string $message The error message + * @param integer $lineno The template line where the error occurred + * @param string $filename The template file name where the error occurred + */ public function __construct($message, $lineno = -1, $filename = null) { $this->lineno = $lineno; @@ -32,11 +39,21 @@ class Twig_Error extends Exception parent::__construct($this->message); } + /** + * Gets the filename where the error occurred. + * + * @return string The filename + */ public function getFilename() { return $this->filename; } + /** + * Sets the filename where the error occurred. + * + * @param string $filename The filename + */ public function setFilename($filename) { $this->filename = $filename; diff --git a/lib/Twig/Extension.php b/lib/Twig/Extension.php index 8327c43..ac289cb 100644 --- a/lib/Twig/Extension.php +++ b/lib/Twig/Extension.php @@ -15,9 +15,9 @@ abstract class Twig_Extension implements Twig_ExtensionInterface * * This is where you can load some file that contains filter functions for instance. * - * @param Twig_Environment $environement The current Twig_Environment instance + * @param Twig_Environment $environment The current Twig_Environment instance */ - public function initRuntime(Twig_Environment $environement) + public function initRuntime(Twig_Environment $environment) { } diff --git a/lib/Twig/ExtensionInterface.php b/lib/Twig/ExtensionInterface.php index 19df6e9..af8d93e 100644 --- a/lib/Twig/ExtensionInterface.php +++ b/lib/Twig/ExtensionInterface.php @@ -22,63 +22,63 @@ interface Twig_ExtensionInterface * * This is where you can load some file that contains filter functions for instance. * - * @param Twig_Environment $environement The current Twig_Environment instance + * @param Twig_Environment $environment The current Twig_Environment instance */ - public function initRuntime(Twig_Environment $environement); + function initRuntime(Twig_Environment $environment); /** * Returns the token parser instances to add to the existing list. * * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances */ - public function getTokenParsers(); + function getTokenParsers(); /** * Returns the node visitor instances to add to the existing list. * * @return array An array of Twig_NodeVisitorInterface instances */ - public function getNodeVisitors(); + function getNodeVisitors(); /** * Returns a list of filters to add to the existing list. * * @return array An array of filters */ - public function getFilters(); + function getFilters(); /** * Returns a list of tests to add to the existing list. * * @return array An array of tests */ - public function getTests(); + function getTests(); /** * Returns a list of functions to add to the existing list. * * @return array An array of functions */ - public function getFunctions(); + function getFunctions(); /** * Returns a list of operators to add to the existing list. * * @return array An array of operators */ - public function getOperators(); + function getOperators(); /** * Returns a list of global functions to add to the existing list. * * @return array An array of global functions */ - public function getGlobals(); + function getGlobals(); /** * Returns the name of the extension. * * @return string The extension name */ - public function getName(); + function getName(); } diff --git a/lib/Twig/FilterInterface.php b/lib/Twig/FilterInterface.php index 6abeab1..eb6ac57 100644 --- a/lib/Twig/FilterInterface.php +++ b/lib/Twig/FilterInterface.php @@ -17,8 +17,16 @@ */ interface Twig_FilterInterface { - public function compile(); - public function needsEnvironment(); - public function getSafe(Twig_Node $filterArgs); - public function getPreEscape(); + /** + * Compiles a filter. + * + * @return string The PHP code for the filter + */ + function compile(); + + function needsEnvironment(); + + function getSafe(Twig_Node $filterArgs); + + function getPreEscape(); } diff --git a/lib/Twig/FunctionInterface.php b/lib/Twig/FunctionInterface.php index ee4f489..01d3566 100644 --- a/lib/Twig/FunctionInterface.php +++ b/lib/Twig/FunctionInterface.php @@ -18,7 +18,14 @@ */ interface Twig_FunctionInterface { - public function compile(); - public function needsEnvironment(); - public function getSafe(Twig_Node $filterArgs); + /** + * Compiles a function. + * + * @return string The PHP code for the function + */ + function compile(); + + function needsEnvironment(); + + function getSafe(Twig_Node $filterArgs); } diff --git a/lib/Twig/GrammarInterface.php b/lib/Twig/GrammarInterface.php index 5a71b7e..efb005c 100644 --- a/lib/Twig/GrammarInterface.php +++ b/lib/Twig/GrammarInterface.php @@ -10,9 +10,9 @@ */ interface Twig_GrammarInterface { - public function setParser(Twig_ParserInterface $parser); + function setParser(Twig_ParserInterface $parser); - public function parse(Twig_Token $token); + function parse(Twig_Token $token); - public function getName(); + function getName(); } diff --git a/lib/Twig/LexerInterface.php b/lib/Twig/LexerInterface.php index 5c1af5d..58fee31 100644 --- a/lib/Twig/LexerInterface.php +++ b/lib/Twig/LexerInterface.php @@ -25,5 +25,5 @@ interface Twig_LexerInterface * * @return Twig_TokenStream A token stream instance */ - public function tokenize($code, $filename = null); + function tokenize($code, $filename = null); } diff --git a/lib/Twig/LoaderInterface.php b/lib/Twig/LoaderInterface.php index 9c86124..c4e9d96 100644 --- a/lib/Twig/LoaderInterface.php +++ b/lib/Twig/LoaderInterface.php @@ -24,7 +24,7 @@ interface Twig_LoaderInterface * * @return string The template source code */ - public function getSource($name); + function getSource($name); /** * Gets the cache key to use for the cache for a given template name. @@ -33,7 +33,7 @@ interface Twig_LoaderInterface * * @return string The cache key */ - public function getCacheKey($name); + function getCacheKey($name); /** * Returns true if the template is still fresh. @@ -41,5 +41,5 @@ interface Twig_LoaderInterface * @param string $name The template name * @param timestamp $time The last modification time of the cached template */ - public function isFresh($name, $time); + function isFresh($name, $time); } diff --git a/lib/Twig/NodeInterface.php b/lib/Twig/NodeInterface.php index e6803b9..7e5626c 100644 --- a/lib/Twig/NodeInterface.php +++ b/lib/Twig/NodeInterface.php @@ -22,9 +22,9 @@ interface Twig_NodeInterface * * @param Twig_Compiler A Twig_Compiler instance */ - public function compile($compiler); + function compile($compiler); - public function getLine(); + function getLine(); - public function getNodeTag(); + function getNodeTag(); } diff --git a/lib/Twig/NodeVisitorInterface.php b/lib/Twig/NodeVisitorInterface.php index 00921b7..c73aca5 100644 --- a/lib/Twig/NodeVisitorInterface.php +++ b/lib/Twig/NodeVisitorInterface.php @@ -25,7 +25,7 @@ interface Twig_NodeVisitorInterface * * @param Twig_NodeInterface The modified node */ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env); + function enterNode(Twig_NodeInterface $node, Twig_Environment $env); /** * Called after child nodes are visited. @@ -35,7 +35,7 @@ interface Twig_NodeVisitorInterface * * @param Twig_NodeInterface The modified node */ - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); + function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); /** * Returns the priority for this visitor. @@ -44,5 +44,5 @@ interface Twig_NodeVisitorInterface * * @return integer The priority level */ - public function getPriority(); + function getPriority(); } diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index 7307386..08bca6f 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -9,6 +9,13 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Default parser implementation. + * + * @package twig + * @author Fabien Potencier + */ class Twig_Parser implements Twig_ParserInterface { protected $stream; @@ -23,6 +30,11 @@ class Twig_Parser implements Twig_ParserInterface protected $reservedMacroNames; protected $importedFunctions; + /** + * Constructor. + * + * @param Twig_Environment $env A Twig_Environment instance + */ public function __construct(Twig_Environment $env) { $this->env = $env; diff --git a/lib/Twig/ParserInterface.php b/lib/Twig/ParserInterface.php index f9e5aef..30cabc0 100644 --- a/lib/Twig/ParserInterface.php +++ b/lib/Twig/ParserInterface.php @@ -12,8 +12,8 @@ /** * Interface implemented by parser classes. * - * @package twig - * @author Fabien Potencier + * @package twig + * @author Fabien Potencier */ interface Twig_ParserInterface { @@ -24,5 +24,5 @@ interface Twig_ParserInterface * * @return Twig_Node_Module A node tree */ - public function parse(Twig_TokenStream $code); + function parse(Twig_TokenStream $code); } diff --git a/lib/Twig/Sandbox/SecurityPolicyInterface.php b/lib/Twig/Sandbox/SecurityPolicyInterface.php index 2d5db86..2a771c4 100644 --- a/lib/Twig/Sandbox/SecurityPolicyInterface.php +++ b/lib/Twig/Sandbox/SecurityPolicyInterface.php @@ -17,9 +17,9 @@ */ interface Twig_Sandbox_SecurityPolicyInterface { - public function checkSecurity($tags, $filters, $functions); + function checkSecurity($tags, $filters, $functions); - public function checkMethodAllowed($obj, $method); + function checkMethodAllowed($obj, $method); - public function checkPropertyAllowed($obj, $method); + function checkPropertyAllowed($obj, $method); } diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 87b29f4..2fdd88e 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -9,6 +9,13 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Default base class for compiled templates. + * + * @package twig + * @author Fabien Potencier + */ abstract class Twig_Template implements Twig_TemplateInterface { static protected $cache = array(); @@ -16,27 +23,54 @@ abstract class Twig_Template implements Twig_TemplateInterface protected $env; protected $blocks; + /** + * Constructor. + * + * @param Twig_Environment $env A Twig_Environment instance + */ public function __construct(Twig_Environment $env) { $this->env = $env; $this->blocks = array(); } + /** + * Returns the template name. + * + * @return string The template name + */ public function getTemplateName() { return null; } + /** + * Returns the Twig environment. + * + * @return Twig_Environment The Twig environment + */ public function getEnvironment() { return $this->env; } + /** + * Returns the parent template. + * + * @return Twig_TemplateInterface|false The parent template or false if there is no parent + */ public function getParent(array $context) { return false; } + /** + * Displays a parent block. + * + * @param string $name The block name to display from the parent + * @param array $context The context + * @param array $blocks The current set of blocks + */ public function displayParentBlock($name, array $context, array $blocks = array()) { if (false !== $parent = $this->getParent($context)) { @@ -46,6 +80,13 @@ abstract class Twig_Template implements Twig_TemplateInterface } } + /** + * Displays a block. + * + * @param string $name The block name to display + * @param array $context The context + * @param array $blocks The current set of blocks + */ public function displayBlock($name, array $context, array $blocks = array()) { if (isset($blocks[$name])) { @@ -59,6 +100,15 @@ abstract class Twig_Template implements Twig_TemplateInterface } } + /** + * Renders a parent block. + * + * @param string $name The block name to render from the parent + * @param array $context The context + * @param array $blocks The current set of blocks + * + * @return string The rendered block + */ public function renderParentBlock($name, array $context, array $blocks = array()) { ob_start(); @@ -67,6 +117,15 @@ abstract class Twig_Template implements Twig_TemplateInterface return new Twig_Markup(ob_get_clean()); } + /** + * Renders a block. + * + * @param string $name The block name to render + * @param array $context The context + * @param array $blocks The current set of blocks + * + * @return string The rendered block + */ public function renderBlock($name, array $context, array $blocks = array()) { ob_start(); @@ -75,11 +134,23 @@ abstract class Twig_Template implements Twig_TemplateInterface return new Twig_Markup(ob_get_clean()); } + /** + * Returns whether a block exists or not. + * + * @param string $name The block name + * + * @return Boolean true if the block exists, false otherwise + */ public function hasBlock($name) { return isset($this->blocks[$name]); } + /** + * Returns all block names. + * + * @return array An array of block names + */ public function getBlockNames() { return array_keys($this->blocks); @@ -106,6 +177,17 @@ abstract class Twig_Template implements Twig_TemplateInterface return ob_get_clean(); } + /** + * Returns a variable from the context. + * + * @param array $context The context + * @param string $item The variable to return from the context + * @param integer $line The line where the variable is get + * + * @param mixed The variable value in the context + * + * @throws Twig_Error_Runtime if the variable does not exist + */ protected function getContext($context, $item, $line = -1) { if (!array_key_exists($item, $context)) { @@ -115,6 +197,15 @@ abstract class Twig_Template implements Twig_TemplateInterface return $context[$item]; } + /** + * Returns the attribute value for a given array/object. + * + * @param mixed $object The object or array from where to get the item + * @param mixed $item The item to get from the array or object + * @param array $arguments An array of arguments to pass if the item is an object method + * @param integer $type The type of attribute (@see Twig_Node_Expression_GetAttr) + * @param Boolean $noStrictCheck Whether to throw an exception if the item does not exist ot not + */ protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_Node_Expression_GetAttr::TYPE_ANY, $noStrictCheck = false) { // array diff --git a/lib/Twig/TemplateInterface.php b/lib/Twig/TemplateInterface.php index 0f74ffc..033eb7a 100644 --- a/lib/Twig/TemplateInterface.php +++ b/lib/Twig/TemplateInterface.php @@ -8,6 +8,13 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Interface implemented by all compiled templates. + * + * @package twig + * @author Fabien Potencier + */ interface Twig_TemplateInterface { /** @@ -17,19 +24,19 @@ interface Twig_TemplateInterface * * @return string The rendered template */ - public function render(array $context); + function render(array $context); /** * Displays the template with the given context. * * @param array $context An array of parameters to pass to the template */ - public function display(array $context); + function display(array $context); /** * Returns the bound environment for this template. * * @return Twig_Environment The current environment */ - public function getEnvironment(); + function getEnvironment(); } diff --git a/lib/Twig/TestInterface.php b/lib/Twig/TestInterface.php index cc179d9..691ba14 100644 --- a/lib/Twig/TestInterface.php +++ b/lib/Twig/TestInterface.php @@ -17,5 +17,10 @@ */ interface Twig_TestInterface { - public function compile(); + /** + * Compiles a test. + * + * @return string The PHP code for the test + */ + function compile(); } diff --git a/lib/Twig/Token.php b/lib/Twig/Token.php index 3130c88..93156bb 100644 --- a/lib/Twig/Token.php +++ b/lib/Twig/Token.php @@ -9,6 +9,13 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Represents a Token. + * + * @package twig + * @author Fabien Potencier + */ class Twig_Token { protected $value; @@ -27,6 +34,13 @@ class Twig_Token const OPERATOR_TYPE = 8; const PUNCTUATION_TYPE = 9; + /** + * Constructor. + * + * @param integer $type The type of the token + * @param string $value The token value + * @param integer $lineno The line positionl in the source + */ public function __construct($type, $value, $lineno) { $this->type = $type; @@ -34,17 +48,30 @@ class Twig_Token $this->lineno = $lineno; } + /** + * Returns a string representation of the token. + * + * @return string A string representation of the token + */ public function __toString() { return sprintf('%s(%s)', self::typeToString($this->type, true), $this->value); } /** - * Test the current token for a type. The first argument is the type + * Tests the current token for a type. + * + * The first argument is the type * of the token (if not given Twig_Token::NAME_TYPE), the second the * value of the token (if not given value is not checked). - * the token value can be an array if multiple checks should be + * + * The token value can be an array if multiple checks should be * performed. + * + * @param integer $type The type to test + * @param array|string|null $values The token value + * + * @return Boolean */ public function test($type, $values = null) { @@ -60,21 +87,44 @@ class Twig_Token ); } + /** + * Gets the line. + * + * @return integer The source line + */ public function getLine() { return $this->lineno; } + /** + * Gets the token type. + * + * @return integer The token type + */ public function getType() { return $this->type; } + /** + * Gets the token value. + * + * @return string The token value + */ public function getValue() { return $this->value; } + /** + * Returns the constant representation (internal) of a given type. + * + * @param integer $type The type as an integer + * @param Boolean $short Whether to return a short representation or not + * + * @return string The string representation + */ static public function typeToString($type, $short = false) { switch ($type) { @@ -118,6 +168,14 @@ class Twig_Token return $short ? $name : 'Twig_Token::'.$name; } + /** + * Returns the english representation of a given type. + * + * @param integer $type The type as an integer + * @param Boolean $short Whether to return a short representation or not + * + * @return string The string representation + */ static public function typeToEnglish($type) { switch ($type) { diff --git a/lib/Twig/TokenParser.php b/lib/Twig/TokenParser.php index a18537f..4245a08 100644 --- a/lib/Twig/TokenParser.php +++ b/lib/Twig/TokenParser.php @@ -8,10 +8,22 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Base class for all token parsers. + * + * @package twig + * @author Fabien Potencier + */ abstract class Twig_TokenParser implements Twig_TokenParserInterface { protected $parser; + /** + * Sets the parser associated with this token parser + * + * @param $parser A Twig_Parser instance + */ public function setParser(Twig_Parser $parser) { $this->parser = $parser; diff --git a/lib/Twig/TokenParserBroker.php b/lib/Twig/TokenParserBroker.php index 163620d..9434c7b 100644 --- a/lib/Twig/TokenParserBroker.php +++ b/lib/Twig/TokenParserBroker.php @@ -13,8 +13,8 @@ /** * Default implementation of a token parser broker. * - * @package twig - * @author Arnaud Le Blanc + * @package twig + * @author Arnaud Le Blanc */ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface { @@ -23,7 +23,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface protected $brokers = array(); /** - * Constructor + * Constructor. * * @param array|Iterable $parsers An Iterable of Twig_TokenParserInterface instances * @param array|Iterable $brokers An Iterable of Twig_TokenParserBrokerInterface instances @@ -45,7 +45,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } /** - * Adds a TokenParser + * Adds a TokenParser. * * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance */ @@ -55,7 +55,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } /** - * Adds a TokenParserBroker + * Adds a TokenParserBroker. * * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance */ @@ -65,11 +65,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } /** - * Get a suitable TokenParser for $tag + * Gets a suitable TokenParser for a tag. * * First looks in parsers, then in brokers. * * @param string $tag A tag name + * * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found */ public function getTokenParser($tag) diff --git a/lib/Twig/TokenParserBrokerInterface.php b/lib/Twig/TokenParserBrokerInterface.php index fb8f482..09fee54 100644 --- a/lib/Twig/TokenParserBrokerInterface.php +++ b/lib/Twig/TokenParserBrokerInterface.php @@ -15,28 +15,29 @@ * * Token parser brokers allows to implement custom logic in the process of resolving a token parser for a given tag name. * - * @package twig - * @author Arnaud Le Blanc + * @package twig + * @author Arnaud Le Blanc */ interface Twig_TokenParserBrokerInterface { /** - * Get a TokenParser suitable for $tag + * Gets a TokenParser suitable for a tag. + * + * @param string $tag A tag name * - * @param string $tag A tag name * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found */ function getTokenParser($tag); /** - * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knowns of + * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knowns of. * * @param Twig_ParserInterface $parser A Twig_ParserInterface interface */ function setParser(Twig_ParserInterface $parser); /** - * Get the Twig_ParserInterface + * Gets the Twig_ParserInterface. * * @return null|Twig_ParserInterface A Twig_ParserInterface instance of null */ diff --git a/lib/Twig/TokenParserInterface.php b/lib/Twig/TokenParserInterface.php index 8bcc691..142adec 100644 --- a/lib/Twig/TokenParserInterface.php +++ b/lib/Twig/TokenParserInterface.php @@ -8,9 +8,21 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Interface implemented by token parsers. + * + * @package twig + * @author Fabien Potencier + */ interface Twig_TokenParserInterface { - public function setParser(Twig_Parser $parser); + /** + * Sets the parser associated with this token parser + * + * @param $parser A Twig_Parser instance + */ + function setParser(Twig_Parser $parser); /** * Parses a token and returns a node. @@ -19,12 +31,12 @@ interface Twig_TokenParserInterface * * @return Twig_NodeInterface A Twig_NodeInterface instance */ - public function parse(Twig_Token $token); + function parse(Twig_Token $token); /** * Gets the tag name associated with this token parser. * * @param string The tag name */ - public function getTag(); + function getTag(); } diff --git a/lib/Twig/TokenStream.php b/lib/Twig/TokenStream.php index 187c00c..0a11e5b 100644 --- a/lib/Twig/TokenStream.php +++ b/lib/Twig/TokenStream.php @@ -9,6 +9,13 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + +/** + * Represents a token stream. + * + * @package twig + * @author Fabien Potencier + */ class Twig_TokenStream { protected $tokens; @@ -16,8 +23,10 @@ class Twig_TokenStream protected $filename; /** - * @param array $tokens Array of tokens - * @param string $filename Name which $tokens are associated with + * Constructor. + * + * @param array $tokens An array of tokens + * @param string $filename The name of the filename which tokens are associated with */ public function __construct(array $tokens, $filename = null) { @@ -26,6 +35,11 @@ class Twig_TokenStream $this->filename = $filename; } + /** + * Returns a string representation of the token stream. + * + * @return string + */ public function __toString() { return implode("\n", $this->tokens); @@ -46,7 +60,7 @@ class Twig_TokenStream } /** - * test()s a token and returns it or throws a syntax error. + * Tests a token and returns it or throws a syntax error. * * @return Twig_Token */ @@ -83,7 +97,7 @@ class Twig_TokenStream } /** - * test() current token + * Tests the current token * * @return bool */ -- 1.7.2.5