Merge branch '2.3' into 2.7

* 2.3:
  [DomCrawler] Clarify the value returned by getPhpFiles()
  [DependencyInjection] Fix #16461 Let Container::set() replace existing aliases
  Added more exceptions to singularify method
This commit is contained in:
Nicolas Grekas 2016-02-13 10:21:13 +01:00
commit ec7b3f2053
6 changed files with 39 additions and 1 deletions

View File

@ -193,6 +193,10 @@ class Container implements IntrospectableContainerInterface
$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')) {

View File

@ -218,6 +218,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();

View File

@ -184,6 +184,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();

View File

@ -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()
{

View File

@ -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'),

View File

@ -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'),