Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -57,42 +57,42 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
*
* @var array
*/
protected $parameters = array();
protected $parameters = [];
/**
* The aliases of the container.
*
* @var array
*/
protected $aliases = array();
protected $aliases = [];
/**
* The service definitions of the container.
*
* @var array
*/
protected $serviceDefinitions = array();
protected $serviceDefinitions = [];
/**
* The instantiated services.
*
* @var array
*/
protected $services = array();
protected $services = [];
/**
* The instantiated private services.
*
* @var array
*/
protected $privateServices = array();
protected $privateServices = [];
/**
* The currently loading services.
*
* @var array
*/
protected $loading = array();
protected $loading = [];
/**
* Whether the container parameters can still be changed.
@ -116,14 +116,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
* - machine_format: Whether this container definition uses the optimized
* machine-readable container format.
*/
public function __construct(array $container_definition = array()) {
public function __construct(array $container_definition = []) {
if (!empty($container_definition) && (!isset($container_definition['machine_format']) || $container_definition['machine_format'] !== TRUE)) {
throw new InvalidArgumentException('The non-optimized format is not supported by this class. Use an optimized machine-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.');
}
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : [];
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : [];
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : [];
$this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;
// Register the service_container with itself.
@ -228,7 +228,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id));
}
$arguments = array();
$arguments = [];
if (isset($definition['arguments'])) {
$arguments = $definition['arguments'];
@ -238,14 +238,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
}
if (isset($definition['file'])) {
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file'])));
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']]));
require_once $file;
}
if (isset($definition['factory'])) {
$factory = $definition['factory'];
if (is_array($factory)) {
$factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1]));
$factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]);
}
elseif (!is_string($factory)) {
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
@ -254,7 +254,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
$service = call_user_func_array($factory, $arguments);
}
else {
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']]));
$length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments);
// Optimize class instantiation for services with up to 10 parameters as
@ -322,14 +322,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
if (isset($definition['calls'])) {
foreach ($definition['calls'] as $call) {
$method = $call[0];
$arguments = array();
$arguments = [];
if (!empty($call[1])) {
$arguments = $call[1];
if ($arguments instanceof \stdClass) {
$arguments = $this->resolveServicesAndParameters($arguments);
}
}
call_user_func_array(array($service, $method), $arguments);
call_user_func_array([$service, $method], $arguments);
}
}
@ -362,7 +362,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
* {@inheritdoc}
*/
public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
if (!in_array($scope, array('container', 'request')) || ('request' === $scope && 'request' !== $id)) {
if (!in_array($scope, ['container', 'request']) || ('request' === $scope && 'request' !== $id)) {
@trigger_error('The concept of container scopes is deprecated since version 2.8 and will be removed in 3.0. Omit the third parameter.', E_USER_DEPRECATED);
}
@ -549,7 +549,7 @@ class Container implements IntrospectableContainerInterface, ResettableContainer
* An array of strings with suitable alternatives.
*/
protected function getAlternatives($search_key, array $keys) {
$alternatives = array();
$alternatives = [];
foreach ($keys as $key) {
$lev = levenshtein($search_key, $key);
if ($lev <= strlen($search_key) / 3 || strpos($key, $search_key) !== FALSE) {

View file

@ -2,6 +2,7 @@
namespace Drupal\Component\DependencyInjection\Dumper;
use Drupal\Component\Utility\Crypt;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
@ -48,7 +49,7 @@ class OptimizedPhpArrayDumper extends Dumper {
/**
* {@inheritdoc}
*/
public function dump(array $options = array()) {
public function dump(array $options = []) {
return serialize($this->getArray());
}
@ -59,7 +60,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* A PHP array representation of the service container.
*/
public function getArray() {
$definition = array();
$definition = [];
$this->aliases = $this->getAliases();
$definition['aliases'] = $this->getAliases();
$definition['parameters'] = $this->getParameters();
@ -76,7 +77,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* The aliases.
*/
protected function getAliases() {
$alias_definitions = array();
$alias_definitions = [];
$aliases = $this->container->getAliases();
foreach ($aliases as $alias => $id) {
@ -98,7 +99,7 @@ class OptimizedPhpArrayDumper extends Dumper {
*/
protected function getParameters() {
if (!$this->container->getParameterBag()->all()) {
return array();
return [];
}
$parameters = $this->container->getParameterBag()->all();
@ -114,10 +115,10 @@ class OptimizedPhpArrayDumper extends Dumper {
*/
protected function getServiceDefinitions() {
if (!$this->container->getDefinitions()) {
return array();
return [];
}
$services = array();
$services = [];
foreach ($this->container->getDefinitions() as $id => $definition) {
// Only store public service definitions, references to shared private
// services are handled in ::getReferenceCall().
@ -142,7 +143,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* An array of prepared parameters.
*/
protected function prepareParameters(array $parameters, $escape = TRUE) {
$filtered = array();
$filtered = [];
foreach ($parameters as $key => $value) {
if (is_array($value)) {
$value = $this->prepareParameters($value, $escape);
@ -167,7 +168,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* The escaped parameters.
*/
protected function escape(array $parameters) {
$args = array();
$args = [];
foreach ($parameters as $key => $value) {
if (is_array($value)) {
@ -198,7 +199,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* scope different from SCOPE_CONTAINER and SCOPE_PROTOTYPE.
*/
protected function getServiceDefinition(Definition $definition) {
$service = array();
$service = [];
if ($definition->getClass()) {
$service['class'] = $definition->getClass();
}
@ -278,11 +279,11 @@ class OptimizedPhpArrayDumper extends Dumper {
* The PHP array representation of the method calls.
*/
protected function dumpMethodCalls(array $calls) {
$code = array();
$code = [];
foreach ($calls as $key => $call) {
$method = $call[0];
$arguments = array();
$arguments = [];
if (!empty($call[1])) {
$arguments = $this->dumpCollection($call[1]);
}
@ -308,7 +309,7 @@ class OptimizedPhpArrayDumper extends Dumper {
* The collection in a suitable format.
*/
protected function dumpCollection($collection, &$resolve = FALSE) {
$code = array();
$code = [];
foreach ($collection as $key => $value) {
if (is_array($value)) {
@ -331,11 +332,11 @@ class OptimizedPhpArrayDumper extends Dumper {
return $collection;
}
return (object) array(
return (object) [
'type' => 'collection',
'value' => $code,
'resolve' => $resolve,
);
];
}
/**
@ -350,7 +351,7 @@ class OptimizedPhpArrayDumper extends Dumper {
protected function dumpCallable($callable) {
if (is_array($callable)) {
$callable[0] = $this->dumpValue($callable[0]);
$callable = array($callable[0], $callable[1]);
$callable = [$callable[0], $callable[1]];
}
return $callable;
@ -373,15 +374,15 @@ class OptimizedPhpArrayDumper extends Dumper {
protected function getPrivateServiceCall($id, Definition $definition, $shared = FALSE) {
$service_definition = $this->getServiceDefinition($definition);
if (!$id) {
$hash = hash('sha1', serialize($service_definition));
$hash = Crypt::hashBase64(serialize($service_definition));
$id = 'private__' . $hash;
}
return (object) array(
return (object) [
'type' => 'private_service',
'id' => $id,
'value' => $service_definition,
'shared' => $shared,
);
];
}
/**
@ -398,7 +399,7 @@ class OptimizedPhpArrayDumper extends Dumper {
*/
protected function dumpValue($value) {
if (is_array($value)) {
$code = array();
$code = [];
foreach ($value as $k => $v) {
$code[$k] = $this->dumpValue($v);
}
@ -481,11 +482,11 @@ class OptimizedPhpArrayDumper extends Dumper {
* A suitable representation of the service reference.
*/
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
return (object) array(
return (object) [
'type' => 'service',
'id' => $id,
'invalidBehavior' => $invalid_behavior,
);
];
}
/**
@ -498,10 +499,10 @@ class OptimizedPhpArrayDumper extends Dumper {
* A suitable representation of the parameter reference.
*/
protected function getParameterCall($name) {
return (object) array(
return (object) [
'type' => 'parameter',
'name' => $name,
);
];
}
/**

View file

@ -30,7 +30,7 @@ class PhpArrayDumper extends OptimizedPhpArrayDumper {
* {@inheritdoc}
*/
protected function dumpCollection($collection, &$resolve = FALSE) {
$code = array();
$code = [];
foreach ($collection as $key => $value) {
if (is_array($value)) {

View file

@ -27,16 +27,16 @@ class PhpArrayContainer extends Container {
/**
* {@inheritdoc}
*/
public function __construct(array $container_definition = array()) {
public function __construct(array $container_definition = []) {
if (isset($container_definition['machine_format']) && $container_definition['machine_format'] === TRUE) {
throw new InvalidArgumentException('The machine-optimized format is not supported by this class. Use a human-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper.');
}
// Do not call the parent's constructor as it would bail on the
// machine-optimized format.
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
$this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : [];
$this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : [];
$this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : [];
$this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;
// Register the service_container with itself.
@ -57,20 +57,20 @@ class PhpArrayContainer extends Container {
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id));
}
$arguments = array();
$arguments = [];
if (isset($definition['arguments'])) {
$arguments = $this->resolveServicesAndParameters($definition['arguments']);
}
if (isset($definition['file'])) {
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file'])));
$file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']]));
require_once $file;
}
if (isset($definition['factory'])) {
$factory = $definition['factory'];
if (is_array($factory)) {
$factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1]));
$factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]);
}
elseif (!is_string($factory)) {
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
@ -79,7 +79,7 @@ class PhpArrayContainer extends Container {
$service = call_user_func_array($factory, $arguments);
}
else {
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
$class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']]));
$length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments);
// Optimize class instantiation for services with up to 10 parameters as
@ -147,12 +147,12 @@ class PhpArrayContainer extends Container {
if (isset($definition['calls'])) {
foreach ($definition['calls'] as $call) {
$method = $call[0];
$arguments = array();
$arguments = [];
if (!empty($call[1])) {
$arguments = $call[1];
$arguments = $this->resolveServicesAndParameters($arguments);
}
call_user_func_array(array($service, $method), $arguments);
call_user_func_array([$service, $method], $arguments);
}
}