Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -177,7 +177,7 @@ class GraphvizDumper extends Dumper
} catch (ParameterNotFoundException $e) {
}
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted')));
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted')));
$container->setDefinition($id, new Definition('stdClass'));
}
@ -205,7 +205,7 @@ class GraphvizDumper extends Dumper
$container->setDefinitions($this->container->getDefinitions());
$container->setAliases($this->container->getAliases());
$container->setResources($this->container->getResources());
foreach ($this->container->getScopes() as $scope => $parentScope) {
foreach ($this->container->getScopes(false) as $scope => $parentScope) {
$container->addScope(new Scope($scope, $parentScope));
}
foreach ($this->container->getExtensions() as $extension) {

View file

@ -26,6 +26,7 @@ use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
use Symfony\Component\DependencyInjection\ExpressionLanguage;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
use Symfony\Component\HttpKernel\Kernel;
/**
* PhpDumper dumps a service container as a PHP class.
@ -57,6 +58,7 @@ class PhpDumper extends Dumper
private $expressionLanguage;
private $targetDirRegex;
private $targetDirMaxMatches;
private $docStar;
/**
* @var ExpressionFunctionProviderInterface[]
@ -108,7 +110,9 @@ class PhpDumper extends Dumper
'class' => 'ProjectServiceContainer',
'base_class' => 'Container',
'namespace' => '',
'debug' => true,
), $options);
$this->docStar = $options['debug'] ? '*' : '';
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
// Build a regexp where the first root dirs are mandatory,
@ -233,9 +237,15 @@ class PhpDumper extends Dumper
array($this->getProxyDumper(), 'isProxyCandidate')
);
$code = '';
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
foreach ($definitions as $definition) {
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
$proxyCode = "\n".$this->getProxyDumper()->getProxyCode($definition);
if ($strip) {
$proxyCode = "<?php\n".$proxyCode;
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
}
$code .= $proxyCode;
}
return $code;
@ -382,9 +392,9 @@ class PhpDumper extends Dumper
$isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
$instantiation = '';
if (!$isProxyCandidate && ContainerInterface::SCOPE_CONTAINER === $definition->getScope()) {
if (!$isProxyCandidate && $definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
$instantiation = "\$this->services['$id'] = ".($simple ? '' : '$instance');
} elseif (!$isProxyCandidate && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope()) {
} elseif (!$isProxyCandidate && $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
$instantiation = "\$this->services['$id'] = \$this->scopedServices['$scope']['$id'] = ".($simple ? '' : '$instance');
} elseif (!$simple) {
$instantiation = '$instance';
@ -578,7 +588,7 @@ class PhpDumper extends Dumper
$return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryService(false), $definition->getFactoryMethod(false));
}
$scope = $definition->getScope();
$scope = $definition->getScope(false);
if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) {
if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
$return[] = '';
@ -586,11 +596,19 @@ class PhpDumper extends Dumper
$return[] = sprintf("@throws InactiveScopeException when the '%s' service is requested while the '%s' scope is not active", $id, $scope);
}
$return = implode("\n * ", $return);
if ($definition->isDeprecated()) {
if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
$return[] = '';
}
$return[] = sprintf('@deprecated %s', $definition->getDeprecationMessage($id));
}
$return = str_replace("\n * \n", "\n *\n", implode("\n * ", $return));
$doc = '';
if (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
$doc .= <<<EOF
if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
$doc .= <<<'EOF'
*
* This service is shared.
@ -599,7 +617,7 @@ EOF;
}
if (!$definition->isPublic()) {
$doc .= <<<EOF
$doc .= <<<'EOF'
*
* This service is private.
@ -608,6 +626,14 @@ EOF;
EOF;
}
if ($definition->isAutowired()) {
$doc = <<<EOF
*
* This service is autowired.
EOF;
}
if ($definition->isLazy()) {
$lazyInitialization = '$lazyLoad = true';
$lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *";
@ -621,7 +647,7 @@ EOF;
$visibility = $isProxyCandidate ? 'public' : 'protected';
$code = <<<EOF
/**
/*{$this->docStar}
* Gets the '$id' service.$doc
*$lazyInitializationDoc
* $return
@ -646,6 +672,10 @@ EOF;
if ($definition->isSynthetic()) {
$code .= sprintf(" throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id);
} else {
if ($definition->isDeprecated()) {
$code .= sprintf(" @trigger_error(%s, E_USER_DEPRECATED);\n\n", var_export($definition->getDeprecationMessage($id), true));
}
$code .=
$this->addServiceInclude($id, $definition).
$this->addServiceLocalTempVariables($id, $definition).
@ -737,7 +767,7 @@ EOF;
return <<<EOF
/**
/*{$this->docStar}
* Updates the '$id' service.
*/
protected function synchronize{$this->camelize($id)}Service()
@ -759,6 +789,10 @@ EOF;
if (null !== $definition->getFactory()) {
$callable = $definition->getFactory();
if (is_array($callable)) {
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $callable[1])) {
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $callable[1] ?: 'n/a'));
}
if ($callable[0] instanceof Reference
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
@ -825,7 +859,7 @@ use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
$bagClass
/**
/*{$this->docStar}
* $class.
*
* This class has been auto-generated
@ -851,7 +885,7 @@ EOF;
$code = <<<EOF
/**
/*{$this->docStar}
* Constructor.
*/
public function __construct()
@ -860,16 +894,16 @@ EOF;
EOF;
if (count($scopes = $this->container->getScopes()) > 0) {
if (count($scopes = $this->container->getScopes(false)) > 0) {
$code .= "\n";
$code .= ' $this->scopes = '.$this->dumpValue($scopes).";\n";
$code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren()).";\n";
$code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren(false)).";\n";
}
$code .= $this->addMethodMap();
$code .= $this->addAliases();
$code .= <<<EOF
$code .= <<<'EOF'
}
EOF;
@ -888,7 +922,7 @@ EOF;
$code = <<<EOF
/**
/*{$this->docStar}
* Constructor.
*/
public function __construct()
@ -899,17 +933,17 @@ EOF;
$code .= "\n \$this->parameters = \$this->getDefaultParameters();\n";
}
$code .= <<<EOF
$code .= <<<'EOF'
\$this->services =
\$this->scopedServices =
\$this->scopeStacks = array();
$this->services =
$this->scopedServices =
$this->scopeStacks = array();
EOF;
$code .= "\n";
if (count($scopes = $this->container->getScopes()) > 0) {
if (count($scopes = $this->container->getScopes(false)) > 0) {
$code .= ' $this->scopes = '.$this->dumpValue($scopes).";\n";
$code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren()).";\n";
$code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren(false)).";\n";
} else {
$code .= " \$this->scopes = array();\n";
$code .= " \$this->scopeChildren = array();\n";
@ -918,7 +952,7 @@ EOF;
$code .= $this->addMethodMap();
$code .= $this->addAliases();
$code .= <<<EOF
$code .= <<<'EOF'
}
EOF;
@ -935,7 +969,7 @@ EOF;
{
return <<<EOF
/**
/*{$this->docStar}
* {@inheritdoc}
*/
public function compile()
@ -1009,36 +1043,36 @@ EOF;
$code = '';
if ($this->container->isFrozen()) {
$code .= <<<EOF
$code .= <<<'EOF'
/**
* {@inheritdoc}
*/
public function getParameter(\$name)
public function getParameter($name)
{
\$name = strtolower(\$name);
$name = strtolower($name);
if (!(isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name));
if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
return \$this->parameters[\$name];
return $this->parameters[$name];
}
/**
* {@inheritdoc}
*/
public function hasParameter(\$name)
public function hasParameter($name)
{
\$name = strtolower(\$name);
$name = strtolower($name);
return isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters);
return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters);
}
/**
* {@inheritdoc}
*/
public function setParameter(\$name, \$value)
public function setParameter($name, $value)
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
}
@ -1048,19 +1082,22 @@ EOF;
*/
public function getParameterBag()
{
if (null === \$this->parameterBag) {
\$this->parameterBag = new FrozenParameterBag(\$this->parameters);
if (null === $this->parameterBag) {
$this->parameterBag = new FrozenParameterBag($this->parameters);
}
return \$this->parameterBag;
return $this->parameterBag;
}
EOF;
if ('' === $this->docStar) {
$code = str_replace('/**', '/*', $code);
}
}
$code .= <<<EOF
/**
/*{$this->docStar}
* Gets the default parameters.
*
* @return array An array of the default parameters
@ -1117,7 +1154,7 @@ EOF;
*/
private function endClass()
{
return <<<EOF
return <<<'EOF'
}
EOF;
@ -1310,8 +1347,12 @@ EOF;
}
if (is_array($factory)) {
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $factory[1])) {
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $factory[1] ?: 'n/a'));
}
if (is_string($factory[0])) {
return sprintf('\\%s::%s(%s)', $factory[0], $factory[1], implode(', ', $arguments));
return sprintf('%s::%s(%s)', $this->dumpLiteralClass($this->dumpValue($factory[0])), $factory[1], implode(', ', $arguments));
}
if ($factory[0] instanceof Definition) {
@ -1342,12 +1383,8 @@ EOF;
if (null === $class) {
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
}
$class = $this->dumpValue($class);
if (false !== strpos($class, '$')) {
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
}
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
return sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), implode(', ', $arguments));
} elseif ($value instanceof Variable) {
return '$'.$value;
} elseif ($value instanceof Reference) {
@ -1388,9 +1425,18 @@ EOF;
* @param string $class
*
* @return string
*
* @throws RuntimeException
*/
private function dumpLiteralClass($class)
{
if (false !== strpos($class, '$')) {
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
}
if (0 !== strpos($class, "'") || !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s)', $class ?: 'n/a'));
}
return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1);
}

