package and depencies
This commit is contained in:
41
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
41
vendor/symfony/routing/Loader/XmlFileLoader.php
vendored
@@ -35,17 +35,10 @@ class XmlFileLoader extends FileLoader
|
||||
public const SCHEME_PATH = '/schema/routing/routing-1.0.xsd';
|
||||
|
||||
/**
|
||||
* Loads an XML file.
|
||||
*
|
||||
* @param string $file An XML file path
|
||||
* @param string|null $type The resource type
|
||||
*
|
||||
* @return RouteCollection
|
||||
*
|
||||
* @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be
|
||||
* parsed because it does not validate against the scheme
|
||||
*/
|
||||
public function load($file, string $type = null)
|
||||
public function load(mixed $file, string $type = null): RouteCollection
|
||||
{
|
||||
$path = $this->locator->locate($file);
|
||||
|
||||
@@ -99,10 +92,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($resource, string $type = null)
|
||||
public function supports(mixed $resource, string $type = null): bool
|
||||
{
|
||||
return \is_string($resource) && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
|
||||
}
|
||||
@@ -161,8 +151,17 @@ class XmlFileLoader extends FileLoader
|
||||
*/
|
||||
protected function parseImport(RouteCollection $collection, \DOMElement $node, string $path, string $file)
|
||||
{
|
||||
if ('' === $resource = $node->getAttribute('resource')) {
|
||||
throw new \InvalidArgumentException(sprintf('The <import> element in file "%s" must have a "resource" attribute.', $path));
|
||||
/** @var \DOMElement $resourceElement */
|
||||
if (!($resource = $node->getAttribute('resource') ?: null) && $resourceElement = $node->getElementsByTagName('resource')[0] ?? null) {
|
||||
$resource = [];
|
||||
/** @var \DOMAttr $attribute */
|
||||
foreach ($resourceElement->attributes as $attribute) {
|
||||
$resource[$attribute->name] = $attribute->value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$resource) {
|
||||
throw new \InvalidArgumentException(sprintf('The <import> element in file "%s" must have a "resource" attribute or element.', $path));
|
||||
}
|
||||
|
||||
$type = $node->getAttribute('type');
|
||||
@@ -229,13 +228,11 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DOMDocument
|
||||
*
|
||||
* @throws \InvalidArgumentException When loading of XML file fails because of syntax errors
|
||||
* or when the XML structure is not as expected by the scheme -
|
||||
* see validate()
|
||||
*/
|
||||
protected function loadFile(string $file)
|
||||
protected function loadFile(string $file): \DOMDocument
|
||||
{
|
||||
return XmlUtils::loadFile($file, __DIR__.static::SCHEME_PATH);
|
||||
}
|
||||
@@ -288,6 +285,8 @@ class XmlFileLoader extends FileLoader
|
||||
case 'condition':
|
||||
$condition = trim($n->textContent);
|
||||
break;
|
||||
case 'resource':
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement", "option" or "condition".', $n->localName, $path));
|
||||
}
|
||||
@@ -330,10 +329,8 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
/**
|
||||
* Parses the "default" elements.
|
||||
*
|
||||
* @return array|bool|float|int|string|null
|
||||
*/
|
||||
private function parseDefaultsConfig(\DOMElement $element, string $path)
|
||||
private function parseDefaultsConfig(\DOMElement $element, string $path): array|bool|float|int|string|null
|
||||
{
|
||||
if ($this->isElementValueNull($element)) {
|
||||
return null;
|
||||
@@ -363,11 +360,9 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Recursively parses the value of a "default" element.
|
||||
*
|
||||
* @return array|bool|float|int|string|null
|
||||
*
|
||||
* @throws \InvalidArgumentException when the XML is invalid
|
||||
*/
|
||||
private function parseDefaultNode(\DOMElement $node, string $path)
|
||||
private function parseDefaultNode(\DOMElement $node, string $path): array|bool|float|int|string|null
|
||||
{
|
||||
if ($this->isElementValueNull($node)) {
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user