diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
index 64b0cd8d94..71671774fc 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
@@ -18,6 +18,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
+use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
@@ -55,7 +56,7 @@ class AssetsInstallCommand extends Command
{
$this
->setDefinition(array(
- new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'),
+ new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', null),
))
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
@@ -92,6 +93,10 @@ EOT
$kernel = $this->getApplication()->getKernel();
$targetArg = rtrim($input->getArgument('target'), '/');
+ if (!$targetArg) {
+ $targetArg = $this->getPublicDirectory($this->getContainer());
+ }
+
if (!is_dir($targetArg)) {
$targetArg = $kernel->getContainer()->getParameter('kernel.project_dir').'/'.$targetArg;
@@ -248,4 +253,27 @@ EOT
return self::METHOD_COPY;
}
+
+ private function getPublicDirectory(ContainerInterface $container)
+ {
+ $defaultPublicDir = 'public';
+
+ if (!$container->hasParameter('kernel.project_dir')) {
+ return $defaultPublicDir;
+ }
+
+ $composerFilePath = $container->getParameter('kernel.project_dir').'/composer.json';
+
+ if (!file_exists($composerFilePath)) {
+ return $defaultPublicDir;
+ }
+
+ $composerConfig = json_decode(file_get_contents($composerFilePath), true);
+
+ if (isset($composerConfig['extra']['public-dir'])) {
+ return $composerConfig['extra']['public-dir'];
+ }
+
+ return $defaultPublicDir;
+ }
}
diff --git a/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php b/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php
index 3dc492dcd1..bf08a2bac9 100644
--- a/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php
+++ b/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php
@@ -27,8 +27,31 @@ class WebServerExtension extends Extension
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('webserver.xml');
+ $publicDirectory = $this->getPublicDirectory($container);
+ $container->getDefinition('web_server.command.server_run')->replaceArgument(0, $publicDirectory);
+ $container->getDefinition('web_server.command.server_start')->replaceArgument(0, $publicDirectory);
+
if (!class_exists(ConsoleFormatter::class)) {
$container->removeDefinition('web_server.command.server_log');
}
}
+
+ private function getPublicDirectory(ContainerBuilder $container)
+ {
+ $kernelProjectDir = $container->getParameter('kernel.project_dir');
+ $publicDir = 'public';
+ $composerFilePath = $kernelProjectDir.'/composer.json';
+
+ if (!file_exists($composerFilePath)) {
+ return $kernelProjectDir.'/'.$publicDir;
+ }
+
+ $composerConfig = json_decode(file_get_contents($composerFilePath), true);
+
+ if (isset($composerConfig['extra']['public-dir'])) {
+ $publicDir = $composerConfig['extra']['public-dir'];
+ }
+
+ return $kernelProjectDir.'/'.$publicDir;
+ }
}
diff --git a/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php b/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php
index ebc0c9421f..0d9c2f4bd5 100644
--- a/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php
+++ b/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php
@@ -21,8 +21,17 @@ class WebServerExtensionTest extends TestCase
public function testLoad()
{
$container = new ContainerBuilder();
+ $container->setParameter('kernel.project_dir', __DIR__);
(new WebServerExtension())->load(array(), $container);
+ $this->assertSame(
+ __DIR__.'/test',
+ $container->getDefinition('web_server.command.server_run')->getArgument(0)
+ );
+ $this->assertSame(
+ __DIR__.'/test',
+ $container->getDefinition('web_server.command.server_start')->getArgument(0)
+ );
$this->assertTrue($container->hasDefinition('web_server.command.server_run'));
$this->assertTrue($container->hasDefinition('web_server.command.server_start'));
$this->assertTrue($container->hasDefinition('web_server.command.server_stop'));
diff --git a/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/composer.json b/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/composer.json
new file mode 100644
index 0000000000..a4652ebdf8
--- /dev/null
+++ b/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/composer.json
@@ -0,0 +1,6 @@
+{
+ "name": "test-composer.json",
+ "extra": {
+ "public-dir": "test"
+ }
+}
diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php
index eebac82e70..d685a117eb 100644
--- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php
+++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php
@@ -157,7 +157,7 @@ class OutputFormatter implements OutputFormatterInterface
if (!$open && !$tag) {
// >
$this->styleStack->pop();
- } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
+ } elseif (false === $style = $this->createStyleFromString($tag)) {
$output .= $this->applyCurrentStyle($text);
} elseif ($open) {
$this->styleStack->push($style);
@@ -201,13 +201,14 @@ class OutputFormatter implements OutputFormatterInterface
$style = new OutputFormatterStyle();
foreach ($matches as $match) {
array_shift($match);
+ $match[0] = strtolower($match[0]);
if ('fg' == $match[0]) {
- $style->setForeground($match[1]);
+ $style->setForeground(strtolower($match[1]));
} elseif ('bg' == $match[0]) {
- $style->setBackground($match[1]);
+ $style->setBackground(strtolower($match[1]));
} elseif ('options' === $match[0]) {
- preg_match_all('([^,;]+)', $match[1], $options);
+ preg_match_all('([^,;]+)', strtolower($match[1]), $options);
$options = array_shift($options);
foreach ($options as $option) {
$style->setOption($option);
diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
index 2a36fbea5a..fcdbc3b946 100644
--- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
+++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
@@ -29,7 +29,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
protected $logger;
protected $stopwatch;
- private $called;
+ private $callStack;
private $dispatcher;
private $wrappedListeners;
private $orphanedEvents;
@@ -39,7 +39,6 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->dispatcher = $dispatcher;
$this->stopwatch = $stopwatch;
$this->logger = $logger;
- $this->called = array();
$this->wrappedListeners = array();
$this->orphanedEvents = array();
}
@@ -125,6 +124,10 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/
public function dispatch($eventName, Event $event = null)
{
+ if (null === $this->callStack) {
+ $this->callStack = new \SplObjectStorage();
+ }
+
if (null === $event) {
$event = new Event();
}
@@ -160,11 +163,15 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/
public function getCalledListeners()
{
+ if (null === $this->callStack) {
+ return array();
+ }
+
$called = array();
- foreach ($this->called as $eventName => $listeners) {
- foreach ($listeners as $listener) {
- $called[$eventName.'.'.$listener->getPretty()] = $listener->getInfo($eventName);
- }
+ foreach ($this->callStack as $listener) {
+ list($eventName) = $this->callStack->getInfo();
+
+ $called[] = $listener->getInfo($eventName);
}
return $called;
@@ -190,9 +197,9 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
foreach ($allListeners as $eventName => $listeners) {
foreach ($listeners as $listener) {
$called = false;
- if (isset($this->called[$eventName])) {
- foreach ($this->called[$eventName] as $l) {
- if ($l->getWrappedListener() === $listener) {
+ if (null !== $this->callStack) {
+ foreach ($this->callStack as $calledListener) {
+ if ($calledListener->getWrappedListener() === $listener) {
$called = true;
break;
@@ -204,12 +211,12 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
if (!$listener instanceof WrappedListener) {
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
}
- $notCalled[$eventName.'.'.$listener->getPretty()] = $listener->getInfo($eventName);
+ $notCalled[] = $listener->getInfo($eventName);
}
}
}
- uasort($notCalled, array($this, 'sortListenersByPriority'));
+ uasort($notCalled, array($this, 'sortNotCalledListeners'));
return $notCalled;
}
@@ -221,7 +228,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
public function reset()
{
- $this->called = array();
+ $this->callStack = array();
$this->orphanedEvents = array();
}
@@ -272,6 +279,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
$this->wrappedListeners[$eventName][] = $wrappedListener;
$this->dispatcher->removeListener($eventName, $listener);
$this->dispatcher->addListener($eventName, $wrappedListener, $priority);
+ $this->callStack->attach($wrappedListener, array($eventName));
}
}
@@ -300,8 +308,8 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
if (!isset($this->called[$eventName])) {
$this->called[$eventName] = new \SplObjectStorage();
}
-
- $this->called[$eventName]->attach($listener);
+ } else {
+ $this->callStack->detach($listener);
}
if (null !== $this->logger && $skipped) {
@@ -318,8 +326,12 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
}
}
- private function sortListenersByPriority($a, $b)
+ private function sortNotCalledListeners(array $a, array $b)
{
+ if (0 !== $cmp = strcmp($a['event'], $b['event'])) {
+ return $cmp;
+ }
+
if (\is_int($a['priority']) && !\is_int($b['priority'])) {
return 1;
}
diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
index d3d0cb8a45..8a547da57a 100644
--- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
+++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
@@ -46,7 +46,7 @@ interface EventDispatcherInterface
/**
* Adds an event subscriber.
*
- * The subscriber is asked for all the events he is
+ * The subscriber is asked for all the events it is
* interested in and added as a listener for these events.
*/
public function addSubscriber(EventSubscriberInterface $subscriber);
diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
index 8af778919b..6e1976b86a 100644
--- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
+++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
@@ -12,7 +12,7 @@
namespace Symfony\Component\EventDispatcher;
/**
- * An EventSubscriber knows himself what events he is interested in.
+ * An EventSubscriber knows itself what events it is interested in.
* If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
index b5c53528a7..d1bd482241 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
@@ -110,17 +110,17 @@ class TraceableEventDispatcherTest extends TestCase
$tdispatcher->addListener('foo', function () {}, 5);
$listeners = $tdispatcher->getNotCalledListeners();
- $this->assertArrayHasKey('stub', $listeners['foo.closure']);
- unset($listeners['foo.closure']['stub']);
+ $this->assertArrayHasKey('stub', $listeners[0]);
+ unset($listeners[0]['stub']);
$this->assertEquals(array(), $tdispatcher->getCalledListeners());
- $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
+ $this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$tdispatcher->dispatch('foo');
$listeners = $tdispatcher->getCalledListeners();
- $this->assertArrayHasKey('stub', $listeners['foo.closure']);
- unset($listeners['foo.closure']['stub']);
- $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
+ $this->assertArrayHasKey('stub', $listeners[0]);
+ unset($listeners[0]['stub']);
+ $this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
$this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
}
@@ -133,10 +133,10 @@ class TraceableEventDispatcherTest extends TestCase
$tdispatcher->reset();
$listeners = $tdispatcher->getNotCalledListeners();
- $this->assertArrayHasKey('stub', $listeners['foo.closure']);
- unset($listeners['foo.closure']['stub']);
+ $this->assertArrayHasKey('stub', $listeners[0]);
+ unset($listeners[0]['stub']);
$this->assertEquals(array(), $tdispatcher->getCalledListeners());
- $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
+ $this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
}
public function testGetCalledListenersNested()
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
index c9d45ba0d6..fcaf42e765 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
@@ -378,7 +378,7 @@ class ChoiceType extends AbstractType
if ($options['multiple']) {
$choiceType = __NAMESPACE__.'\CheckboxType';
// The user can check 0 or more checkboxes. If required
- // is true, he is required to check all of them.
+ // is true, they are required to check all of them.
$choiceOpts['required'] = false;
} else {
$choiceType = __NAMESPACE__.'\RadioType';
diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php
index 919b615969..a534918406 100644
--- a/src/Symfony/Component/Form/FormErrorIterator.php
+++ b/src/Symfony/Component/Form/FormErrorIterator.php
@@ -19,10 +19,9 @@ use Symfony\Component\Validator\ConstraintViolation;
/**
* Iterates over the errors of a form.
*
- * Optionally, this class supports recursive iteration. In order to iterate
- * recursively, set the constructor argument $deep to true. Now each element
- * returned by the iterator is either an instance of {@link FormError} or of
- * {@link FormErrorIterator}, in case the errors belong to a sub-form.
+ * This class supports recursive iteration. In order to iterate recursively,
+ * pass a structure of {@link FormError} and {@link FormErrorIterator} objects
+ * to the $errors constructor argument.
*
* You can also wrap the iterator into a {@link \RecursiveIteratorIterator} to
* flatten the recursive structure into a flat list of errors.
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
index c5326a3340..ff30e8b0fa 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
@@ -182,7 +182,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerIsAnObjectWithInvoke()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getHttpKernel($dispatcher, new Controller());
+ $kernel = $this->getHttpKernel($dispatcher, new TestController());
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
@@ -198,7 +198,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerIsAnArray()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getHttpKernel($dispatcher, array(new Controller(), 'controller'));
+ $kernel = $this->getHttpKernel($dispatcher, array(new TestController(), 'controller'));
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
@@ -206,7 +206,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerIsAStaticArray()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\Controller', 'staticcontroller'));
+ $kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\TestController', 'staticcontroller'));
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
@@ -363,7 +363,7 @@ class HttpKernelTest extends TestCase
}
}
-class Controller
+class TestController
{
public function __invoke()
{
diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.vi.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.vi.xlf
index 87e2025218..dac0a4d6dc 100644
--- a/src/Symfony/Component/Security/Core/Resources/translations/security.vi.xlf
+++ b/src/Symfony/Component/Security/Core/Resources/translations/security.vi.xlf
@@ -44,7 +44,7 @@
- Không tìm thấy tên người dùng username.
+ Không tìm thấy tên người dùng.
diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
index 0c64be8640..87b76ae437 100644
--- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php
@@ -170,7 +170,7 @@ class ContextListener implements ListenerInterface
try {
$refreshedUser = $provider->refreshUser($user);
- $newToken = unserialize(serialize($token));
+ $newToken = clone $token;
$newToken->setUser($refreshedUser);
// tokens can be deauthenticated if the user has been changed.
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf
index e1833c79cb..750a4d91e2 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf
@@ -40,7 +40,7 @@
- Lĩnh vực này là mất tích.
+ Lĩnh vực này bị thiếu.
@@ -132,7 +132,7 @@
- Tập tin không phải là hình ảnh.
+ Tập tin không phải là hình ảnh hợp lệ.
@@ -148,7 +148,7 @@
- Giá trị không phải là nước hợp lệ.
+ Giá trị không phải là quốc gia hợp lệ.
@@ -180,7 +180,7 @@
- Giá trị phải có chính xác {{ limit }} kí tự.|Giá trị phải có chính xác {{ limit }} kí tự.
+ Giá trị này phải có chính xác {{ limit }} kí tự.|Giá trị này phải có chính xác {{ limit }} kí tự.
@@ -204,11 +204,11 @@
- Danh sách phải chứa {{ limit }} hoặc nhiều hơn thành phần.|Danh sách phải chứa {{ limit }} hoặc nhiều hơn thành phần.
+ Danh sách phải chứa {{ limit }} thành phần hoặc nhiều hơn.|Danh sách phải chứa {{ limit }} thành phần hoặc nhiều hơn.
- Danh sách phải chứa {{ limit }} hoặc ít hơn thành phần.|Danh sách phải chứa {{ limit }} hoặc ít hơn thành phần.
+ Danh sách phải chứa {{ limit }} thành phần hoặc ít hơn.|Danh sách phải chứa {{ limit }} thành phần hoặc ít hơn.
@@ -240,11 +240,11 @@
- Giá trị không là ISSN hợp lệ.
+ Giá trị không phải là ISSN hợp lệ.
- Giá trị không phải là đơn vi tiền tệ hợp lệ.
+ Giá trị không phải là đơn vị tiền tệ hợp lệ.
@@ -268,7 +268,7 @@
- Giá trị không được phép nhỏ hơn hoặc bằng {{ compared_value }}.
+ Giá trị phải nhỏ hơn hoặc bằng {{ compared_value }}.
diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
index 2d7e73a916..e7487f5ca0 100644
--- a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
@@ -35,7 +35,7 @@ SplFileInfo {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
- inode: %d
+ inode: %i
size: %d
perms: 0%d
owner: %d
@@ -85,7 +85,7 @@ SplFileObject {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
- inode: %d
+ inode: %i
size: %d
perms: 0%d
owner: %d
@@ -105,7 +105,7 @@ SplFileObject {
maxLineLen: 0
fstat: array:26 [
"dev" => %d
- "ino" => %d
+ "ino" => %i
"nlink" => %d
"rdev" => 0
"blksize" => %i