fixed @throws phpdoc tag

This commit is contained in:
Pascal Borreli 2010-04-04 17:11:32 +00:00 committed by Fabien Potencier
parent dd7817ae62
commit 12690a8e92
66 changed files with 280 additions and 18 deletions

View File

@ -99,6 +99,8 @@ class Application
* @param OutputInterface $output An Output instance * @param OutputInterface $output An Output instance
* *
* @return integer 0 if everything went fine, or an error code * @return integer 0 if everything went fine, or an error code
*
* @throws \Exception When doRun returns Exception
*/ */
public function run(InputInterface $input = null, OutputInterface $output = null) public function run(InputInterface $input = null, OutputInterface $output = null)
{ {
@ -396,6 +398,8 @@ class Application
* @param string $name The command name or alias * @param string $name The command name or alias
* *
* @return Command A Command object * @return Command A Command object
*
* @throws \InvalidArgumentException When command name given does not exist
*/ */
public function getCommand($name) public function getCommand($name)
{ {
@ -456,6 +460,8 @@ class Application
* Finds a registered namespace by a name or an abbreviation. * Finds a registered namespace by a name or an abbreviation.
* *
* @return string A registered namespace * @return string A registered namespace
*
* @throws \InvalidArgumentException When namespace is incorrect or ambiguous
*/ */
public function findNamespace($namespace) public function findNamespace($namespace)
{ {
@ -483,6 +489,8 @@ class Application
* @param string $name A command name or a command alias * @param string $name A command name or a command alias
* *
* @return Command A Command instance * @return Command A Command instance
*
* @throws \InvalidArgumentException When command name is incorrect or ambiguous
*/ */
public function findCommand($name) public function findCommand($name)
{ {

View File

@ -43,6 +43,8 @@ class Command
* Constructor. * Constructor.
* *
* @param string $name The name of the command * @param string $name The name of the command
*
* @throws \LogicException When the command name is empty
*/ */
public function __construct($name = null) public function __construct($name = null)
{ {
@ -88,6 +90,8 @@ class Command
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return integer 0 if everything went fine, or an error code * @return integer 0 if everything went fine, or an error code
*
* @throws \LogicException When this abstrass class is not implemented
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -273,6 +277,8 @@ class Command
* @param string $name The command name * @param string $name The command name
* *
* @return Command The current instance * @return Command The current instance
*
* @throws \InvalidArgumentException When command name given is empty
*/ */
public function setName($name) public function setName($name)
{ {

View File

@ -82,6 +82,8 @@ class DialogHelper extends Helper
* @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite) * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
* *
* @return mixed * @return mixed
*
* @throws \Exception When any of the validator returns an error
*/ */
public function askAndValidate(OutputInterface $output, $question, \Closure $validator, $attempts = false) public function askAndValidate(OutputInterface $output, $question, \Closure $validator, $attempts = false)
{ {

View File

@ -118,6 +118,8 @@ class ArgvInput extends Input
* Parses a short option set. * Parses a short option set.
* *
* @param string $token The current token * @param string $token The current token
*
* @throws \RuntimeException When option given doesn't exist
*/ */
protected function parseShortOptionSet($name) protected function parseShortOptionSet($name)
{ {
@ -166,6 +168,8 @@ class ArgvInput extends Input
* Parses an argument. * Parses an argument.
* *
* @param string $token The current token * @param string $token The current token
*
* @throws \RuntimeException When too many arguments are given
*/ */
protected function parseArgument($token) protected function parseArgument($token)
{ {
@ -182,6 +186,8 @@ class ArgvInput extends Input
* *
* @param string $shortcut The short option key * @param string $shortcut The short option key
* @param mixed $value The value for the option * @param mixed $value The value for the option
*
* @throws \RuntimeException When option given doesn't exist
*/ */
protected function addShortOption($shortcut, $value) protected function addShortOption($shortcut, $value)
{ {
@ -198,6 +204,8 @@ class ArgvInput extends Input
* *
* @param string $name The long option key * @param string $name The long option key
* @param mixed $value The value for the option * @param mixed $value The value for the option
*
* @throws \RuntimeException When option given doesn't exist
*/ */
protected function addLongOption($name, $value) protected function addLongOption($name, $value)
{ {

View File

@ -117,6 +117,8 @@ class ArrayInput extends Input
* *
* @param string $shortcut The short option key * @param string $shortcut The short option key
* @param mixed $value The value for the option * @param mixed $value The value for the option
*
* @throws \RuntimeException When option given doesn't exist
*/ */
protected function addShortOption($shortcut, $value) protected function addShortOption($shortcut, $value)
{ {
@ -133,6 +135,8 @@ class ArrayInput extends Input
* *
* @param string $name The long option key * @param string $name The long option key
* @param mixed $value The value for the option * @param mixed $value The value for the option
*
* @throws \RuntimeException When option given doesn't exist
*/ */
protected function addLongOption($name, $value) protected function addLongOption($name, $value)
{ {
@ -161,6 +165,8 @@ class ArrayInput extends Input
* *
* @param string $name The argument name * @param string $name The argument name
* @param mixed $value The value for the argument * @param mixed $value The value for the argument
*
* @throws \RuntimeException When option given doesn't exist
*/ */
protected function addArgument($name, $value) protected function addArgument($name, $value)
{ {

View File

@ -68,6 +68,9 @@ abstract class Input implements InputInterface
*/ */
abstract protected function parse(); abstract protected function parse();
/**
* @throws \RuntimeException When not enough arguments are given
*/
public function validate() public function validate()
{ {
if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) if (count($this->arguments) < $this->definition->getArgumentRequiredCount())
@ -102,6 +105,8 @@ abstract class Input implements InputInterface
* @param string $name The argument name * @param string $name The argument name
* *
* @return mixed The argument value * @return mixed The argument value
*
* @throws \InvalidArgumentException When argument given doesn't exist
*/ */
public function getArgument($name) public function getArgument($name)
{ {
@ -118,6 +123,8 @@ abstract class Input implements InputInterface
* *
* @param string $name The argument name * @param string $name The argument name
* @param string $value The argument value * @param string $value The argument value
*
* @throws \InvalidArgumentException When argument given doesn't exist
*/ */
public function setArgument($name, $value) public function setArgument($name, $value)
{ {
@ -157,6 +164,8 @@ abstract class Input implements InputInterface
* @param string $name The option name * @param string $name The option name
* *
* @return mixed The option value * @return mixed The option value
*
* @throws \InvalidArgumentException When option given doesn't exist
*/ */
public function getOption($name) public function getOption($name)
{ {
@ -173,6 +182,8 @@ abstract class Input implements InputInterface
* *
* @param string $name The option name * @param string $name The option name
* @param string $value The option value * @param string $value The option value
*
* @throws \InvalidArgumentException When option given doesn't exist
*/ */
public function setOption($name, $value) public function setOption($name, $value)
{ {

View File

@ -36,6 +36,8 @@ class InputArgument
* @param integer $mode The argument mode: self::REQUIRED or self::OPTIONAL * @param integer $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param string $description A description text * @param string $description A description text
* @param mixed $default The default value (for self::OPTIONAL mode only) * @param mixed $default The default value (for self::OPTIONAL mode only)
*
* @throws \InvalidArgumentException When argument mode is not valid
*/ */
public function __construct($name, $mode = null, $description = '', $default = null) public function __construct($name, $mode = null, $description = '', $default = null)
{ {
@ -89,6 +91,8 @@ class InputArgument
* Sets the default value. * Sets the default value.
* *
* @param mixed $default The default value * @param mixed $default The default value
*
* @throws \LogicException When incorrect default value is given
*/ */
public function setDefault($default = null) public function setDefault($default = null)
{ {

View File

@ -97,6 +97,8 @@ class InputDefinition
* Add an InputArgument object. * Add an InputArgument object.
* *
* @param InputArgument $argument An InputArgument object * @param InputArgument $argument An InputArgument object
*
* @throws \LogicException When incorrect argument is given
*/ */
public function addArgument(InputArgument $argument) public function addArgument(InputArgument $argument)
{ {
@ -138,6 +140,8 @@ class InputDefinition
* @param string|integer $name The InputArgument name or position * @param string|integer $name The InputArgument name or position
* *
* @return InputArgument An InputArgument object * @return InputArgument An InputArgument object
*
* @throws \InvalidArgumentException When argument given doesn't exist
*/ */
public function getArgument($name) public function getArgument($name)
{ {
@ -240,6 +244,8 @@ class InputDefinition
* Add an InputOption object. * Add an InputOption object.
* *
* @param InputOption $option An InputOption object * @param InputOption $option An InputOption object
*
* @throws \LogicException When option given already exist
*/ */
public function addOption(InputOption $option) public function addOption(InputOption $option)
{ {
@ -342,6 +348,8 @@ class InputDefinition
* @param string $shortcut The shortcut * @param string $shortcut The shortcut
* *
* @return string The InputOption name * @return string The InputOption name
*
* @throws \InvalidArgumentException When option given does not exist
*/ */
protected function shortcutToName($shortcut) protected function shortcutToName($shortcut)
{ {

View File

@ -39,6 +39,8 @@ class InputOption
* @param integer $mode The option mode: self::PARAMETER_REQUIRED, self::PARAMETER_NONE or self::PARAMETER_OPTIONAL * @param integer $mode The option mode: self::PARAMETER_REQUIRED, self::PARAMETER_NONE or self::PARAMETER_OPTIONAL
* @param string $description A description text * @param string $description A description text
* @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE) * @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE)
*
* @throws \InvalidArgumentException If option mode is invalid or incompatible
*/ */
public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
{ {

View File

@ -40,6 +40,9 @@ class StringInput extends ArgvInput
$this->tokens = $this->tokenize($input); $this->tokens = $this->tokenize($input);
} }
/**
* @throws \InvalidArgumentException When unable to parse input (should never happen)
*/
protected function tokenize($input) protected function tokenize($input)
{ {
$input = preg_replace('/(\r\n|\r|\n|\t)/', ' ', $input); $input = preg_replace('/(\r\n|\r|\n|\t)/', ' ', $input);

View File

@ -127,6 +127,8 @@ abstract class Output implements OutputInterface
* @param string|array $messages The message as an array of lines of a single string * @param string|array $messages The message as an array of lines of a single string
* @param Boolean $newline Whether to add a newline or not * @param Boolean $newline Whether to add a newline or not
* @param integer $type The type of output * @param integer $type The type of output
*
* @throws \InvalidArgumentException When unknown output type is given
*/ */
public function write($messages, $newline = false, $type = 0) public function write($messages, $newline = false, $type = 0)
{ {
@ -182,6 +184,9 @@ abstract class Output implements OutputInterface
return preg_replace_callback('#</([a-z][a-z0-9\-_]+)>#i', array($this, 'replaceEndStyle'), $message); return preg_replace_callback('#</([a-z][a-z0-9\-_]+)>#i', array($this, 'replaceEndStyle'), $message);
} }
/**
* @throws \InvalidArgumentException When style is unknown
*/
protected function replaceStartStyle($match) protected function replaceStartStyle($match)
{ {
if (!$this->decorated) if (!$this->decorated)

View File

@ -36,6 +36,8 @@ class StreamOutput extends Output
* @param mixed $stream A stream resource * @param mixed $stream A stream resource
* @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE) * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE)
* @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)
*
* @throws \InvalidArgumentException When first argument is not a real stream
*/ */
public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null) public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null)
{ {
@ -69,6 +71,8 @@ class StreamOutput extends Output
* *
* @param string $message A message to write to the output * @param string $message A message to write to the output
* @param Boolean $newline Whether to add a newline or not * @param Boolean $newline Whether to add a newline or not
*
* @throws \RuntimeException When unable to write output (should never happen)
*/ */
public function doWrite($message, $newline) public function doWrite($message, $newline)
{ {

View File

@ -38,6 +38,8 @@ class Shell
* a \RuntimeException exception is thrown. * a \RuntimeException exception is thrown.
* *
* @param Application $application An application instance * @param Application $application An application instance
*
* @throws \RuntimeException When Readline extension is not enabled
*/ */
public function __construct(Application $application) public function __construct(Application $application)
{ {

View File

@ -53,6 +53,9 @@ class AttribNode implements NodeInterface
} }
} }
/**
* @throws SyntaxError When unknown operator is found
*/
public function toXpath() public function toXpath()
{ {
$path = $this->selector->toXpath(); $path = $this->selector->toXpath();

View File

@ -50,6 +50,9 @@ class CombinedSelectorNode implements NodeInterface
return sprintf('%s[%s %s %s]', __CLASS__, $this->selector, $comb, $this->subselector); return sprintf('%s[%s %s %s]', __CLASS__, $this->selector, $comb, $this->subselector);
} }
/**
* @throws SyntaxError When unknown combinator is found
*/
public function toXpath() public function toXpath()
{ {
if (!isset(self::$_method_mapping[$this->combinator])) if (!isset(self::$_method_mapping[$this->combinator]))

View File

@ -46,6 +46,9 @@ class FunctionNode implements NodeInterface
return sprintf('%s[%s%s%s(%s)]', __CLASS__, $this->selector, $this->type, $this->name, $this->expr); return sprintf('%s[%s%s%s(%s)]', __CLASS__, $this->selector, $this->type, $this->name, $this->expr);
} }
/**
* @throws SyntaxError When unsupported or unknown pseudo-class is found
*/
public function toXpath() public function toXpath()
{ {
$sel_path = $this->selector->toXpath(); $sel_path = $this->selector->toXpath();

View File

@ -35,6 +35,9 @@ class PseudoNode implements NodeInterface
protected $type; protected $type;
protected $ident; protected $ident;
/**
* @throws SyntaxError When incorrect PseudoNode type is given
*/
public function __construct($element, $type, $ident) public function __construct($element, $type, $ident)
{ {
$this->element = $element; $this->element = $element;
@ -53,6 +56,9 @@ class PseudoNode implements NodeInterface
return sprintf('%s[%s%s%s]', __CLASS__, $this->element, $this->type, $this->ident); return sprintf('%s[%s%s%s]', __CLASS__, $this->element, $this->type, $this->ident);
} }
/**
* @throws SyntaxError When unsupported or unknown pseudo-class is found
*/
public function toXpath() public function toXpath()
{ {
$el_xpath = $this->element->toXpath(); $el_xpath = $this->element->toXpath();
@ -78,6 +84,9 @@ class PseudoNode implements NodeInterface
return $xpath; return $xpath;
} }
/**
* @throws SyntaxError If this element is the root element
*/
protected function xpath_root($xpath) protected function xpath_root($xpath)
{ {
// if this element is the root element // if this element is the root element
@ -114,6 +123,9 @@ class PseudoNode implements NodeInterface
return $xpath; return $xpath;
} }
/**
* @throws SyntaxError Because *:last-of-type is not implemented
*/
protected function xpath_last_of_type($xpath) protected function xpath_last_of_type($xpath)
{ {
if ($xpath->getElement() == '*') if ($xpath->getElement() == '*')
@ -135,6 +147,9 @@ class PseudoNode implements NodeInterface
return $xpath; return $xpath;
} }
/**
* @throws SyntaxError Because *:only-of-type is not implemented
*/
protected function xpath_only_of_type($xpath) protected function xpath_only_of_type($xpath)
{ {
if ($xpath->getElement() == '*') if ($xpath->getElement() == '*')

View File

@ -26,6 +26,9 @@ namespace Symfony\Components\CssSelector;
*/ */
class Parser class Parser
{ {
/**
* @throws SyntaxError When got None for xpath expression
*/
static public function cssToXpath($cssExpr, $prefix = 'descendant-or-self::') static public function cssToXpath($cssExpr, $prefix = 'descendant-or-self::')
{ {
if (is_string($cssExpr)) if (is_string($cssExpr))
@ -66,6 +69,9 @@ class Parser
return (string) $expr; return (string) $expr;
} }
/**
* @throws \Exception When tokenizer throws it while parsing
*/
public function parse($string) public function parse($string)
{ {
$tokenizer = new Tokenizer(); $tokenizer = new Tokenizer();
@ -108,6 +114,9 @@ class Parser
return new Node\OrNode($result); return new Node\OrNode($result);
} }
/**
* @throws SyntaxError When expected selector but got something else
*/
protected function parseSelector($stream) protected function parseSelector($stream)
{ {
$result = $this->parseSimpleSelector($stream); $result = $this->parseSimpleSelector($stream);
@ -141,6 +150,9 @@ class Parser
return $result; return $result;
} }
/**
* @throws SyntaxError When expected symbol but got something else
*/
protected function parseSimpleSelector($stream) protected function parseSimpleSelector($stream)
{ {
$peek = $stream->peek(); $peek = $stream->peek();
@ -269,6 +281,9 @@ class Parser
return $result; return $result;
} }
/**
* @throws SyntaxError When encountered unexpected selector
*/
protected function parseAttrib($selector, $stream) protected function parseAttrib($selector, $stream)
{ {
$attrib = $stream->next(); $attrib = $stream->next();

View File

@ -108,6 +108,9 @@ class Tokenizer
} }
} }
/**
* @throws SyntaxError When expected closing is not found
*/
protected function tokenizeEscapedString($s, $pos) protected function tokenizeEscapedString($s, $pos)
{ {
$quote = $s[$pos]; $quote = $s[$pos];
@ -139,6 +142,9 @@ class Tokenizer
} }
} }
/**
* @throws SyntaxError When invalid escape sequence is found
*/
protected function unescapeStringLiteral($literal) protected function unescapeStringLiteral($literal)
{ {
return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal) return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal)
@ -158,6 +164,9 @@ class Tokenizer
}, $literal); }, $literal);
} }
/**
* @throws SyntaxError When Unexpected symbol is found
*/
protected function tokenizeSymbol($s, $pos) protected function tokenizeSymbol($s, $pos)
{ {
$start = $pos; $start = $pos;

View File

@ -335,6 +335,8 @@ class Builder extends Container implements AnnotatedContainerInterface
* @param string $id The service identifier * @param string $id The service identifier
* *
* @return object The service described by the service definition * @return object The service described by the service definition
*
* @throws \InvalidArgumentException When configure callable is not callable
*/ */
protected function createService(Definition $definition, $id) protected function createService(Definition $definition, $id)
{ {

View File

@ -317,6 +317,8 @@ class Container implements ContainerInterface, \ArrayAccess
* Removes a service by identifier. * Removes a service by identifier.
* *
* @param string The service identifier * @param string The service identifier
*
* @throws LogicException When trying to unset a service
*/ */
public function __unset($id) public function __unset($id)
{ {
@ -330,6 +332,8 @@ class Container implements ContainerInterface, \ArrayAccess
* @param array $arguments The method arguments * @param array $arguments The method arguments
* *
* @return mixed * @return mixed
*
* @throws \RuntimeException When calling to an undefined method
*/ */
public function __call($method, $arguments) public function __call($method, $arguments)
{ {

View File

@ -40,6 +40,8 @@ abstract class Dumper implements DumperInterface
* @param array $options An array of options * @param array $options An array of options
* *
* @return string The representation of the service container * @return string The representation of the service container
*
* @throws \LogicException When this abstrass class is not implemented
*/ */
public function dump(array $options = array()) public function dump(array $options = array())
{ {

View File

@ -227,6 +227,9 @@ EOF;
return $args; return $args;
} }
/**
* @throws \RuntimeException When trying to dump object or ressource
*/
static public function phpToXml($value) static public function phpToXml($value)
{ {
switch (true) switch (true)

View File

@ -143,6 +143,9 @@ class YamlDumper extends Dumper
return Yaml::dump(array('parameters' => $this->prepareParameters($this->container->getParameters())), 2); return Yaml::dump(array('parameters' => $this->prepareParameters($this->container->getParameters())), 2);
} }
/**
* @throws \RuntimeException When trying to dump object or ressource
*/
protected function dumpValue($value) protected function dumpValue($value)
{ {
if (is_array($value)) if (is_array($value))

View File

@ -37,6 +37,9 @@ abstract class FileLoader extends Loader
$this->paths = $paths; $this->paths = $paths;
} }
/**
* @throws \InvalidArgumentException When provided file does not exist
*/
protected function findFile($file) protected function findFile($file)
{ {
$path = $this->getAbsolutePath($file); $path = $this->getAbsolutePath($file);

View File

@ -29,6 +29,8 @@ class IniFileLoader extends FileLoader
* @param string $file An INI file path * @param string $file An INI file path
* *
* @return BuilderConfiguration A BuilderConfiguration instance * @return BuilderConfiguration A BuilderConfiguration instance
*
* @throws \InvalidArgumentException When ini file is not valid
*/ */
public function load($file) public function load($file)
{ {

View File

@ -40,6 +40,8 @@ abstract class LoaderExtension implements LoaderExtensionInterface
* @param array An array of configuration values * @param array An array of configuration values
* *
* @return BuilderConfiguration A BuilderConfiguration instance * @return BuilderConfiguration A BuilderConfiguration instance
*
* @throws \InvalidArgumentException When provided tag is not defined in this extension
*/ */
public function load($tag, array $config) public function load($tag, array $config)
{ {

View File

@ -197,6 +197,9 @@ class XmlFileLoader extends FileLoader
$configuration->setDefinition($id, $definition); $configuration->setDefinition($id, $definition);
} }
/**
* @throws \InvalidArgumentException When loading of XML file returns error
*/
protected function parseFile($file) protected function parseFile($file)
{ {
$dom = new \DOMDocument(); $dom = new \DOMDocument();
@ -249,6 +252,10 @@ class XmlFileLoader extends FileLoader
$this->validateExtensions($dom, $file); $this->validateExtensions($dom, $file);
} }
/**
* @throws \RuntimeException When extension references a non-existent XSD file
* @throws \InvalidArgumentException When xml doesn't validate its xsd schema
*/
protected function validateSchema($dom, $file) protected function validateSchema($dom, $file)
{ {
$schemaLocations = array('http://www.symfony-project.org/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd')); $schemaLocations = array('http://www.symfony-project.org/schema/dic/services' => str_replace('\\', '/', __DIR__.'/schema/dic/services/services-1.0.xsd'));
@ -299,6 +306,9 @@ EOF
libxml_use_internal_errors(false); libxml_use_internal_errors(false);
} }
/**
* @throws \InvalidArgumentException When non valid tag are found or no extension are found
*/
protected function validateExtensions($dom, $file) protected function validateExtensions($dom, $file)
{ {
foreach ($dom->documentElement->childNodes as $node) foreach ($dom->documentElement->childNodes as $node)

View File

@ -196,6 +196,9 @@ class YamlFileLoader extends FileLoader
return $this->validate(Yaml::load($file), $file); return $this->validate(Yaml::load($file), $file);
} }
/**
* @throws \InvalidArgumentException When service file is not valid
*/
protected function validate($content, $file) protected function validate($content, $file)
{ {
if (null === $content) if (null === $content)

View File

@ -127,6 +127,8 @@ class Event implements \ArrayAccess
* @param string $name The parameter name * @param string $name The parameter name
* *
* @return mixed The parameter value * @return mixed The parameter value
*
* @throws \InvalidArgumentException When parameter doesn't exists for this event
*/ */
public function getParameter($name) public function getParameter($name)
{ {

View File

@ -120,7 +120,7 @@ class ArrayDecorator extends GetterDecorator implements \Iterator, \ArrayAccess,
* @param string $offset (ignored) * @param string $offset (ignored)
* @param string $value (ignored) * @param string $value (ignored)
* *
* @throws \LogicException * @throws \LogicException When trying to set values
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
@ -136,7 +136,7 @@ class ArrayDecorator extends GetterDecorator implements \Iterator, \ArrayAccess,
* *
* @param string $offset (ignored) * @param string $offset (ignored)
* *
* @throws LogicException * @throws \LogicException When trying to unset values
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)
{ {

View File

@ -131,7 +131,7 @@ class IteratorDecorator extends ObjectDecorator implements \Iterator, \Countable
* @param string $offset (ignored) * @param string $offset (ignored)
* @param string $value (ignored) * @param string $value (ignored)
* *
* @throws \LogicException * @throws \LogicException When trying to set values
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
@ -147,7 +147,7 @@ class IteratorDecorator extends ObjectDecorator implements \Iterator, \Countable
* *
* @param string $offset (ignored) * @param string $offset (ignored)
* *
* @throws \LogicException * @throws \LogicException When trying to unset values
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)
{ {

View File

@ -46,6 +46,8 @@ class RequestHandler
* @param Boolean $main Whether this is the main request or not * @param Boolean $main Whether this is the main request or not
* *
* @return ResponseInterface $response A Response instance * @return ResponseInterface $response A Response instance
*
* @throws \Exception When Exception couldn't be catch by event processing
*/ */
public function handle(RequestInterface $request, $main = true) public function handle(RequestInterface $request, $main = true)
{ {
@ -78,7 +80,8 @@ class RequestHandler
* *
* @return ResponseInterface $response A Response instance * @return ResponseInterface $response A Response instance
* *
* @throws \LogicException if one of the listener does not behave as expected * @throws \LogicException If one of the listener does not behave as expected
* @throws NotFoundHttpException When controller cannot be found
*/ */
public function handleRaw(RequestInterface $request, $main = true) public function handleRaw(RequestInterface $request, $main = true)
{ {

View File

@ -144,6 +144,8 @@ class Response implements ResponseInterface
* @param string $domain Domain name * @param string $domain Domain name
* @param bool $secure If secure * @param bool $secure If secure
* @param bool $httpOnly If uses only HTTP * @param bool $httpOnly If uses only HTTP
*
* @throws \InvalidArgumentException When cookie expire parameter is not valid
*/ */
public function setCookie($name, $value, $expire = null, $path = '/', $domain = '', $secure = false, $httpOnly = false) public function setCookie($name, $value, $expire = null, $path = '/', $domain = '', $secure = false, $httpOnly = false)
{ {
@ -192,6 +194,7 @@ class Response implements ResponseInterface
* @param string $code HTTP status code * @param string $code HTTP status code
* @param string $text HTTP status text * @param string $text HTTP status text
* *
* @throws \InvalidArgumentException When the HTTP status code is not valid
*/ */
public function setStatusCode($code, $text = null) public function setStatusCode($code, $text = null)
{ {

View File

@ -41,6 +41,8 @@ abstract class GeneratorDumper implements GeneratorDumperInterface
* @param array $options An array of options * @param array $options An array of options
* *
* @return string The representation of the routing * @return string The representation of the routing
*
* @throws \LogicException When this abstrass class is not implemented
*/ */
public function dump(array $options = array()) public function dump(array $options = array())
{ {

View File

@ -51,6 +51,8 @@ class UrlGenerator implements UrlGeneratorInterface
* @param Boolean $absolute Whether to generate an absolute URL * @param Boolean $absolute Whether to generate an absolute URL
* *
* @return string The generated URL * @return string The generated URL
*
* @throws \InvalidArgumentException When route doesn't exist
*/ */
public function generate($name, array $parameters, $absolute = false) public function generate($name, array $parameters, $absolute = false)
{ {
@ -67,6 +69,9 @@ class UrlGenerator implements UrlGeneratorInterface
return $this->doGenerate($this->cache[$name]->getVariables(), $route->getDefaults(), $route->getRequirements(), $this->cache[$name]->getTokens(), $parameters, $name, $absolute); return $this->doGenerate($this->cache[$name]->getVariables(), $route->getDefaults(), $route->getRequirements(), $this->cache[$name]->getTokens(), $parameters, $name, $absolute);
} }
/**
* @throws \InvalidArgumentException When route has some missing mandatory parameters
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute) protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute)
{ {
$defaults = array_merge($this->defaults, $defaults); $defaults = array_merge($this->defaults, $defaults);

View File

@ -37,6 +37,9 @@ abstract class FileLoader implements LoaderInterface
$this->paths = $paths; $this->paths = $paths;
} }
/**
* @throws \InvalidArgumentException When file is not found
*/
protected function findFile($file) protected function findFile($file)
{ {
$path = $this->getAbsolutePath($file); $path = $this->getAbsolutePath($file);

View File

@ -30,6 +30,8 @@ class XmlFileLoader extends FileLoader
* @param string $file A XML file path * @param string $file A XML file path
* *
* @return RouteCollection A RouteCollection instance * @return RouteCollection A RouteCollection instance
*
* @throws \InvalidArgumentException When a tag can't be parsed
*/ */
public function load($file) public function load($file)
{ {
@ -123,6 +125,9 @@ class XmlFileLoader extends FileLoader
$collection->addCollection($loader->load($importedFile), (string) $node->getAttribute('prefix')); $collection->addCollection($loader->load($importedFile), (string) $node->getAttribute('prefix'));
} }
/**
* @throws \InvalidArgumentException When loading of XML file returns error
*/
protected function loadFile($path) protected function loadFile($path)
{ {
$dom = new \DOMDocument(); $dom = new \DOMDocument();
@ -139,6 +144,9 @@ class XmlFileLoader extends FileLoader
return $dom; return $dom;
} }
/**
* @throws \InvalidArgumentException When xml doesn't validate its xsd schema
*/
protected function validate($dom, $file) protected function validate($dom, $file)
{ {
libxml_use_internal_errors(true); libxml_use_internal_errors(true);

View File

@ -31,6 +31,8 @@ class YamlFileLoader extends FileLoader
* @param string $file A Yaml file path * @param string $file A Yaml file path
* *
* @return RouteCollection A RouteCollection instance * @return RouteCollection A RouteCollection instance
*
* @throws \InvalidArgumentException When route can't be parsed
*/ */
public function load($file) public function load($file)
{ {
@ -60,6 +62,9 @@ class YamlFileLoader extends FileLoader
return $collection; return $collection;
} }
/**
* @throws \InvalidArgumentException When coonfig pattern is not defined for the given route
*/
protected function parseRoute(RouteCollection $collection, $name, $config, $file) protected function parseRoute(RouteCollection $collection, $name, $config, $file)
{ {
$defaults = isset($config['defaults']) ? $config['defaults'] : array(); $defaults = isset($config['defaults']) ? $config['defaults'] : array();
@ -76,6 +81,9 @@ class YamlFileLoader extends FileLoader
$collection->addRoute($name, $route); $collection->addRoute($name, $route);
} }
/**
* @throws \InvalidArgumentException When import resource is not defined
*/
protected function parseImport(RouteCollection $collection, $name, $import, $file) protected function parseImport(RouteCollection $collection, $name, $import, $file)
{ {
if (!isset($import['resource'])) if (!isset($import['resource']))

View File

@ -32,6 +32,8 @@ class ApacheMatcherDumper extends MatcherDumper
* @param array $options An array of options * @param array $options An array of options
* *
* @return string A PHP class representing the matcher class * @return string A PHP class representing the matcher class
*
* @throws \RuntimeException When a route has more than 9 variables
*/ */
public function dump(array $options = array()) public function dump(array $options = array())
{ {

View File

@ -41,6 +41,8 @@ abstract class MatcherDumper implements MatcherDumperInterface
* @param array $options An array of options * @param array $options An array of options
* *
* @return string The representation of the routing * @return string The representation of the routing
*
* @throws \LogicException When this abstrass class is not implemented
*/ */
public function dump(array $options = array()) public function dump(array $options = array())
{ {

View File

@ -37,6 +37,8 @@ class RouteCollection
* *
* @param string $name The route name * @param string $name The route name
* @param Route $route A Route instance * @param Route $route A Route instance
*
* @throws \InvalidArgumentException When route name contains non valid characters
*/ */
public function addRoute($name, Route $route) public function addRoute($name, Route $route)
{ {

View File

@ -127,6 +127,8 @@ class RouteCompiler implements RouteCompilerInterface
/** /**
* Tokenizes the route. * Tokenizes the route.
*
* @throws \InvalidArgumentException When route can't be parsed
*/ */
protected function tokenize() protected function tokenize()
{ {

View File

@ -41,6 +41,8 @@ class Router implements RouterInterface
* @param array $options An array of options * @param array $options An array of options
* @param array $context The context * @param array $context The context
* @param array $defaults The default values * @param array $defaults The default values
*
* @throws \InvalidArgumentException When unsupported option is provided
*/ */
public function __construct($loader, array $options = array(), array $context = array(), array $defaults = array()) public function __construct($loader, array $options = array(), array $context = array(), array $defaults = array())
{ {
@ -249,6 +251,9 @@ class Router implements RouterInterface
return $this->options['cache_dir'].'/'.$class.'.'.$extension; return $this->options['cache_dir'].'/'.$class.'.'.$extension;
} }
/**
* @throws \RuntimeException When cache file can't be wrote
*/
protected function writeCacheFile($file, $content) protected function writeCacheFile($file, $content)
{ {
$tmpFile = tempnam(dirname($file), basename($file)); $tmpFile = tempnam(dirname($file), basename($file));

View File

@ -69,6 +69,8 @@ class Inline
* @param mixed $value The PHP variable to convert * @param mixed $value The PHP variable to convert
* *
* @return string The YAML string representing the PHP array * @return string The YAML string representing the PHP array
*
* @throws Exception When trying to dump PHP ressource
*/ */
static public function dump($value) static public function dump($value)
{ {
@ -157,6 +159,8 @@ class Inline
* @param boolean $evaluate * @param boolean $evaluate
* *
* @return string A YAML string * @return string A YAML string
*
* @throws ParserException When malformed inline YAML string is parsed
*/ */
static public function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) static public function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true)
{ {
@ -202,6 +206,8 @@ class Inline
* @param integer $i * @param integer $i
* *
* @return string A YAML string * @return string A YAML string
*
* @throws ParserException When malformed inline YAML string is parsed
*/ */
static protected function parseQuotedScalar($scalar, &$i) static protected function parseQuotedScalar($scalar, &$i)
{ {
@ -235,6 +241,8 @@ class Inline
* @param integer $i * @param integer $i
* *
* @return string A YAML string * @return string A YAML string
*
* @throws ParserException When malformed inline YAML string is parsed
*/ */
static protected function parseSequence($sequence, &$i = 0) static protected function parseSequence($sequence, &$i = 0)
{ {
@ -295,6 +303,8 @@ class Inline
* @param integer $i * @param integer $i
* *
* @return string A YAML string * @return string A YAML string
*
* @throws ParserException When malformed inline YAML string is parsed
*/ */
static protected function parseMapping($mapping, &$i = 0) static protected function parseMapping($mapping, &$i = 0)
{ {

View File

@ -42,7 +42,7 @@ class Parser
* *
* @return mixed A PHP value * @return mixed A PHP value
* *
* @throws \InvalidArgumentException If the YAML is not valid * @throws ParserException If the YAML is not valid
*/ */
public function parse($value) public function parse($value)
{ {
@ -298,6 +298,8 @@ class Parser
* @param integer $indentation The indent level at which the block is to be read, or null for default * @param integer $indentation The indent level at which the block is to be read, or null for default
* *
* @return string A YAML string * @return string A YAML string
*
* @throws ParserException When indentation problem are detected
*/ */
protected function getNextEmbedBlock($indentation = null) protected function getNextEmbedBlock($indentation = null)
{ {
@ -386,6 +388,8 @@ class Parser
* @param string $value A YAML value * @param string $value A YAML value
* *
* @return mixed A PHP value * @return mixed A PHP value
*
* @throws ParserException When reference doesn't not exist
*/ */
protected function parseValue($value) protected function parseValue($value)
{ {

View File

@ -25,6 +25,8 @@ class Yaml
* Sets the YAML specification version to use. * Sets the YAML specification version to use.
* *
* @param string $version The YAML specification version * @param string $version The YAML specification version
*
* @throws \InvalidArgumentException When version of YAML specs is not supported
*/ */
static public function setSpecVersion($version) static public function setSpecVersion($version)
{ {

View File

@ -19,6 +19,9 @@ namespace Symfony\Foundation;
*/ */
class ClassCollectionLoader class ClassCollectionLoader
{ {
/**
* @throws \InvalidArgumentException When class can't be loaded
*/
static public function load($classes, $cacheDir, $name, $autoReload) static public function load($classes, $cacheDir, $name, $autoReload)
{ {
$cache = $cacheDir.'/'.$name.'.php'; $cache = $cacheDir.'/'.$name.'.php';

View File

@ -46,6 +46,9 @@ class ErrorHandler
set_error_handler(array($this, 'handle')); set_error_handler(array($this, 'handle'));
} }
/**
* @throws \ErrorException When error_reporting returns error
*/
public function handle($level, $message, $file, $line, $context) public function handle($level, $message, $file, $line, $context)
{ {
if (0 === $this->level) if (0 === $this->level)

View File

@ -98,6 +98,8 @@ abstract class Kernel implements \Serializable
* the DI container. * the DI container.
* *
* @return Kernel The current Kernel instance * @return Kernel The current Kernel instance
*
* @throws \LogicException When the Kernel is already booted
*/ */
public function boot() public function boot()
{ {

View File

@ -81,6 +81,8 @@ The above will re-build everything and load all bundle data fixtures.
/** /**
* @see Command * @see Command
*
* @throws \InvalidArgumentException When neither of any build options is included
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

View File

@ -48,6 +48,8 @@ class DatabaseToolDoctrineCommand extends DoctrineCommand
/** /**
* @see Command * @see Command
*
* @throws \InvalidArgumentException When neither of --drop or --create is specified
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

View File

@ -44,6 +44,8 @@ class ImportMappingDoctrineCommand extends DoctrineCommand
/** /**
* @see Command * @see Command
*
* @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle\MySampleBundle")
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

View File

@ -58,6 +58,8 @@ Now you have a new entity and your database has been updated.
/** /**
* @see Command * @see Command
*
* @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle\MySampleBundle")
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

View File

@ -82,6 +82,9 @@ class ProfilerStorage
$this->close($db); $this->close($db);
} }
/**
* @throws \RuntimeException When neither of SQLite or PDO_SQLite extension is enabled
*/
protected function initDb($readOnly = true) protected function initDb($readOnly = true)
{ {
if (class_exists('\SQLite3')) if (class_exists('\SQLite3'))

View File

@ -42,6 +42,8 @@ class AssetsInstallCommand extends Command
/** /**
* @see Command * @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

View File

@ -43,6 +43,9 @@ class InitBundleCommand extends Command
/** /**
* @see Command * @see Command
*
* @throws \InvalidArgumentException When namespace doesn't end with Bundle
* @throws \RuntimeException When bundle can't be executed
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

View File

@ -104,6 +104,9 @@ EOF
} }
} }
/**
* @throws \InvalidArgumentException When route does not exist
*/
protected function outputRoute(OutputInterface $output, $routes, $name) protected function outputRoute(OutputInterface $output, $routes, $name)
{ {
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name))); $output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));

View File

@ -25,6 +25,9 @@ use Symfony\Components\RequestHandler\Exception\HttpException;
*/ */
class ExceptionController extends Controller class ExceptionController extends Controller
{ {
/**
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function exceptionAction(\Exception $exception, Request $originalRequest, array $logs) public function exceptionAction(\Exception $exception, Request $originalRequest, array $logs)
{ {
$template = $this->container->getParameter('kernel.debug') ? 'exception' : 'error'; $template = $this->container->getParameter('kernel.debug') ? 'exception' : 'error';

View File

@ -74,6 +74,9 @@ class ControllerLoader
return true; return true;
} }
/**
* @throws \InvalidArgumentException|\LogicException If controller can't be found
*/
public function findController($bundle, $controller, $action) public function findController($bundle, $controller, $action)
{ {
$class = null; $class = null;
@ -130,6 +133,9 @@ class ControllerLoader
return array($controller, $method); return array($controller, $method);
} }
/**
* @throws \RuntimeException When value for argument given is not provided
*/
public function getMethodArguments(\ReflectionFunctionAbstract $r, array $parameters, $controller) public function getMethodArguments(\ReflectionFunctionAbstract $r, array $parameters, $controller)
{ {
$arguments = array(); $arguments = array();

View File

@ -21,6 +21,9 @@ class PdoSession extends NativeSession
{ {
protected $db; protected $db;
/**
* @throws \InvalidArgumentException When "db_table" option is not provided
*/
public function __construct(\PDO $db, $options = null) public function __construct(\PDO $db, $options = null)
{ {
$this->db = $db; $this->db = $db;
@ -60,8 +63,6 @@ class PdoSession extends NativeSession
* @param string $name (ignored) * @param string $name (ignored)
* *
* @return boolean true, if the session was opened, otherwise an exception is thrown * @return boolean true, if the session was opened, otherwise an exception is thrown
*
* @throws <b>DatabaseException</b> If a connection with the database does not exist or cannot be created
*/ */
public function sessionOpen($path = null, $name = null) public function sessionOpen($path = null, $name = null)
{ {
@ -84,9 +85,9 @@ class PdoSession extends NativeSession
* *
* @param string $id A session ID * @param string $id A session ID
* *
* @return bool true, if the session was destroyed, otherwise an exception is thrown * @return bool true, if the session was destroyed, otherwise an exception is thrown
* *
* @throws <b>DatabaseException</b> If the session cannot be destroyed * @throws \RuntimeException If the session cannot be destroyed
*/ */
public function sessionDestroy($id) public function sessionDestroy($id)
{ {
@ -118,7 +119,7 @@ class PdoSession extends NativeSession
* *
* @return bool true, if old sessions have been cleaned, otherwise an exception is thrown * @return bool true, if old sessions have been cleaned, otherwise an exception is thrown
* *
* @throws <b>DatabaseException</b> If any old sessions cannot be cleaned * @throws \RuntimeException If any old sessions cannot be cleaned
*/ */
public function sessionGC($lifetime) public function sessionGC($lifetime)
{ {
@ -148,7 +149,7 @@ class PdoSession extends NativeSession
* *
* @return string The session data if the session was read or created, otherwise an exception is thrown * @return string The session data if the session was read or created, otherwise an exception is thrown
* *
* @throws <b>DatabaseException</b> If the session cannot be read * @throws \RuntimeException If the session cannot be read
*/ */
public function sessionRead($id) public function sessionRead($id)
{ {
@ -202,7 +203,7 @@ class PdoSession extends NativeSession
* *
* @return bool true, if the session was written, otherwise an exception is thrown * @return bool true, if the session was written, otherwise an exception is thrown
* *
* @throws <b>DatabaseException</b> If the session data cannot be written * @throws \RuntimeException If the session data cannot be written
*/ */
public function sessionWrite($id, $data) public function sessionWrite($id, $data)
{ {

View File

@ -28,7 +28,7 @@ interface SessionInterface
* *
* @return mixed Data associated with the key * @return mixed Data associated with the key
* *
* @throws RuntimeException If an error occurs while reading data from this storage * @throws \RuntimeException If an error occurs while reading data from this storage
*/ */
public function read($key); public function read($key);
@ -41,7 +41,7 @@ interface SessionInterface
* *
* @return mixed Data associated with the key * @return mixed Data associated with the key
* *
* @throws RuntimeException If an error occurs while removing data from this storage * @throws \RuntimeException If an error occurs while removing data from this storage
*/ */
public function remove($key); public function remove($key);
@ -53,7 +53,7 @@ interface SessionInterface
* @param string $key A unique key identifying your data * @param string $key A unique key identifying your data
* @param mixed $data Data associated with your key * @param mixed $data Data associated with your key
* *
* @throws RuntimeException If an error occurs while writing to this storage * @throws \RuntimeException If an error occurs while writing to this storage
*/ */
public function write($key, $data); public function write($key, $data);
@ -64,7 +64,7 @@ interface SessionInterface
* *
* @return boolean True if session regenerated, false if error * @return boolean True if session regenerated, false if error
* *
* @throws RuntimeException If an error occurs while regenerating this storage * @throws \RuntimeException If an error occurs while regenerating this storage
*/ */
public function regenerate($destroy = false); public function regenerate($destroy = false);
} }

View File

@ -77,6 +77,9 @@ class Engine extends BaseEngine
return isset($this->helpers[$name]); return isset($this->helpers[$name]);
} }
/**
* @throws \InvalidArgumentException When the helper is not defined
*/
public function get($name) public function get($name)
{ {
if (!isset($this->helpers[$name])) if (!isset($this->helpers[$name]))

View File

@ -166,6 +166,8 @@ class Filesystem
* *
* @param string $origin The origin filename * @param string $origin The origin filename
* @param string $target The new filename * @param string $target The new filename
*
* @throws \RuntimeException When target file already exists
*/ */
public function rename($origin, $target) public function rename($origin, $target)
{ {
@ -220,6 +222,8 @@ class Filesystem
* @param string $targetDir The target directory * @param string $targetDir The target directory
* @param Finder $finder An Finder instance * @param Finder $finder An Finder instance
* @param array $options An array of options (see copy()) * @param array $options An array of options (see copy())
*
* @throws \RuntimeException When file type is unknown
*/ */
public function mirror($originDir, $targetDir, $finder = null, $options = array()) public function mirror($originDir, $targetDir, $finder = null, $options = array())
{ {

View File

@ -286,6 +286,8 @@ class Finder
* *
* @param mixed function or method to call * @param mixed function or method to call
* @return Finder Current object * @return Finder Current object
*
* @throws \InvalidArgumentException If function or method does not exist
*/ */
public function exec() public function exec()
{ {

View File

@ -43,7 +43,9 @@ class NumberCompare
{ {
$this->test = $test; $this->test = $test;
} }
/**
* @throws \RuntimeException If the test is not understood
*/
public function test($number) public function test($number)
{ {
if (!preg_match('{^([<>]=?)?(.*?)([kmg]i?)?$}i', $this->test, $matches)) if (!preg_match('{^([<>]=?)?(.*?)([kmg]i?)?$}i', $this->test, $matches))