View file

@ -126,7 +126,10 @@ class XmlDumper extends Dumper
if ($definition->getFactoryService(false)) {
$service->setAttribute('factory-service', $definition->getFactoryService(false));
}
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
if (!$definition->isShared()) {
$service->setAttribute('shared', 'false');
}
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
$service->setAttribute('scope', $scope);
}
if (!$definition->isPublic()) {
@ -142,11 +145,14 @@ class XmlDumper extends Dumper
$service->setAttribute('lazy', 'true');
}
if (null !== $decorated = $definition->getDecoratedService()) {
list($decorated, $renamedId) = $decorated;
list($decorated, $renamedId, $priority) = $decorated;
$service->setAttribute('decorates', $decorated);
if (null !== $renamedId) {
$service->setAttribute('decoration-inner-name', $renamedId);
}
if (0 !== $priority) {
$service->setAttribute('decoration-priority', $priority);
}
}
foreach ($definition->getTags() as $name => $tags) {
@ -191,6 +197,24 @@ class XmlDumper extends Dumper
$service->appendChild($factory);
}
if ($definition->isDeprecated()) {
$deprecated = $this->document->createElement('deprecated');
$deprecated->appendChild($this->document->createTextNode($definition->getDeprecationMessage('%service_id%')));
$service->appendChild($deprecated);
}
if ($definition->isAutowired()) {
$service->setAttribute('autowire', 'true');
}
foreach ($definition->getAutowiringTypes() as $autowiringTypeValue) {
$autowiringType = $this->document->createElement('autowiring-type');
$autowiringType->appendChild($this->document->createTextNode($autowiringTypeValue));
$service->appendChild($autowiringType);
}
if ($callable = $definition->getConfigurator()) {
$configurator = $this->document->createElement('configurator');
@ -283,7 +307,7 @@ class XmlDumper extends Dumper
} elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
$element->setAttribute('on-invalid', 'ignore');
}
if (!$value->isStrict()) {
if (!$value->isStrict(false)) {
$element->setAttribute('strict', 'false');
}
} elseif ($value instanceof Definition) {

View file

@ -65,7 +65,7 @@ class YamlDumper extends Dumper
$class = substr($class, 1);
}
$code .= sprintf(" class: %s\n", $class);
$code .= sprintf(" class: %s\n", $this->dumper->dump($class));
}
if (!$definition->isPublic()) {
@ -89,7 +89,7 @@ class YamlDumper extends Dumper
}
if ($definition->getFile()) {
$code .= sprintf(" file: %s\n", $definition->getFile());
$code .= sprintf(" file: %s\n", $this->dumper->dump($definition->getFile()));
}
if ($definition->isSynthetic()) {
@ -100,8 +100,24 @@ class YamlDumper extends Dumper
$code .= sprintf(" synchronized: true\n");
}
if ($definition->isDeprecated()) {
$code .= sprintf(" deprecated: %s\n", $definition->getDeprecationMessage('%service_id%'));
}
if ($definition->isAutowired()) {
$code .= " autowire: true\n";
}
$autowiringTypesCode = '';
foreach ($definition->getAutowiringTypes() as $autowiringType) {
$autowiringTypesCode .= sprintf(" - %s\n", $this->dumper->dump($autowiringType));
}
if ($autowiringTypesCode) {
$code .= sprintf(" autowiring_types:\n%s", $autowiringTypesCode);
}
if ($definition->getFactoryClass(false)) {
$code .= sprintf(" factory_class: %s\n", $definition->getFactoryClass(false));
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
}
if ($definition->isLazy()) {
@ -109,11 +125,11 @@ class YamlDumper extends Dumper
}
if ($definition->getFactoryMethod(false)) {
$code .= sprintf(" factory_method: %s\n", $definition->getFactoryMethod(false));
$code .= sprintf(" factory_method: %s\n", $this->dumper->dump($definition->getFactoryMethod(false)));
}
if ($definition->getFactoryService(false)) {
$code .= sprintf(" factory_service: %s\n", $definition->getFactoryService(false));
$code .= sprintf(" factory_service: %s\n", $this->dumper->dump($definition->getFactoryService(false)));
}
if ($definition->getArguments()) {
@ -128,16 +144,23 @@ class YamlDumper extends Dumper
$code .= sprintf(" calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
}
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) {
$code .= sprintf(" scope: %s\n", $scope);
if (!$definition->isShared()) {
$code .= " shared: false\n";
}
if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
$code .= sprintf(" scope: %s\n", $this->dumper->dump($scope));
}
if (null !== $decorated = $definition->getDecoratedService()) {
list($decorated, $renamedId) = $decorated;
list($decorated, $renamedId, $priority) = $decorated;
$code .= sprintf(" decorates: %s\n", $decorated);
if (null !== $renamedId) {
$code .= sprintf(" decoration_inner_name: %s\n", $renamedId);
}
if (0 !== $priority) {
$code .= sprintf(" decoration_priority: %s\n", $priority);
}
}
if ($callable = $definition->getFactory()) {