diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 04e62890b1..a9a004735b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -47,8 +47,9 @@ class TranslationUpdateCommand extends ContainerAwareCommand )) ->setDescription('Updates the translation file') ->setHelp(<<<'EOF' -The %command.name% command extract translation strings from templates +The %command.name% command extracts translation strings from templates of a given bundle or the app folder. It can display them or merge the new ones into the translation files. + When new translation strings are found it can automatically add a prefix to the translation message. diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 7c05663610..1cd4f4c3b0 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -200,6 +200,10 @@ class Container implements IntrospectableContainerInterface, ResettableContainer $this->scopedServices[$scope][$id] = $service; } + if (isset($this->aliases[$id])) { + unset($this->aliases[$id]); + } + $this->services[$id] = $service; if (method_exists($this, $method = 'synchronize'.strtr($id, $this->underscoreMap).'Service')) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 15a4af481b..fcb85dab30 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -253,6 +253,16 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertTrue(isset($aliases['foobar'])); } + public function testSetReplacesAlias() + { + $builder = new ContainerBuilder(); + $builder->setAlias('alias', 'aliased'); + $builder->set('aliased', new \stdClass()); + + $builder->set('alias', $foo = new \stdClass()); + $this->assertSame($foo, $builder->get('alias'), '->set() replaces an existing alias'); + } + public function testAddGetCompilerPass() { $builder = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index cbe40e4681..8d4fc6004d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -192,6 +192,14 @@ class ContainerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($c->synchronized, '->set() calls synchronize*Service() if it is defined for the service'); } + public function testSetReplacesAlias() + { + $c = new ProjectServiceContainer(); + + $c->set('alias', $foo = new \stdClass()); + $this->assertSame($foo, $c->get('alias'), '->set() replaces an existing alias'); + } + public function testGet() { $sc = new ProjectServiceContainer(); diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 0c7a3b2ec5..c9c3c139b1 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -157,8 +157,12 @@ class Form extends Link implements \ArrayAccess * * This method converts fields with the array notation * (like foo[bar] to arrays) like PHP does. + * The returned array is consistent with the array for field values + * (@see getPhpValues), rather than uploaded files found in $_FILES. + * For a compound file field foo[bar] it will create foo[bar][name], + * instead of foo[name][bar] which would be found in $_FILES. * - * @return array An array of field values. + * @return array An array of file field values. */ public function getPhpFiles() { diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index 3b5156118a..64378336e9 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -94,9 +94,10 @@ class CsrfValidationListener implements EventSubscriberInterface public function preSubmit(FormEvent $event) { $form = $event->getForm(); - $data = $event->getData(); if ($form->isRoot() && $form->getConfig()->getOption('compound')) { + $data = $event->getData(); + if (!isset($data[$this->fieldName]) || !$this->tokenManager->isTokenValid(new CsrfToken($this->tokenId, $data[$this->fieldName]))) { $errorMessage = $this->errorMessage; @@ -109,10 +110,9 @@ class CsrfValidationListener implements EventSubscriberInterface if (is_array($data)) { unset($data[$this->fieldName]); + $event->setData($data); } } - - $event->setData($data); } /** diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 108f0402e8..1e3291be7a 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -27,6 +27,9 @@ class BinaryFileResponse extends Response { protected static $trustXSendfileTypeHeader = false; + /** + * @var File + */ protected $file; protected $offset; protected $maxlen; @@ -180,7 +183,7 @@ class BinaryFileResponse extends Response $this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream'); } - if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { + if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) { $this->setProtocolVersion('1.1'); } @@ -197,17 +200,17 @@ class BinaryFileResponse extends Response if (false === $path) { $path = $this->file->getPathname(); } - if (strtolower($type) == 'x-accel-redirect') { + if (strtolower($type) === 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); - if (2 == count($mapping)) { + if (2 === count($mapping)) { $pathPrefix = trim($mapping[0]); $location = trim($mapping[1]); - if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) { + if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) { $path = $location.substr($path, strlen($pathPrefix)); break; } @@ -218,7 +221,7 @@ class BinaryFileResponse extends Response $this->maxlen = 0; } elseif ($request->headers->has('Range')) { // Process the range headers. - if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) { + if (!$request->headers->has('If-Range') || $this->getEtag() === $request->headers->get('If-Range')) { $range = $request->headers->get('Range'); $fileSize = $this->file->getSize(); @@ -253,17 +256,17 @@ class BinaryFileResponse extends Response /** * Sends the file. + * + * {@inheritdoc} */ public function sendContent() { if (!$this->isSuccessful()) { - parent::sendContent(); - - return; + return parent::sendContent(); } if (0 === $this->maxlen) { - return; + return $this; } $out = fopen('php://output', 'wb'); @@ -277,6 +280,8 @@ class BinaryFileResponse extends Response if ($this->deleteFileAfterSend) { unlink($this->file->getPathname()); } + + return $this; } /** diff --git a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php index d2f0898605..c9e51cc26f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php @@ -35,6 +35,10 @@ class ValueExporter return sprintf('Object(%s)', get_class($value)); } + if ($value instanceof \__PHP_Incomplete_Class) { + return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value)); + } + if (is_array($value)) { if (empty($value)) { return '[]'; @@ -75,4 +79,11 @@ class ValueExporter return (string) $value; } + + private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) + { + $array = new \ArrayObject($value); + + return $array['__PHP_Incomplete_Class_Name']; + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php index 2f2bb972da..4bfa944f8a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php @@ -39,4 +39,12 @@ class ValueExporterTest extends \PHPUnit_Framework_TestCase $dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC')); $this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime)); } + + public function testIncompleteClass() + { + $foo = new \__PHP_Incomplete_Class(); + $array = new \ArrayObject($foo); + $array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo'; + $this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo)); + } } diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 2f31925e73..248a6483d8 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -39,6 +39,9 @@ class StringUtil // nebulae (nebula) array('ea', 2, true, true, 'a'), + // services (service) + array('secivres', 8, true, true, 'service'), + // mice (mouse), lice (louse) array('eci', 3, false, true, 'ouse'), @@ -66,6 +69,12 @@ class StringUtil // movies (movie) array('seivom', 6, true, true, 'movie'), + // news (news) + array('swen', 4, true, true, 'news'), + + // series (series) + array('seires', 6, true, true, 'series'), + // babies (baby) array('sei', 3, false, true, 'y'), diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index c5691ed7bd..0fd6bb69b2 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -102,6 +102,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('movies', 'movie'), array('nebulae', 'nebula'), array('neuroses', array('neuros', 'neurose', 'neurosis')), + array('news', 'news'), array('oases', array('oas', 'oase', 'oasis')), array('objectives', 'objective'), array('oxen', 'ox'), @@ -120,6 +121,8 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('scarves', array('scarf', 'scarve', 'scarff')), array('schemas', 'schema'), //schemata array('selfies', 'selfie'), + array('series', 'series'), + array('services', 'service'), array('sheriffs', 'sheriff'), array('shoes', array('sho', 'shoe')), array('spies', 'spy'), diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php index 9cb606fadc..b00c0d435b 100644 --- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php @@ -69,15 +69,12 @@ array:24 [ 7 => b"é\\x00" "[]" => [] "res" => stream resource {@{$res} - wrapper_type: "plainfile" +%A wrapper_type: "plainfile" stream_type: "STDIO" mode: "r" unread_bytes: 0 seekable: true - timed_out: false - blocked: true - eof: false - options: [] +%A options: [] } "obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d +foo: "foo" @@ -216,16 +213,13 @@ EOTXT; $this->assertStringMatchesFormat( <<7 => b"&%s;\\x00" "[]" => [] "res" => stream resource @{$res} - wrapper_type: "plainfile" +%A wrapper_type: "plainfile" stream_type: "STDIO" mode: "r" unread_bytes: 0 seekable: true - timed_out: false - blocked: true - eof: false - options: [] +%A options: [] } "obj" => DumbFoo {#%d +foo: "foo"