diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index fba6d70d6978..fedc425a11a0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -15,6 +15,7 @@ use Symfony\Component\Translation\Translator as BaseTranslator; use Symfony\Component\Translation\MessageSelector; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Translation\Exception\InvalidArgumentException; /** * Translator. @@ -51,7 +52,7 @@ class Translator extends BaseTranslator implements WarmableInterface * @param array $loaderIds An array of loader Ids * @param array $options An array of options * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array()) { @@ -60,7 +61,7 @@ public function __construct(ContainerInterface $container, MessageSelector $sele // check option names if ($diff = array_diff(array_keys($options), array_keys($this->options))) { - throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff))); + throw new InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff))); } $this->options = array_merge($this->options, $options); diff --git a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php index 9598e1767a7d..8ea921aa4e6d 100644 --- a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php +++ b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php @@ -13,6 +13,8 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\MessageCatalogueInterface; +use Symfony\Component\Translation\Exception\InvalidArgumentException; +use Symfony\Component\Translation\Exception\LogicException; /** * Base catalogues binary operation class. @@ -72,12 +74,12 @@ abstract class AbstractOperation implements OperationInterface * @param MessageCatalogueInterface $source The source catalogue * @param MessageCatalogueInterface $target The target catalogue * - * @throws \LogicException + * @throws LogicException */ public function __construct(MessageCatalogueInterface $source, MessageCatalogueInterface $target) { if ($source->getLocale() !== $target->getLocale()) { - throw new \LogicException('Operated catalogues must belong to the same locale.'); + throw new LogicException('Operated catalogues must belong to the same locale.'); } $this->source = $source; @@ -105,7 +107,7 @@ public function getDomains() public function getMessages($domain) { if (!in_array($domain, $this->getDomains())) { - throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); + throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); } if (!isset($this->messages[$domain]['all'])) { @@ -121,7 +123,7 @@ public function getMessages($domain) public function getNewMessages($domain) { if (!in_array($domain, $this->getDomains())) { - throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); + throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); } if (!isset($this->messages[$domain]['new'])) { @@ -137,7 +139,7 @@ public function getNewMessages($domain) public function getObsoleteMessages($domain) { if (!in_array($domain, $this->getDomains())) { - throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); + throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); } if (!isset($this->messages[$domain]['obsolete'])) { diff --git a/src/Symfony/Component/Translation/DataCollectorTranslator.php b/src/Symfony/Component/Translation/DataCollectorTranslator.php index 244672335806..cd467354df77 100644 --- a/src/Symfony/Component/Translation/DataCollectorTranslator.php +++ b/src/Symfony/Component/Translation/DataCollectorTranslator.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Translation; +use Symfony\Component\Translation\Exception\InvalidArgumentException; + /** * @author Abdellatif Ait boudad */ @@ -36,7 +38,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter public function __construct(TranslatorInterface $translator) { if (!$translator instanceof TranslatorBagInterface) { - throw new \InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator))); + throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator))); } $this->translator = $translator; diff --git a/src/Symfony/Component/Translation/Dumper/FileDumper.php b/src/Symfony/Component/Translation/Dumper/FileDumper.php index 4228741270dd..a0b207fc3fba 100644 --- a/src/Symfony/Component/Translation/Dumper/FileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/FileDumper.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Dumper; use Symfony\Component\Translation\MessageCatalogue; +use Symfony\Component\Translation\Exception\InvalidArgumentException; /** * FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s). @@ -64,7 +65,7 @@ public function setBackup($backup) public function dump(MessageCatalogue $messages, $options = array()) { if (!array_key_exists('path', $options)) { - throw new \InvalidArgumentException('The file dumper needs a path option.'); + throw new InvalidArgumentException('The file dumper needs a path option.'); } // save a file for each domain @@ -79,7 +80,7 @@ public function dump(MessageCatalogue $messages, $options = array()) } else { $directory = dirname($fullpath); if (!file_exists($directory) && !@mkdir($directory, 0777, true)) { - throw new \RuntimeException(sprintf('Unable to create directory "%s".', $directory)); + throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory)); } } // save file diff --git a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php index 915dbcae8e84..47b05c81b12d 100644 --- a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Dumper; use Symfony\Component\Translation\MessageCatalogue; +use Symfony\Component\Translation\Exception\InvalidArgumentException; /** * XliffFileDumper generates xliff files from a message catalogue. @@ -43,7 +44,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti return $this->dumpXliff2($defaultLocale, $messages, $domain, $options); } - throw new \InvalidArgumentException(sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion)); + throw new InvalidArgumentException(sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion)); } /** diff --git a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php index 625953c79008..fdd113b10365 100644 --- a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php @@ -14,6 +14,7 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Util\ArrayConverter; use Symfony\Component\Yaml\Yaml; +use Symfony\Component\Translation\Exception\LogicException; /** * YamlFileDumper generates yaml files from a message catalogue. @@ -28,7 +29,7 @@ class YamlFileDumper extends FileDumper public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) { if (!class_exists('Symfony\Component\Yaml\Yaml')) { - throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); + throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); } $data = $messages->all($domain); diff --git a/src/Symfony/Component/Translation/Exception/InvalidArgumentException.php b/src/Symfony/Component/Translation/Exception/InvalidArgumentException.php new file mode 100644 index 000000000000..90d06690f182 --- /dev/null +++ b/src/Symfony/Component/Translation/Exception/InvalidArgumentException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Exception; + +/** + * Base InvalidArgumentException for the Translation component. + * + * @author Abdellatif Ait boudad + */ +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Translation/Exception/LogicException.php b/src/Symfony/Component/Translation/Exception/LogicException.php new file mode 100644 index 000000000000..9019c7e7be78 --- /dev/null +++ b/src/Symfony/Component/Translation/Exception/LogicException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Exception; + +/** + * Base LogicException for Translation component. + * + * @author Abdellatif Ait boudad + */ +class LogicException extends \LogicException implements ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Translation/Exception/RuntimeException.php b/src/Symfony/Component/Translation/Exception/RuntimeException.php new file mode 100644 index 000000000000..dcd794082960 --- /dev/null +++ b/src/Symfony/Component/Translation/Exception/RuntimeException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Exception; + +/** + * Base RuntimeException for the Translation component. + * + * @author Abdellatif Ait boudad + */ +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php index 57fd4938d22c..4b6b155df60a 100644 --- a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Translation\Extractor; +use Symfony\Component\Translation\Exception\InvalidArgumentException; + /** * Base class used by classes that extract translation messages from files. * @@ -56,12 +58,12 @@ private function toSplFileInfo($file) * * @return bool * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ protected function isFile($file) { if (!is_file($file)) { - throw new \InvalidArgumentException(sprintf('The "%s" file does not exist.', $file)); + throw new InvalidArgumentException(sprintf('The "%s" file does not exist.', $file)); } return true; diff --git a/src/Symfony/Component/Translation/Interval.php b/src/Symfony/Component/Translation/Interval.php index 2a51156ef735..9e2cae648c6d 100644 --- a/src/Symfony/Component/Translation/Interval.php +++ b/src/Symfony/Component/Translation/Interval.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Translation; +use Symfony\Component\Translation\Exception\InvalidArgumentException; + /** * Tests if a given number belongs to a given math interval. * @@ -41,14 +43,14 @@ class Interval * * @return bool * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public static function test($number, $interval) { $interval = trim($interval); if (!preg_match('/^'.self::getIntervalRegexp().'$/x', $interval, $matches)) { - throw new \InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval)); + throw new InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval)); } if ($matches[1]) { diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 62ce80eefd64..e3cab6543744 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -15,6 +15,7 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Exception\InvalidResourceException; use Symfony\Component\Translation\Exception\NotFoundResourceException; +use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Config\Resource\FileResource; /** @@ -202,7 +203,7 @@ private function getSchema($xliffVersion) $schemaSource = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-2.0.xsd'); $xmlUri = 'informativeCopiesOf3rdPartySchemas/w3c/xml.xsd'; } else { - throw new \InvalidArgumentException(sprintf('No support implemented for loading XLIFF version "%s".', $xliffVersion)); + throw new InvalidArgumentException(sprintf('No support implemented for loading XLIFF version "%s".', $xliffVersion)); } return $this->fixXmlLocation($schemaSource, $xmlUri); @@ -267,7 +268,7 @@ private function getXmlErrors($internalErrors) * * @param \DOMDocument $dom * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return string */ @@ -283,7 +284,7 @@ private function getVersionNumber(\DOMDocument $dom) $namespace = $xliff->attributes->getNamedItem('xmlns'); if ($namespace) { if (substr_compare('urn:oasis:names:tc:xliff:document:', $namespace->nodeValue, 0, 34) !== 0) { - throw new \InvalidArgumentException(sprintf('Not a valid XLIFF namespace "%s"', $namespace)); + throw new InvalidArgumentException(sprintf('Not a valid XLIFF namespace "%s"', $namespace)); } return substr($namespace, 34); diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index 5d9a3aded1d9..41e390d0e967 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Loader; use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\LogicException; use Symfony\Component\Yaml\Parser as YamlParser; use Symfony\Component\Yaml\Exception\ParseException; @@ -31,7 +32,7 @@ protected function loadResource($resource) { if (null === $this->yamlParser) { if (!class_exists('Symfony\Component\Yaml\Parser')) { - throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); + throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); } $this->yamlParser = new YamlParser(); diff --git a/src/Symfony/Component/Translation/LoggingTranslator.php b/src/Symfony/Component/Translation/LoggingTranslator.php index fa5c5cc5b5ff..3ea3df316d68 100644 --- a/src/Symfony/Component/Translation/LoggingTranslator.php +++ b/src/Symfony/Component/Translation/LoggingTranslator.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation; use Psr\Log\LoggerInterface; +use Symfony\Component\Translation\Exception\InvalidArgumentException; /** * @author Abdellatif Ait boudad @@ -35,7 +36,7 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface public function __construct(TranslatorInterface $translator, LoggerInterface $logger) { if (!$translator instanceof TranslatorBagInterface) { - throw new \InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator))); + throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator))); } $this->translator = $translator; diff --git a/src/Symfony/Component/Translation/MessageCatalogue.php b/src/Symfony/Component/Translation/MessageCatalogue.php index dd354a85aae3..9d77f07db788 100644 --- a/src/Symfony/Component/Translation/MessageCatalogue.php +++ b/src/Symfony/Component/Translation/MessageCatalogue.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation; use Symfony\Component\Config\Resource\ResourceInterface; +use Symfony\Component\Translation\Exception\LogicException; /** * MessageCatalogue. @@ -143,7 +144,7 @@ public function add($messages, $domain = 'messages') public function addCatalogue(MessageCatalogueInterface $catalogue) { if ($catalogue->getLocale() !== $this->locale) { - throw new \LogicException(sprintf('Cannot add a catalogue for locale "%s" as the current locale for this catalogue is "%s"', $catalogue->getLocale(), $this->locale)); + throw new LogicException(sprintf('Cannot add a catalogue for locale "%s" as the current locale for this catalogue is "%s"', $catalogue->getLocale(), $this->locale)); } foreach ($catalogue->all() as $domain => $messages) { @@ -169,14 +170,14 @@ public function addFallbackCatalogue(MessageCatalogueInterface $catalogue) $c = $catalogue; while ($c = $c->getFallbackCatalogue()) { if ($c->getLocale() === $this->getLocale()) { - throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale())); + throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale())); } } $c = $this; do { if ($c->getLocale() === $catalogue->getLocale()) { - throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale())); + throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale())); } } while ($c = $c->parent); diff --git a/src/Symfony/Component/Translation/MessageSelector.php b/src/Symfony/Component/Translation/MessageSelector.php index 91823ad51153..c6134191bce0 100644 --- a/src/Symfony/Component/Translation/MessageSelector.php +++ b/src/Symfony/Component/Translation/MessageSelector.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Translation; +use Symfony\Component\Translation\Exception\InvalidArgumentException; + /** * MessageSelector. * @@ -43,7 +45,7 @@ class MessageSelector * * @return string * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function choose($message, $number, $locale) { @@ -78,7 +80,7 @@ public function choose($message, $number, $locale) return $standardRules[0]; } - throw new \InvalidArgumentException(sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $message, $locale, $number)); + throw new InvalidArgumentException(sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $message, $locale, $number)); } return $standardRules[$position]; diff --git a/src/Symfony/Component/Translation/Tests/IntervalTest.php b/src/Symfony/Component/Translation/Tests/IntervalTest.php index 075c98b768f8..8dd4b3345ef6 100644 --- a/src/Symfony/Component/Translation/Tests/IntervalTest.php +++ b/src/Symfony/Component/Translation/Tests/IntervalTest.php @@ -24,7 +24,7 @@ public function testTest($expected, $number, $interval) } /** - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testTestException() { diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php index 6f55b8cc5e8f..e87525330196 100644 --- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php @@ -125,7 +125,7 @@ public function testAddFallbackCatalogue() } /** - * @expectedException \LogicException + * @expectedException \Symfony\Component\Translation\Exception\LogicException */ public function testAddFallbackCatalogueWithParentCircularReference() { @@ -137,7 +137,7 @@ public function testAddFallbackCatalogueWithParentCircularReference() } /** - * @expectedException \LogicException + * @expectedException \Symfony\Component\Translation\Exception\LogicException */ public function testAddFallbackCatalogueWithFallbackCircularReference() { @@ -151,7 +151,7 @@ public function testAddFallbackCatalogueWithFallbackCircularReference() } /** - * @expectedException \LogicException + * @expectedException \Symfony\Component\Translation\Exception\LogicException */ public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne() { diff --git a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php index a92e7614894a..59707c74a093 100644 --- a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php @@ -34,7 +34,7 @@ public function testReturnMessageIfExactlyOneStandardRuleIsGiven() /** * @dataProvider getNonMatchingMessages - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number) { diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 777165854d09..e31cd4765b68 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -20,7 +20,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider getInvalidLocalesTests - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testConstructorInvalidLocale($locale) { @@ -56,7 +56,7 @@ public function testSetGetLocale() /** * @dataProvider getInvalidLocalesTests - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testSetInvalidLocale($locale) { @@ -139,7 +139,7 @@ public function testSetFallbackLocalesMultiple() /** * @dataProvider getInvalidLocalesTests - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testSetFallbackInvalidLocales($locale) { @@ -170,7 +170,7 @@ public function testTransWithFallbackLocale() /** * @dataProvider getInvalidLocalesTests - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testAddResourceInvalidLocales($locale) { @@ -263,7 +263,7 @@ public function testTransNonExistentWithFallback() } /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\Translation\Exception\RuntimeException */ public function testWhenAResourceHasNoRegisteredLoader() { @@ -307,7 +307,7 @@ public function testTrans($expected, $id, $translation, $parameters, $locale, $d /** * @dataProvider getInvalidLocalesTests - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testTransInvalidLocale($locale) { @@ -357,7 +357,7 @@ public function testTransChoice($expected, $id, $translation, $number, $paramete /** * @dataProvider getInvalidLocalesTests - * @expectedException \InvalidArgumentException + * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function testTransChoiceInvalidLocale($locale) { diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index c98d25d2737c..9bddee34e21e 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -13,6 +13,8 @@ use Symfony\Component\Translation\Loader\LoaderInterface; use Symfony\Component\Translation\Exception\NotFoundResourceException; +use Symfony\Component\Translation\Exception\InvalidArgumentException; +use Symfony\Component\Translation\Exception\RuntimeException; use Symfony\Component\Config\ConfigCacheInterface; use Symfony\Component\Config\ConfigCacheFactoryInterface; use Symfony\Component\Config\ConfigCacheFactory; @@ -77,7 +79,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface * @param string|null $cacheDir The directory to use for the cache * @param bool $debug Use cache in debug mode ? * - * @throws \InvalidArgumentException If a locale contains invalid characters + * @throws InvalidArgumentException If a locale contains invalid characters */ public function __construct($locale, MessageSelector $selector = null, $cacheDir = null, $debug = false) { @@ -116,7 +118,7 @@ public function addLoader($format, LoaderInterface $loader) * @param string $locale The locale * @param string $domain The domain * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ public function addResource($format, $resource, $locale, $domain = null) { @@ -157,7 +159,7 @@ public function getLocale() * * @param array $locales The fallback locales * - * @throws \InvalidArgumentException If a locale contains invalid characters + * @throws InvalidArgumentException If a locale contains invalid characters */ public function setFallbackLocales(array $locales) { @@ -371,7 +373,7 @@ private function doLoadCatalogue($locale) if (isset($this->resources[$locale])) { foreach ($this->resources[$locale] as $resource) { if (!isset($this->loaders[$resource[0]])) { - throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0])); + throw new RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0])); } $this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2])); } @@ -419,12 +421,12 @@ protected function computeFallbackLocales($locale) * * @param string $locale Locale to tests * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ protected function assertValidLocale($locale) { if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { - throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); + throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); } } diff --git a/src/Symfony/Component/Translation/TranslatorBagInterface.php b/src/Symfony/Component/Translation/TranslatorBagInterface.php index 14fbb17f5e46..b454f02a3a2b 100644 --- a/src/Symfony/Component/Translation/TranslatorBagInterface.php +++ b/src/Symfony/Component/Translation/TranslatorBagInterface.php @@ -25,7 +25,7 @@ interface TranslatorBagInterface * * @return MessageCatalogueInterface * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ public function getCatalogue($locale = null); } diff --git a/src/Symfony/Component/Translation/TranslatorInterface.php b/src/Symfony/Component/Translation/TranslatorInterface.php index 6916c335bd42..92b5a622e89d 100644 --- a/src/Symfony/Component/Translation/TranslatorInterface.php +++ b/src/Symfony/Component/Translation/TranslatorInterface.php @@ -28,7 +28,7 @@ interface TranslatorInterface * * @return string The translated string * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ public function trans($id, array $parameters = array(), $domain = null, $locale = null); @@ -43,7 +43,7 @@ public function trans($id, array $parameters = array(), $domain = null, $locale * * @return string The translated string * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null); @@ -52,7 +52,7 @@ public function transChoice($id, $number, array $parameters = array(), $domain = * * @param string $locale The locale * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ public function setLocale($locale); diff --git a/src/Symfony/Component/Translation/Writer/TranslationWriter.php b/src/Symfony/Component/Translation/Writer/TranslationWriter.php index 2f5eaa1edf0d..901a8894e1c4 100644 --- a/src/Symfony/Component/Translation/Writer/TranslationWriter.php +++ b/src/Symfony/Component/Translation/Writer/TranslationWriter.php @@ -13,6 +13,8 @@ use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Dumper\DumperInterface; +use Symfony\Component\Translation\Exception\InvalidArgumentException; +use Symfony\Component\Translation\Exception\RuntimeException; /** * TranslationWriter writes translation messages. @@ -68,19 +70,19 @@ public function getFormats() * @param string $format The format to use to dump the messages * @param array $options Options that are passed to the dumper * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function writeTranslations(MessageCatalogue $catalogue, $format, $options = array()) { if (!isset($this->dumpers[$format])) { - throw new \InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format)); + throw new InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format)); } // get the right dumper $dumper = $this->dumpers[$format]; if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) { - throw new \RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path'])); + throw new RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path'])); } // save