Merge branch '3.3' into 3.4

* 3.3:
  [Profiler] Fix data collector getCasters() call
  remove symfony/process suggestion
  [DI] Remove unused dynamic property
  [Process] Fixed issue between process builder and exec
  non-conflicting anonymous service ids across files
This commit is contained in:
Nicolas Grekas 2017-07-15 10:52:56 +02:00
commit b24a338f71
10 changed files with 48 additions and 19 deletions

View File

@ -80,7 +80,6 @@
"symfony/validator": "For using validation",
"symfony/yaml": "For using the debug:config and lint:yaml commands",
"symfony/property-info": "For using the property_info service",
"symfony/process": "For using the server:run, server:start, server:stop, and server:status commands",
"symfony/web-link": "For using web links, features such as preloading, prefetching or prerendering"
},
"autoload": {

View File

@ -120,7 +120,6 @@ class PhpDumper extends Dumper
'debug' => true,
), $options);
$this->classResources = array();
$this->initializeMethodNamesMap($options['base_class']);
$this->docStar = $options['debug'] ? '*' : '';

View File

@ -121,11 +121,11 @@ class YamlFileLoader extends FileLoader
// parameters
if (isset($content['parameters'])) {
if (!is_array($content['parameters'])) {
throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $resource));
throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $path));
}
foreach ($content['parameters'] as $key => $value) {
$this->container->setParameter($key, $this->resolveServices($value, $resource, true));
$this->container->setParameter($key, $this->resolveServices($value, $path, true));
}
}
@ -136,7 +136,7 @@ class YamlFileLoader extends FileLoader
$this->anonymousServicesCount = 0;
$this->setCurrentDir(dirname($path));
try {
$this->parseDefinitions($content, $resource);
$this->parseDefinitions($content, $path);
} finally {
$this->instanceof = array();
}

View File

@ -0,0 +1,4 @@
services:
AppBundle\Foo:
arguments:
- !service {class: AppBundle\Bar }

View File

@ -0,0 +1,4 @@
services:
AppBundle\Hello:
arguments:
- !service {class: AppBundle\World}

View File

@ -501,7 +501,7 @@ class YamlFileLoaderTest extends TestCase
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage Parameter "tags" must be an array for service "Foo\Bar" in services31_invalid_tags.yml. Check your YAML syntax.
* @expectedExceptionMessageRegExp /Parameter "tags" must be an array for service "Foo\\Bar" in .+services31_invalid_tags\.yml\. Check your YAML syntax./
*/
public function testInvalidTagsWithDefaults()
{
@ -534,7 +534,7 @@ class YamlFileLoaderTest extends TestCase
$this->assertCount(1, $args);
$this->assertInstanceOf(Reference::class, $args[0]);
$this->assertTrue($container->has((string) $args[0]));
$this->assertStringStartsWith('2', (string) $args[0]);
$this->assertRegExp('/^\d+_[A-Za-z0-9]{64}$/', (string) $args[0]);
$anonymous = $container->getDefinition((string) $args[0]);
$this->assertEquals('Bar', $anonymous->getClass());
@ -546,7 +546,7 @@ class YamlFileLoaderTest extends TestCase
$this->assertInternalType('array', $factory);
$this->assertInstanceOf(Reference::class, $factory[0]);
$this->assertTrue($container->has((string) $factory[0]));
$this->assertStringStartsWith('1', (string) $factory[0]);
$this->assertRegExp('/^\d+_[A-Za-z0-9]{64}$/', (string) $factory[0]);
$this->assertEquals('constructFoo', $factory[1]);
$anonymous = $container->getDefinition((string) $factory[0]);
@ -555,6 +555,19 @@ class YamlFileLoaderTest extends TestCase
$this->assertFalse($anonymous->isAutowired());
}
public function testAnonymousServicesInDifferentFilesWithSameNameDoNotConflict()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml/foo'));
$loader->load('services.yml');
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml/bar'));
$loader->load('services.yml');
$this->assertCount(5, $container->getDefinitions());
}
public function testAnonymousServicesInInstanceof()
{
$container = new ContainerBuilder();
@ -582,7 +595,7 @@ class YamlFileLoaderTest extends TestCase
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage Creating an alias using the tag "!service" is not allowed in "anonymous_services_alias.yml".
* @expectedExceptionMessageRegExp /Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./
*/
public function testAnonymousServicesWithAliases()
{
@ -593,7 +606,7 @@ class YamlFileLoaderTest extends TestCase
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage Using an anonymous service in a parameter is not allowed in "anonymous_services_in_parameters.yml".
* @expectedExceptionMessageRegExp /Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./
*/
public function testAnonymousServicesInParameters()
{
@ -614,7 +627,7 @@ class YamlFileLoaderTest extends TestCase
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage Service "_defaults" key must be an array, "NULL" given in "bad_empty_defaults.yml".
* @expectedExceptionMessageRegExp /Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./
*/
public function testEmptyDefaultsThrowsClearException()
{
@ -625,7 +638,7 @@ class YamlFileLoaderTest extends TestCase
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage Service "_instanceof" key must be an array, "NULL" given in "bad_empty_instanceof.yml".
* @expectedExceptionMessageRegExp /Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./
*/
public function testEmptyInstanceofThrowsClearException()
{

View File

@ -16,7 +16,6 @@ use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\VarDumper\Caster\Caster;
use Symfony\Component\VarDumper\Caster\ClassStub;
@ -68,11 +67,6 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
*/
private $formsByView;
/**
* @var ValueExporter
*/
private $valueExporter;
private $hasVarDumper;
public function __construct(FormDataExtractorInterface $dataExtractor)

View File

@ -69,7 +69,7 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
if (class_exists(CutStub::class)) {
$this->cloner = new VarCloner();
$this->cloner->setMaxItems(-1);
$this->cloner->addCasters(self::getCasters());
$this->cloner->addCasters($this->getCasters());
} else {
@trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED);
$this->cloner = false;

View File

@ -268,6 +268,9 @@ class ProcessBuilder
$arguments = array_merge($this->prefix, $this->arguments);
$process = new Process($arguments, $this->cwd, $this->env, $this->input, $this->timeout, $this->options);
// to preserve the BC with symfony <3.3, we convert the array structure
// to a string structure to avoid the prefixing with the exec command
$process->setCommandLine($process->getCommandLine());
if ($this->inheritEnv) {
$process->inheritEnvironmentVariables();

View File

@ -210,4 +210,17 @@ class ProcessBuilderTest extends TestCase
$builder = ProcessBuilder::create();
$builder->setInput(array());
}
public function testDoesNotPrefixExec()
{
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.');
}
$builder = ProcessBuilder::create(array('command', '-v', 'ls'));
$process = $builder->getProcess();
$process->run();
$this->assertTrue($process->isSuccessful());
}
}