Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DependencyInjection] fixed PhpDumper + as_files + new lines in string arguments/properties/etc of Definitions #24517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,13 @@ private function export($value)

private function doExport($value)
{
$export = var_export($value, true);
if (is_string($value) && false !== strpos($value, "\n")) {
$cleanParts = explode("\n", $value);
$cleanParts = array_map(function ($part) { return var_export($part, true); }, $cleanParts);
$export = implode('."\n".', $cleanParts);
} else {
$export = var_export($value, true);
}

if ("'" === $export[0] && $export !== $resolvedExport = $this->container->resolveEnvPlaceholders($export, "'.\$this->getEnv('string:%s').'")) {
$export = $resolvedExport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ public function testServicesWithAnonymousFactories()
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services19.php', $dumper->dump(), '->dump() dumps services with anonymous factories');
}

public function testDumpAsFilesWhenServicePropertiesContainSpaces()
{
$container = include self::$fixturesPath.'/containers/container_nl_in_argument.php';
$container->compile();
$dumper = new PhpDumper($container);
$dump = print_r($dumper->dump(array('as_files' => true, 'file' => __DIR__)), true);
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/container_nl_in_argument_as_files.txt', $dump);
}

public function testAddServiceIdWithUnsupportedCharacters()
{
$class = 'Symfony_DI_PhpDumper_Test_Unsupported_Characters';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Symfony\Component\DependencyInjection\ContainerBuilder;

$container = new ContainerBuilder();

$container
->register('foo', 'Foo')
->addArgument("string with\nnew line")
->setPublic(true)
;

$container
->register('foo2', 'Foo')
->addArgument("string with\nnl")
->setPublic(true)
;

return $container;
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
Array
(
[ContainerAx0roru/removed-ids.php] => <?php

return array(
'Psr\\Container\\ContainerInterface' => true,
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
);

[ContainerAx0roru/getFooService.php] => <?php

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'foo' shared service.

return $this->services['foo'] = new \Foo('string with'."\n".'new line');

[ContainerAx0roru/getFoo2Service.php] => <?php

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'foo2' shared service.

return $this->services['foo2'] = new \Foo('string with'."\n".'nl');

[ContainerAx0roru/Container.php] => <?php

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
*/
class ContainerAx0roru extends Container
{
private $parameters;
private $targetDirs = array();

public function __construct()
{
$dir = $this->targetDirs[0] = dirname(__DIR__);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = dirname($dir);
}
$this->services = array();
$this->fileMap = array(
'foo' => __DIR__.'/getFooService.php',
'foo2' => __DIR__.'/getFoo2Service.php',
);

$this->aliases = array();
}

public function getRemovedIds()
{
return require __DIR__.'/removed-ids.php';
}

public function compile()
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
{
return true;
}

public function isFrozen()
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);

return true;
}

protected function load($file, $lazyLoad = true)
{
return require $file;
}
}

[ProjectServiceContainer.php] => <?php

// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.

if (!class_exists(ContainerAx0roru::class, false)) {
require __DIR__.'/ContainerAx0roru/Container.php';
}

if (!class_exists(ProjectServiceContainer::class, false)) {
class_alias(ContainerAx0roru::class, ProjectServiceContainer::class, false);
}

return new ContainerAx0roru();

)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.