package and depencies
This commit is contained in:
@@ -16,7 +16,7 @@ use Symfony\Component\Routing\Alias;
|
||||
|
||||
class AliasConfigurator
|
||||
{
|
||||
private $alias;
|
||||
private Alias $alias;
|
||||
|
||||
public function __construct(Alias $alias)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ class AliasConfigurator
|
||||
*
|
||||
* @throws InvalidArgumentException when the message template is invalid
|
||||
*/
|
||||
public function deprecate(string $package, string $version, string $message): self
|
||||
public function deprecate(string $package, string $version, string $message): static
|
||||
{
|
||||
$this->alias->setDeprecated($package, $version, $message);
|
||||
|
||||
|
@@ -23,10 +23,10 @@ class CollectionConfigurator
|
||||
use Traits\HostTrait;
|
||||
use Traits\RouteTrait;
|
||||
|
||||
private $parent;
|
||||
private $parentConfigurator;
|
||||
private $parentPrefixes;
|
||||
private $host;
|
||||
private RouteCollection $parent;
|
||||
private ?CollectionConfigurator $parentConfigurator;
|
||||
private ?array $parentPrefixes;
|
||||
private string|array|null $host = null;
|
||||
|
||||
public function __construct(RouteCollection $parent, string $name, self $parentConfigurator = null, array $parentPrefixes = null)
|
||||
{
|
||||
@@ -38,10 +38,7 @@ class CollectionConfigurator
|
||||
$this->parentPrefixes = $parentPrefixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||
}
|
||||
@@ -78,7 +75,7 @@ class CollectionConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix): self
|
||||
final public function prefix(string|array $prefix): static
|
||||
{
|
||||
if (\is_array($prefix)) {
|
||||
if (null === $this->parentPrefixes) {
|
||||
@@ -111,7 +108,7 @@ class CollectionConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function host($host): self
|
||||
final public function host(string|array $host): static
|
||||
{
|
||||
$this->host = $host;
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class ImportConfigurator
|
||||
use Traits\PrefixTrait;
|
||||
use Traits\RouteTrait;
|
||||
|
||||
private $parent;
|
||||
private RouteCollection $parent;
|
||||
|
||||
public function __construct(RouteCollection $parent, RouteCollection $route)
|
||||
{
|
||||
@@ -30,10 +30,7 @@ class ImportConfigurator
|
||||
$this->route = $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||
}
|
||||
@@ -55,7 +52,7 @@ class ImportConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix, bool $trailingSlashOnRoot = true): self
|
||||
final public function prefix(string|array $prefix, bool $trailingSlashOnRoot = true): static
|
||||
{
|
||||
$this->addPrefix($this->route, $prefix, $trailingSlashOnRoot);
|
||||
|
||||
@@ -67,7 +64,7 @@ class ImportConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function namePrefix(string $namePrefix): self
|
||||
final public function namePrefix(string $namePrefix): static
|
||||
{
|
||||
$this->route->addNamePrefix($namePrefix);
|
||||
|
||||
@@ -81,7 +78,7 @@ class ImportConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function host($host): self
|
||||
final public function host(string|array $host): static
|
||||
{
|
||||
$this->addHost($this->route, $host);
|
||||
|
||||
|
@@ -40,7 +40,7 @@ class RouteConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function host($host): self
|
||||
final public function host(string|array $host): static
|
||||
{
|
||||
$this->addHost($this->route, $host);
|
||||
|
||||
|
@@ -21,10 +21,10 @@ class RoutingConfigurator
|
||||
{
|
||||
use Traits\AddTrait;
|
||||
|
||||
private $loader;
|
||||
private $path;
|
||||
private $file;
|
||||
private $env;
|
||||
private PhpFileLoader $loader;
|
||||
private string $path;
|
||||
private string $file;
|
||||
private ?string $env;
|
||||
|
||||
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file, string $env = null)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class RoutingConfigurator
|
||||
/**
|
||||
* @param string|string[]|null $exclude Glob patterns to exclude from the import
|
||||
*/
|
||||
final public function import($resource, string $type = null, bool $ignoreErrors = false, $exclude = null): ImportConfigurator
|
||||
final public function import(string|array $resource, string $type = null, bool $ignoreErrors = false, string|array $exclude = null): ImportConfigurator
|
||||
{
|
||||
$this->loader->setCurrentDir(\dirname($this->path));
|
||||
|
||||
@@ -68,10 +68,7 @@ class RoutingConfigurator
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
final public function withPath(string $path): self
|
||||
final public function withPath(string $path): static
|
||||
{
|
||||
$clone = clone $this;
|
||||
$clone->path = $clone->file = $path;
|
||||
|
@@ -35,7 +35,7 @@ trait AddTrait
|
||||
*
|
||||
* @param string|array $path the path, or the localized paths of the route
|
||||
*/
|
||||
public function add(string $name, $path): RouteConfigurator
|
||||
public function add(string $name, string|array $path): RouteConfigurator
|
||||
{
|
||||
$parentConfigurator = $this instanceof CollectionConfigurator ? $this : ($this instanceof RouteConfigurator ? $this->parentConfigurator : null);
|
||||
$route = $this->createLocalizedRoute($this->collection, $name, $path, $this->name, $this->prefixes);
|
||||
@@ -53,7 +53,7 @@ trait AddTrait
|
||||
*
|
||||
* @param string|array $path the path, or the localized paths of the route
|
||||
*/
|
||||
public function __invoke(string $name, $path): RouteConfigurator
|
||||
public function __invoke(string $name, string|array $path): RouteConfigurator
|
||||
{
|
||||
return $this->add($name, $path);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
*/
|
||||
trait HostTrait
|
||||
{
|
||||
final protected function addHost(RouteCollection $routes, $hosts)
|
||||
final protected function addHost(RouteCollection $routes, string|array $hosts)
|
||||
{
|
||||
if (!$hosts || !\is_array($hosts)) {
|
||||
$routes->setHost($hosts ?: '');
|
||||
|
@@ -27,7 +27,7 @@ trait LocalizedRouteTrait
|
||||
*
|
||||
* @param string|array $path the path, or the localized paths of the route
|
||||
*/
|
||||
final protected function createLocalizedRoute(RouteCollection $collection, string $name, $path, string $namePrefix = '', array $prefixes = null): RouteCollection
|
||||
final protected function createLocalizedRoute(RouteCollection $collection, string $name, string|array $path, string $namePrefix = '', array $prefixes = null): RouteCollection
|
||||
{
|
||||
$paths = [];
|
||||
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
*/
|
||||
trait PrefixTrait
|
||||
{
|
||||
final protected function addPrefix(RouteCollection $routes, $prefix, bool $trailingSlashOnRoot)
|
||||
final protected function addPrefix(RouteCollection $routes, string|array $prefix, bool $trailingSlashOnRoot)
|
||||
{
|
||||
if (\is_array($prefix)) {
|
||||
foreach ($prefix as $locale => $localePrefix) {
|
||||
|
@@ -26,7 +26,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function defaults(array $defaults): self
|
||||
final public function defaults(array $defaults): static
|
||||
{
|
||||
$this->route->addDefaults($defaults);
|
||||
|
||||
@@ -38,7 +38,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function requirements(array $requirements): self
|
||||
final public function requirements(array $requirements): static
|
||||
{
|
||||
$this->route->addRequirements($requirements);
|
||||
|
||||
@@ -50,7 +50,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function options(array $options): self
|
||||
final public function options(array $options): static
|
||||
{
|
||||
$this->route->addOptions($options);
|
||||
|
||||
@@ -62,7 +62,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function utf8(bool $utf8 = true): self
|
||||
final public function utf8(bool $utf8 = true): static
|
||||
{
|
||||
$this->route->addOptions(['utf8' => $utf8]);
|
||||
|
||||
@@ -74,7 +74,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function condition(string $condition): self
|
||||
final public function condition(string $condition): static
|
||||
{
|
||||
$this->route->setCondition($condition);
|
||||
|
||||
@@ -86,7 +86,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function host(string $pattern): self
|
||||
final public function host(string $pattern): static
|
||||
{
|
||||
$this->route->setHost($pattern);
|
||||
|
||||
@@ -101,7 +101,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function schemes(array $schemes): self
|
||||
final public function schemes(array $schemes): static
|
||||
{
|
||||
$this->route->setSchemes($schemes);
|
||||
|
||||
@@ -116,7 +116,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function methods(array $methods): self
|
||||
final public function methods(array $methods): static
|
||||
{
|
||||
$this->route->setMethods($methods);
|
||||
|
||||
@@ -130,7 +130,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function controller($controller): self
|
||||
final public function controller(callable|string|array $controller): static
|
||||
{
|
||||
$this->route->addDefaults(['_controller' => $controller]);
|
||||
|
||||
@@ -142,7 +142,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function locale(string $locale): self
|
||||
final public function locale(string $locale): static
|
||||
{
|
||||
$this->route->addDefaults(['_locale' => $locale]);
|
||||
|
||||
@@ -154,7 +154,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function format(string $format): self
|
||||
final public function format(string $format): static
|
||||
{
|
||||
$this->route->addDefaults(['_format' => $format]);
|
||||
|
||||
@@ -166,7 +166,7 @@ trait RouteTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function stateless(bool $stateless = true): self
|
||||
final public function stateless(bool $stateless = true): static
|
||||
{
|
||||
$this->route->addDefaults(['_stateless' => $stateless]);
|
||||
|
||||
|
Reference in New Issue
Block a user