1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00

Update dependencies.

This commit is contained in:
Caleb Mazalevskis 2022-01-06 20:13:38 +08:00
parent 43c00721ca
commit feb9ac315b
No known key found for this signature in database
GPG key ID: 082E6BC1046FAB95
11243 changed files with 338413 additions and 11922 deletions

View file

@ -50,7 +50,11 @@ class CompiledUrlGenerator extends UrlGenerator
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
}
[$variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes] = $this->compiledRoutes[$name];
[$variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes, $deprecations] = $this->compiledRoutes[$name] + [6 => []];
foreach ($deprecations as $deprecation) {
trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
}
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
if (!\in_array('_locale', $variables, true)) {

View file

@ -11,6 +11,8 @@
namespace Symfony\Component\Routing\Generator\Dumper;
use Symfony\Component\Routing\Exception\RouteCircularReferenceException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
/**
@ -35,12 +37,57 @@ class CompiledUrlGeneratorDumper extends GeneratorDumper
$compiledRoute->getTokens(),
$compiledRoute->getHostTokens(),
$route->getSchemes(),
[],
];
}
return $compiledRoutes;
}
public function getCompiledAliases(): array
{
$routes = $this->getRoutes();
$compiledAliases = [];
foreach ($routes->getAliases() as $name => $alias) {
$deprecations = $alias->isDeprecated() ? [$alias->getDeprecation($name)] : [];
$currentId = $alias->getId();
$visited = [];
while (null !== $alias = $routes->getAlias($currentId) ?? null) {
if (false !== $searchKey = array_search($currentId, $visited)) {
$visited[] = $currentId;
throw new RouteCircularReferenceException($currentId, \array_slice($visited, $searchKey));
}
if ($alias->isDeprecated()) {
$deprecations[] = $deprecation = $alias->getDeprecation($currentId);
trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
}
$visited[] = $currentId;
$currentId = $alias->getId();
}
if (null === $target = $routes->get($currentId)) {
throw new RouteNotFoundException(sprintf('Target route "%s" for alias "%s" does not exist.', $currentId, $name));
}
$compiledTarget = $target->compile();
$compiledAliases[$name] = [
$compiledTarget->getVariables(),
$target->getDefaults(),
$target->getRequirements(),
$compiledTarget->getTokens(),
$compiledTarget->getHostTokens(),
$target->getSchemes(),
$deprecations,
];
}
return $compiledAliases;
}
/**
* {@inheritdoc}
*/
@ -68,6 +115,10 @@ EOF;
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
}
foreach ($this->getCompiledAliases() as $alias => $properties) {
$routes .= sprintf("\n '%s' => %s,", $alias, CompiledUrlMatcherDumper::export($properties));
}
return $routes;
}
}

View file

@ -24,14 +24,14 @@ interface GeneratorDumperInterface
* Dumps a set of routes to a string representation of executable code
* that can then be used to generate a URL of such a route.
*
* @return string Executable code
* @return string
*/
public function dump(array $options = []);
/**
* Gets the routes to dump.
*
* @return RouteCollection A RouteCollection instance
* @return RouteCollection
*/
public function getRoutes();
}

View file

@ -295,6 +295,17 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
return $a == $b ? 0 : 1;
});
array_walk_recursive($extra, $caster = static function (&$v) use (&$caster) {
if (\is_object($v)) {
if ($vars = get_object_vars($v)) {
array_walk_recursive($vars, $caster);
$v = $vars;
} elseif (method_exists($v, '__toString')) {
$v = (string) $v;
}
}
});
// extract fragment
$fragment = $defaults['_fragment'] ?? '';
@ -332,7 +343,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
* @param string $basePath The base path
* @param string $targetPath The target path
*
* @return string The relative target path
* @return string
*/
public static function getRelativePath(string $basePath, string $targetPath)
{

View file

@ -71,7 +71,7 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
*
* The special parameter _fragment will be used as the document fragment suffixed to the final URL.
*
* @return string The generated URL
* @return string
*
* @throws RouteNotFoundException If the named route doesn't exist
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route