Merge branch '2.7' into 2.8
* 2.7: [VarDumper] Fix tests on PHP 7 [DomCrawler] Clarify the value returned by getPhpFiles() [DependencyInjection] Fix #16461 Let Container::set() replace existing aliases avoid (string) catchable fatal error for instances of __PHP_Incomplete_Class remove unnecessary retrieval and setting of data avoid (string) catchable fatal error for __PHP_Incomplete_Class instances sendContent return as parent. [FrameworkBundle] Fix a typo Added more exceptions to singularify method
This commit is contained in:
commit
1d8d43b4e7
@ -47,8 +47,9 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
))
|
||||
->setDescription('Updates the translation file')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command extract translation strings from templates
|
||||
The <info>%command.name%</info> 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.
|
||||
|
||||
|
@ -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')) {
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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'),
|
||||
|
||||
|
@ -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'),
|
||||
|
@ -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(
|
||||
<<<EOTXT
|
||||
stream resource {@{$ref}
|
||||
wrapper_type: "PHP"
|
||||
%Awrapper_type: "PHP"
|
||||
stream_type: "MEMORY"
|
||||
mode: "%s+b"
|
||||
unread_bytes: 0
|
||||
seekable: true
|
||||
uri: "php://memory"
|
||||
timed_out: false
|
||||
blocked: true
|
||||
eof: false
|
||||
options: []
|
||||
%Aoptions: []
|
||||
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
|
||||
#message: "Unexpected Exception thrown from a caster: Foobar"
|
||||
-trace: {
|
||||
|
@ -72,15 +72,12 @@ EOTXT;
|
||||
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&%s;</span>\\x00"
|
||||
"<span class=sf-dump-key>[]</span>" => []
|
||||
"<span class=sf-dump-key>res</span>" => <span class=sf-dump-note>stream resource</span> <a class=sf-dump-ref>@{$res}</a><samp>
|
||||
<span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
|
||||
%A <span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
|
||||
<span class=sf-dump-meta>stream_type</span>: "<span class=sf-dump-str title="5 characters">STDIO</span>"
|
||||
<span class=sf-dump-meta>mode</span>: "<span class=sf-dump-str>r</span>"
|
||||
<span class=sf-dump-meta>unread_bytes</span>: <span class=sf-dump-num>0</span>
|
||||
<span class=sf-dump-meta>seekable</span>: <span class=sf-dump-const>true</span>
|
||||
<span class=sf-dump-meta>timed_out</span>: <span class=sf-dump-const>false</span>
|
||||
<span class=sf-dump-meta>blocked</span>: <span class=sf-dump-const>true</span>
|
||||
<span class=sf-dump-meta>eof</span>: <span class=sf-dump-const>false</span>
|
||||
<span class=sf-dump-meta>options</span>: []
|
||||
%A <span class=sf-dump-meta>options</span>: []
|
||||
</samp>}
|
||||
"<span class=sf-dump-key>obj</span>" => <abbr title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo" class=sf-dump-note>DumbFoo</abbr> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a><samp id={$dumpId}-ref2%d>
|
||||
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
|
||||
|
Reference in New Issue
Block a user