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

@@ -11,14 +11,19 @@
namespace Symfony\Component\Routing;
use Symfony\Component\Config\Exception\FileLoaderLoadException;
use Symfony\Component\Config\Exception\LoaderLoadException;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\ResourceInterface;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
trigger_deprecation('symfony/routing', '5.1', 'The "%s" class is deprecated, use "%s" instead.', RouteCollectionBuilder::class, RoutingConfigurator::class);
/**
* Helps add and import routes into a RouteCollection.
*
* @author Ryan Weaver <ryan@knpuniversity.com>
*
* @deprecated since Symfony 5.1, use RoutingConfigurator instead
*/
class RouteCollectionBuilder
{
@@ -48,17 +53,15 @@ class RouteCollectionBuilder
*
* $routes->import('blog.yml', '/blog');
*
* @param mixed $resource
* @param string|null $prefix
* @param string $type
* @param mixed $resource
*
* @return self
*
* @throws FileLoaderLoadException
* @throws LoaderLoadException
*/
public function import($resource, $prefix = '/', $type = null)
public function import($resource, string $prefix = '/', string $type = null)
{
/** @var RouteCollection[] $collection */
/** @var RouteCollection[] $collections */
$collections = $this->load($resource, $type);
// create a builder from the RouteCollection
@@ -87,13 +90,9 @@ class RouteCollectionBuilder
/**
* Adds a route and returns it for future modification.
*
* @param string $path The route path
* @param string $controller The route's controller
* @param string|null $name The name to give this route
*
* @return Route
*/
public function add($path, $controller, $name = null)
public function add(string $path, string $controller, string $name = null)
{
$route = new Route($path);
$route->setDefault('_controller', $controller);
@@ -114,11 +113,8 @@ class RouteCollectionBuilder
/**
* Add a RouteCollectionBuilder.
*
* @param string $prefix
* @param RouteCollectionBuilder $builder
*/
public function mount($prefix, self $builder)
public function mount(string $prefix, self $builder)
{
$builder->prefix = trim(trim($prefix), '/');
$this->routes[] = $builder;
@@ -127,11 +123,9 @@ class RouteCollectionBuilder
/**
* Adds a Route object to the builder.
*
* @param string|null $name
*
* @return $this
*/
public function addRoute(Route $route, $name = null)
public function addRoute(Route $route, string $name = null)
{
if (null === $name) {
// used as a flag to know which routes will need a name later
@@ -146,11 +140,9 @@ class RouteCollectionBuilder
/**
* Sets the host on all embedded routes (unless already set).
*
* @param string $pattern
*
* @return $this
*/
public function setHost($pattern)
public function setHost(?string $pattern)
{
$this->host = $pattern;
@@ -160,11 +152,9 @@ class RouteCollectionBuilder
/**
* Sets a condition on all embedded routes (unless already set).
*
* @param string $condition
*
* @return $this
*/
public function setCondition($condition)
public function setCondition(?string $condition)
{
$this->condition = $condition;
@@ -175,12 +165,11 @@ class RouteCollectionBuilder
* Sets a default value that will be added to all embedded routes (unless that
* default value is already set).
*
* @param string $key
* @param mixed $value
* @param mixed $value
*
* @return $this
*/
public function setDefault($key, $value)
public function setDefault(string $key, $value)
{
$this->defaults[$key] = $value;
@@ -191,12 +180,11 @@ class RouteCollectionBuilder
* Sets a requirement that will be added to all embedded routes (unless that
* requirement is already set).
*
* @param string $key
* @param mixed $regex
* @param mixed $regex
*
* @return $this
*/
public function setRequirement($key, $regex)
public function setRequirement(string $key, $regex)
{
$this->requirements[$key] = $regex;
@@ -207,12 +195,11 @@ class RouteCollectionBuilder
* Sets an option that will be added to all embedded routes (unless that
* option is already set).
*
* @param string $key
* @param mixed $value
* @param mixed $value
*
* @return $this
*/
public function setOption($key, $value)
public function setOption(string $key, $value)
{
$this->options[$key] = $value;
@@ -252,7 +239,7 @@ class RouteCollectionBuilder
*
* @return $this
*/
private function addResource(ResourceInterface $resource)
private function addResource(ResourceInterface $resource): self
{
$this->resources[] = $resource;
@@ -308,7 +295,9 @@ class RouteCollectionBuilder
} else {
/* @var self $route */
$subCollection = $route->build();
$subCollection->addPrefix($this->prefix);
if (null !== $this->prefix) {
$subCollection->addPrefix($this->prefix);
}
$routeCollection->addCollection($subCollection);
}
@@ -323,10 +312,8 @@ class RouteCollectionBuilder
/**
* Generates a route name based on details of this route.
*
* @return string
*/
private function generateRouteName(Route $route)
private function generateRouteName(Route $route): string
{
$methods = implode('_', $route->getMethods()).'_';
@@ -348,9 +335,9 @@ class RouteCollectionBuilder
*
* @return RouteCollection[]
*
* @throws FileLoaderLoadException If no loader is found
* @throws LoaderLoadException If no loader is found
*/
private function load($resource, $type = null)
private function load($resource, string $type = null): array
{
if (null === $this->loader) {
throw new \BadMethodCallException('Cannot import other routing resources: you must pass a LoaderInterface when constructing RouteCollectionBuilder.');
@@ -363,11 +350,11 @@ class RouteCollectionBuilder
}
if (null === $resolver = $this->loader->getResolver()) {
throw new FileLoaderLoadException($resource, null, null, null, $type);
throw new LoaderLoadException($resource, null, 0, null, $type);
}
if (false === $loader = $resolver->resolve($resource, $type)) {
throw new FileLoaderLoadException($resource, null, null, null, $type);
throw new LoaderLoadException($resource, null, 0, null, $type);
}
$collections = $loader->load($resource, $type);