migration symfony 5 4 (#300)

* symfony 5.4 (diff dev)

* symfony 5.4 (working)

* symfony 5.4 (update autoload)

* symfony 5.4 (remove swiftmailer mailer implementation)

* symfony 5.4 (php doc and split Global accessor class)


### Impacted packages:

composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies

composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -25,18 +25,13 @@ class ParameterBag implements ParameterBagInterface
protected $parameters = [];
protected $resolved = false;
private $normalizedNames = [];
/**
* @param array $parameters An array of parameters
*/
public function __construct(array $parameters = [])
{
$this->add($parameters);
}
/**
* Clears all parameters.
* {@inheritdoc}
*/
public function clear()
{
@@ -44,9 +39,7 @@ class ParameterBag implements ParameterBagInterface
}
/**
* Adds parameters to the service container parameters.
*
* @param array $parameters An array of parameters
* {@inheritdoc}
*/
public function add(array $parameters)
{
@@ -66,10 +59,8 @@ class ParameterBag implements ParameterBagInterface
/**
* {@inheritdoc}
*/
public function get($name)
public function get(string $name)
{
$name = $this->normalizeName($name);
if (!\array_key_exists($name, $this->parameters)) {
if (!$name) {
throw new ParameterNotFoundException($name);
@@ -78,13 +69,13 @@ class ParameterBag implements ParameterBagInterface
$alternatives = [];
foreach ($this->parameters as $key => $parameterValue) {
$lev = levenshtein($name, $key);
if ($lev <= \strlen($name) / 3 || false !== strpos($key, $name)) {
if ($lev <= \strlen($name) / 3 || str_contains($key, $name)) {
$alternatives[] = $key;
}
}
$nonNestedAlternative = null;
if (!\count($alternatives) && false !== strpos($name, '.')) {
if (!\count($alternatives) && str_contains($name, '.')) {
$namePartsLength = array_map('strlen', explode('.', $name));
$key = substr($name, 0, -1 * (1 + array_pop($namePartsLength)));
while (\count($namePartsLength)) {
@@ -106,32 +97,27 @@ class ParameterBag implements ParameterBagInterface
}
/**
* Sets a service container parameter.
*
* @param string $name The parameter name
* @param mixed $value The parameter value
* {@inheritdoc}
*/
public function set($name, $value)
public function set(string $name, $value)
{
$this->parameters[$this->normalizeName($name)] = $value;
$this->parameters[$name] = $value;
}
/**
* {@inheritdoc}
*/
public function has($name)
public function has(string $name)
{
return \array_key_exists($this->normalizeName($name), $this->parameters);
return \array_key_exists($name, $this->parameters);
}
/**
* Removes a parameter.
*
* @param string $name The parameter name
* {@inheritdoc}
*/
public function remove($name)
public function remove(string $name)
{
unset($this->parameters[$this->normalizeName($name)]);
unset($this->parameters[$name]);
}
/**
@@ -165,7 +151,7 @@ class ParameterBag implements ParameterBagInterface
* @param mixed $value A value
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @return mixed The resolved value
* @return mixed
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
* @throws ParameterCircularReferenceException if a circular reference if detected
@@ -192,29 +178,27 @@ class ParameterBag implements ParameterBagInterface
/**
* Resolves parameters inside a string.
*
* @param string $value The string to resolve
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @return mixed The resolved string
* @return mixed
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
* @throws ParameterCircularReferenceException if a circular reference if detected
* @throws RuntimeException when a given parameter has a type problem
*/
public function resolveString($value, array $resolving = [])
public function resolveString(string $value, array $resolving = [])
{
// we do this to deal with non string values (Boolean, integer, ...)
// as the preg_replace_callback throw an exception when trying
// a non-string in a parameter value
if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
$key = $match[1];
$lcKey = strtolower($key); // strtolower() to be removed in 4.0
if (isset($resolving[$lcKey])) {
if (isset($resolving[$key])) {
throw new ParameterCircularReferenceException(array_keys($resolving));
}
$resolving[$lcKey] = true;
$resolving[$key] = true;
return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
}
@@ -226,19 +210,18 @@ class ParameterBag implements ParameterBagInterface
}
$key = $match[1];
$lcKey = strtolower($key); // strtolower() to be removed in 4.0
if (isset($resolving[$lcKey])) {
if (isset($resolving[$key])) {
throw new ParameterCircularReferenceException(array_keys($resolving));
}
$resolved = $this->get($key);
if (!\is_string($resolved) && !is_numeric($resolved)) {
throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \gettype($resolved), $value));
throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, get_debug_type($resolved), $value));
}
$resolved = (string) $resolved;
$resolving[$lcKey] = true;
$resolving[$key] = true;
return $this->isResolved() ? $resolved : $this->resolveString($resolved, $resolving);
}, $value);
@@ -290,18 +273,4 @@ class ParameterBag implements ParameterBagInterface
return $value;
}
private function normalizeName($name)
{
if (isset($this->normalizedNames[$normalizedName = strtolower($name)])) {
$normalizedName = $this->normalizedNames[$normalizedName];
if ((string) $name !== $normalizedName) {
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since Symfony 3.4.', $name, $normalizedName), \E_USER_DEPRECATED);
}
} else {
$normalizedName = $this->normalizedNames[$normalizedName] = (string) $name;
}
return $normalizedName;
}
}