diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 20686669dd..955835a040 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -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": { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 2c0f289256..1cd0d21fae 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -120,7 +120,6 @@ class PhpDumper extends Dumper 'debug' => true, ), $options); - $this->classResources = array(); $this->initializeMethodNamesMap($options['base_class']); $this->docStar = $options['debug'] ? '*' : ''; diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 8ac54173ec..221a218cc3 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -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(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bar/services.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bar/services.yml new file mode 100644 index 0000000000..0f846f5f76 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bar/services.yml @@ -0,0 +1,4 @@ +services: + AppBundle\Foo: + arguments: + - !service {class: AppBundle\Bar } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/foo/services.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/foo/services.yml new file mode 100644 index 0000000000..76eee552fa --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/foo/services.yml @@ -0,0 +1,4 @@ +services: + AppBundle\Hello: + arguments: + - !service {class: AppBundle\World} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 2c655d7189..b8ac2fc0e9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -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() { diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php index 7540449b96..378edf563b 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php @@ -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) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php index 770c985637..845c2c1380 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php @@ -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; diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 5a54689875..5c476e64f2 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -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(); diff --git a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php index c1a67afa18..36c40bf03f 100644 --- a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -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()); + } }