mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 14:08:46 +02:00
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:
@@ -44,10 +44,10 @@ class XmlUtils
|
||||
* @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself
|
||||
* @throws \RuntimeException When DOM extension is missing
|
||||
*/
|
||||
public static function parse($content, $schemaOrCallable = null)
|
||||
public static function parse(string $content, $schemaOrCallable = null)
|
||||
{
|
||||
if (!\extension_loaded('dom')) {
|
||||
throw new \RuntimeException('Extension DOM is required.');
|
||||
throw new \LogicException('Extension DOM is required.');
|
||||
}
|
||||
|
||||
$internalErrors = libxml_use_internal_errors(true);
|
||||
@@ -86,7 +86,7 @@ class XmlUtils
|
||||
$e = null;
|
||||
if (\is_callable($schemaOrCallable)) {
|
||||
try {
|
||||
$valid = \call_user_func($schemaOrCallable, $dom, $internalErrors);
|
||||
$valid = $schemaOrCallable($dom, $internalErrors);
|
||||
} catch (\Exception $e) {
|
||||
$valid = false;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class XmlUtils
|
||||
* @throws XmlParsingException When XML parsing returns any errors
|
||||
* @throws \RuntimeException When DOM extension is missing
|
||||
*/
|
||||
public static function loadFile($file, $schemaOrCallable = null)
|
||||
public static function loadFile(string $file, $schemaOrCallable = null)
|
||||
{
|
||||
if (!is_file($file)) {
|
||||
throw new \InvalidArgumentException(sprintf('Resource "%s" is not a file.', $file));
|
||||
@@ -169,7 +169,7 @@ class XmlUtils
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true)
|
||||
public static function convertDomElementToArray(\DOMElement $element, bool $checkPrefix = true)
|
||||
{
|
||||
$prefix = (string) $element->prefix;
|
||||
$empty = true;
|
||||
@@ -236,15 +236,11 @@ class XmlUtils
|
||||
case 'null' === $lowercaseValue:
|
||||
return null;
|
||||
case ctype_digit($value):
|
||||
$raw = $value;
|
||||
$cast = (int) $value;
|
||||
|
||||
return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
|
||||
$raw = $value;
|
||||
$cast = (int) $value;
|
||||
|
||||
return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||
return self::isOctal($value) ? \intval($value, 8) : (($raw === (string) $cast) ? $cast : $raw);
|
||||
case 'true' === $lowercaseValue:
|
||||
return true;
|
||||
case 'false' === $lowercaseValue:
|
||||
@@ -262,7 +258,7 @@ class XmlUtils
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getXmlErrors($internalErrors)
|
||||
protected static function getXmlErrors(bool $internalErrors)
|
||||
{
|
||||
$errors = [];
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
@@ -281,4 +277,13 @@ class XmlUtils
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
private static function isOctal(string $str): bool
|
||||
{
|
||||
if ('-' === $str[0]) {
|
||||
$str = substr($str, 1);
|
||||
}
|
||||
|
||||
return $str === '0'.decoct(\intval($str, 8));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user