diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index a871be2a0d..562a2952da 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -95,7 +95,7 @@ class DoctrineTokenProvider implements TokenProviderInterface $paramValues = array('value' => $tokenValue, 'lastUsed' => $lastUsed, 'series' => $series,); - $paramTypes = array('value' => \PDO::PARAM_STR, + $paramTypes = array('value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, 'series' => \PDO::PARAM_STR,); $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php index 5023a808dc..69e1b9b3e7 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php @@ -26,9 +26,6 @@ class LazyServiceProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); } diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php index 1c75d8bb85..e4757d8b9d 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php @@ -56,7 +56,7 @@ class TransChoiceTokenParser extends TransTokenParser if ($stream->test('into')) { // {% transchoice count into "fr" %} $stream->next(); - $locale = $this->parser->getExpressionParser()->parseExpression(); + $locale = $this->parser->getExpressionParser()->parseExpression(); } $stream->expect(\Twig_Token::BLOCK_END_TYPE); diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index 86f9579cf6..96e420e5ce 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -53,7 +53,7 @@ class TransTokenParser extends \Twig_TokenParser if ($stream->test('into')) { // {% trans into "fr" %} $stream->next(); - $locale = $this->parser->getExpressionParser()->parseExpression(); + $locale = $this->parser->getExpressionParser()->parseExpression(); } elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php index 4a94f99fe0..32f749f79f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php @@ -41,4 +41,25 @@ abstract class ServerCommand extends ContainerAwareCommand { return sys_get_temp_dir().'/'.strtr($address, '.:', '--').'.pid'; } + + protected function isOtherServerProcessRunning($address) + { + $lockFile = $this->getLockFile($address); + + if (file_exists($lockFile)) { + return true; + } + + list($hostname, $port) = explode(':', $address); + + $fp = @fsockopen($hostname, $port, $errno, $errstr, 5); + + if (false !== $fp) { + fclose($fp); + + return true; + } + + return false; + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 3b2efc139a..392ffee534 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -23,7 +23,7 @@ use Symfony\Component\Process\ProcessBuilder; * * @author Michał Pipa */ -class ServerRunCommand extends ContainerAwareCommand +class ServerRunCommand extends ServerCommand { /** * {@inheritdoc} @@ -96,15 +96,28 @@ EOF } $env = $this->getContainer()->getParameter('kernel.environment'); + $address = $input->getArgument('address'); + + if (false === strpos($address, ':')) { + $output->writeln('The address has to be of the form bind-address:port.'); + + return 1; + } + + if ($this->isOtherServerProcessRunning($address)) { + $output->writeln(sprintf('A process is already listening on http://%s.', $address)); + + return 1; + } if ('prod' === $env) { $output->writeln('Running PHP built-in server in production environment is NOT recommended!'); } - $output->writeln(sprintf("Server running on http://%s\n", $input->getArgument('address'))); + $output->writeln(sprintf("Server running on http://%s\n", $address)); $output->writeln('Quit the server with CONTROL-C.'); - if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) { + if (null === $builder = $this->createPhpProcessBuilder($output, $adress, $input->getOption('router'), $env)) { return 1; } @@ -131,9 +144,9 @@ EOF return $process->getExitCode(); } - private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env) + private function createPhpProcessBuilder(OutputInterface $output, $address, $router, $env) { - $router = $input->getOption('router') ?: $this + $router = $router ?: $this ->getContainer() ->get('kernel') ->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env)) @@ -154,6 +167,6 @@ EOF return; } - return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router)); + return new ProcessBuilder(array($binary, '-S', $address, $router)); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php index 364777e459..87bf2c5e95 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php @@ -160,27 +160,6 @@ EOF } } - private function isOtherServerProcessRunning($address) - { - $lockFile = $this->getLockFile($address); - - if (file_exists($lockFile)) { - return true; - } - - list($hostname, $port) = explode(':', $address); - - $fp = @fsockopen($hostname, $port, $errno, $errstr, 5); - - if (false !== $fp) { - fclose($fp); - - return true; - } - - return false; - } - /** * Determine the absolute file path for the router script, using the environment to choose a standard script * if no custom router script is specified. diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index f30e9fd833..5637c3a325 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -141,7 +141,7 @@ EOF } } - if ($input->getOption('output-format') == 'xliff') { + if ($input->getOption('output-format') == 'xlf') { $output->writeln('Xliff output version is 1.2'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php index 3b899131dd..40722c0433 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php @@ -51,7 +51,7 @@ class PhpStringTokenParser { protected static $replacements = array( '\\' => '\\', - '$' => '$', + '$' => '$', 'n' => "\n", 'r' => "\r", 't' => "\t", diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php index 269cea3b72..aab98f273f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php @@ -22,7 +22,7 @@ class FirewallEntryPointTest extends WebTestCase $client->request('GET', '/secure/resource', array(), array(), array( 'PHP_AUTH_USER' => 'unknown', - 'PHP_AUTH_PW' => 'credentials', + 'PHP_AUTH_PW' => 'credentials', )); $this->assertEquals( diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 0525f50095..b2981cc7d4 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -470,7 +470,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface return $service; } - if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) { + if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) { return $this->get($this->aliasDefinitions[$id]); } @@ -684,7 +684,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface throw new InvalidArgumentException('$id must be a string, or an Alias object.'); } - if ($alias === strtolower($id)) { + if ($alias === (string) $id) { throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias)); } @@ -746,7 +746,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface { $id = strtolower($id); - if (!$this->hasAlias($id)) { + if (!isset($this->aliasDefinitions[$id])) { throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id)); } @@ -864,7 +864,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface { $id = strtolower($id); - if (!$this->hasDefinition($id)) { + if (!array_key_exists($id, $this->definitions)) { throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id)); } @@ -886,8 +886,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function findDefinition($id) { - while ($this->hasAlias($id)) { - $id = (string) $this->getAlias($id); + $id = strtolower($id); + + while (isset($this->aliasDefinitions[$id])) { + $id = (string) $this->aliasDefinitions[$id]; } return $this->getDefinition($id); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index ca2d450c00..517d411251 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -898,9 +898,6 @@ EOF; \$this->services = \$this->scopedServices = \$this->scopeStacks = array(); - - \$this->set('service_container', \$this); - EOF; $code .= "\n"; diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 51c59d272d..fce6879cfa 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -190,6 +190,13 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertTrue($builder->has('bar'), '->setAlias() defines a new service'); $this->assertTrue($builder->get('bar') === $builder->get('foo'), '->setAlias() creates a service that is an alias to another one'); + try { + $builder->setAlias('foobar', 'foobar'); + $this->fail('->setAlias() throws an InvalidArgumentException if the alias references itself'); + } catch (\InvalidArgumentException $e) { + $this->assertEquals('An alias can not reference itself, got a circular reference on "foobar".', $e->getMessage(), '->setAlias() throws an InvalidArgumentException if the alias references itself'); + } + try { $builder->getAlias('foobar'); $this->fail('->getAlias() throws an InvalidArgumentException if the alias does not exist'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index a9a1fffff7..b9b8d5b386 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 6e7823e090..a53f3a3e81 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -33,9 +33,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 5cab356704..f8b84ef2e6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container $this->services = $this->scopedServices = $this->scopeStacks = array(); - - $this->set('service_container', $this); - $this->scopes = array(); $this->scopeChildren = array(); $this->methodMap = array( diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index efb7c5beca..9d9fc4d44c 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -77,7 +77,7 @@ interface EventDispatcherInterface public function removeSubscriber(EventSubscriberInterface $subscriber); /** - * Gets the listeners of a specific event or all listeners. + * Gets the listeners of a specific event or all listeners sorted by descending priority. * * @param string $eventName The name of the event * diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index c820cbce78..fa4ecfb0a4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -155,7 +155,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface public function read($sessionId) { $dbData = $this->getCollection()->findOne(array( - $this->options['id_field'] => $sessionId, + $this->options['id_field'] => $sessionId, $this->options['expiry_field'] => array('$gte' => new \MongoDate()), )); diff --git a/src/Symfony/Component/HttpKernel/UriSigner.php b/src/Symfony/Component/HttpKernel/UriSigner.php index fa0d4571ad..6ddce8736b 100644 --- a/src/Symfony/Component/HttpKernel/UriSigner.php +++ b/src/Symfony/Component/HttpKernel/UriSigner.php @@ -94,14 +94,14 @@ class UriSigner ksort($params); $url['query'] = http_build_query($params, '', '&'); - $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; - $host = isset($url['host']) ? $url['host'] : ''; - $port = isset($url['port']) ? ':'.$url['port'] : ''; - $user = isset($url['user']) ? $url['user'] : ''; - $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($url['path']) ? $url['path'] : ''; - $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; + $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; + $host = isset($url['host']) ? $url['host'] : ''; + $port = isset($url['port']) ? ':'.$url['port'] : ''; + $user = isset($url['user']) ? $url['user'] : ''; + $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; + $pass = ($user || $pass) ? "$pass@" : ''; + $path = isset($url['path']) ? $url['path'] : ''; + $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : ''; return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index 0f4cb89e6b..60701a6cde 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -48,7 +48,7 @@ class ProcessUtils } $escapedArgument = ''; - $quote = false; + $quote = false; foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { if ('"' === $part) { $escapedArgument .= '\\"'; diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 2160f0f422..2f31925e73 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -60,6 +60,9 @@ class StringUtil // indices (index), appendices (appendix), prices (price) array('seci', 4, false, true, array('ex', 'ix', 'ice')), + // selfies (selfie) + array('seifles', 7, true, true, 'selfie'), + // movies (movie) array('seivom', 6, true, true, 'movie'), diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index 73922cd72a..c5691ed7bd 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -119,6 +119,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('sandwiches', array('sandwich', 'sandwiche')), array('scarves', array('scarf', 'scarve', 'scarff')), array('schemas', 'schema'), //schemata + array('selfies', 'selfie'), array('sheriffs', 'sheriff'), array('shoes', array('sho', 'shoe')), array('spies', 'spy'), diff --git a/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf b/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf index e661000148..f2af13ea3d 100644 --- a/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf +++ b/src/Symfony/Component/Security/Resources/translations/security.pt_PT.xlf @@ -4,7 +4,7 @@ An authentication exception occurred. - Ocorreu um excepção durante a autenticação. + Ocorreu uma excepção durante a autenticação. Authentication credentials could not be found. @@ -20,7 +20,7 @@ Cookie has already been used by someone else. - Este cookie já esta em uso. + Este cookie já está em uso. Not privileged to request the resource. @@ -64,7 +64,7 @@ Account is locked. - A conta esta trancada. + A conta está trancada. diff --git a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php index 5920fef20c..870fb98380 100644 --- a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php @@ -26,6 +26,10 @@ class YamlFileDumper extends FileDumper */ protected function format(MessageCatalogue $messages, $domain) { + if (!class_exists('Symfony\Component\Yaml\Yaml')) { + throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); + } + return Yaml::dump($messages->all($domain)); } diff --git a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php index ddcf595baf..fc927601d9 100644 --- a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php @@ -71,7 +71,10 @@ class CsvFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php index a36cd76e71..71ba90a39d 100644 --- a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php @@ -52,7 +52,10 @@ class IcuDatFileLoader extends IcuResFileLoader $messages = $this->flatten($rb); $catalogue = new MessageCatalogue($locale); $catalogue->add($messages, $domain); - $catalogue->addResource(new FileResource($resource.'.dat')); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource.'.dat')); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php index d864c7bd0c..2f8037fb16 100644 --- a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php @@ -52,7 +52,10 @@ class IcuResFileLoader implements LoaderInterface $messages = $this->flatten($rb); $catalogue = new MessageCatalogue($locale); $catalogue->add($messages, $domain); - $catalogue->addResource(new DirectoryResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\DirectoryResource')) { + $catalogue->addResource(new DirectoryResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/IniFileLoader.php b/src/Symfony/Component/Translation/Loader/IniFileLoader.php index 3f01ab4e99..1b3a7b1911 100644 --- a/src/Symfony/Component/Translation/Loader/IniFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IniFileLoader.php @@ -38,7 +38,10 @@ class IniFileLoader extends ArrayLoader $messages = parse_ini_file($resource, true); $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/MoFileLoader.php b/src/Symfony/Component/Translation/Loader/MoFileLoader.php index 9cab3f0d8d..ab4e7a9574 100644 --- a/src/Symfony/Component/Translation/Loader/MoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/MoFileLoader.php @@ -66,7 +66,10 @@ class MoFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php index 1cc9d06d9c..9ce2e7d2fa 100644 --- a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php @@ -42,7 +42,10 @@ class PhpFileLoader extends ArrayLoader $messages = require $resource; $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index 8c8f1a297a..b5d12e9821 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -44,7 +44,10 @@ class PoFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/QtFileLoader.php b/src/Symfony/Component/Translation/Loader/QtFileLoader.php index aacfb4a55e..6dd0696c6f 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -68,7 +68,10 @@ class QtFileLoader implements LoaderInterface } $translation = $translation->nextSibling; } - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } } libxml_use_internal_errors($internalErrors); diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index c3a50cd8bb..99761e7f24 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -78,7 +78,10 @@ class XliffFileLoader implements LoaderInterface $catalogue->setMetadata((string) $source, array('notes' => $notes), $domain); } } - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index e50e0fa385..fb0946cc57 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -43,6 +43,10 @@ class YamlFileLoader extends ArrayLoader throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource)); } + if (!class_exists('Symfony\Component\Yaml\Parser')) { + throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); + } + if (null === $this->yamlParser) { $this->yamlParser = new YamlParser(); } @@ -64,7 +68,10 @@ class YamlFileLoader extends ArrayLoader } $catalogue = parent::load($messages, $locale, $domain); - $catalogue->addResource(new FileResource($resource)); + + if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + $catalogue->addResource(new FileResource($resource)); + } return $catalogue; } diff --git a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php index 2ceb0169a1..dffc3840c9 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php @@ -40,7 +40,7 @@ EOF; '42 cannot be used here', 'this is the message template', array(), - array('some_value' => 42), + array('some_value' => 42), 'some_value', null ); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index b515b84358..1aecb4efdd 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -167,6 +167,20 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest ->assertRaised(); } + public function testInvalidChoiceEmptyChoices() + { + $constraint = new Choice(array( + 'choices' => array(), + 'message' => 'myMessage', + )); + + $this->validator->validate('baz', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"baz"') + ->assertRaised(); + } + public function testInvalidChoiceMultiple() { $constraint = new Choice(array(