src/Project/Loader/XML.php
public static function getXMLElementValue(SimpleXMLElement $element, string $forceType = NULL, bool $forceAll = false) {
        $normalize = function(SimpleXMLElement $element, $forced) use (&$normalize, $forceAll) {
            $type = (string) ($element['type'] ?? 'string');
            if($forced)
                $type = $forced;

            if($type == 'list') {
                $list = [];
                foreach($element->children() as $child) {
                    $key = (string)$child["key"];
                    $value = $normalize($child, $forceAll ? $forced : "");

                    if($key)
                        $list[$key] = $value;
                    else
                        $list[] = $value;
                }
                return $list;
            }

            $value = (string) $element;
            switch ($type) {
                case 'int': return (int) $value;
                case 'float': return (float) $value;
                case 'bool': return (bool) $value;
                default: break;
            }
            return $value;
        };

        return $normalize($element, $forceType);
    }
public static function getXMLElementValue(SimpleXMLElement $element, string $forceType = NULL, bool $forceAll = false) {
        $normalize = function(SimpleXMLElement $element, $forced) use (&$normalize, $forceAll) {
            $type = (string) ($element['type'] ?? 'string');
            if($forced)
                $type = $forced;

            if($type == 'list') {
                $list = [];
                foreach($element->children() as $child) {
                    $key = (string)$child["key"];
                    $value = $normalize($child, $forceAll ? $forced : "");

                    if($key)
                        $list[$key] = $value;
                    else
                        $list[] = $value;
                }
                return $list;
            }

            $value = (string) $element;
            switch ($type) {
                case 'int': return (int) $value;
                case 'float': return (float) $value;
                case 'bool': return (bool) $value;
                default: break;
            }
            return $value;
        };

        return $normalize($element, $forceType);
    }
public static function getXMLElementValue ( SimpleXMLElement $ element , string $ forceType = NULL , bool $ forceAll = false ) { $ normalize = function ( SimpleXMLElement $ element , $ forced ) use ( & $ normalize , $ forceAll ) { $ type = ( string ) ( $ element [ 'type' ] ?? 'string' ) ; if ( $ forced ) $ type = $ forced ; if ( $ type == 'list' ) { $ list = [ ] ; foreach ( $ element -> children ( ) as $ child ) { $ key = ( string ) $ child [ "key" ] ; $ value = $ normalize ( $ child , $ forceAll ? $ forced : "" ) ; if ( $ key ) $ list [ $ key ] = $ value ; else $ list [ ] = $ value ; } return $ list ; } $ value = ( string ) $ element ; switch ( $ type ) { case 'int' : return ( int ) $ value ; case 'float' : return ( float ) $ value ; case 'bool' : return ( bool ) $ value ; default : break ; } return $ value ; } ; return $ normalize ( $ element , $ forceType ) ; }
Unpacks an XML element into a value <... type="string|int|bool|float|list">....</...>
While the type list expects children like <item key="a key">...</item>

@param \SimpleXMLElement $element
@return bool|float|int|string|array
Unpacks an XML element into a value < ... type = string|int|bool|float|list > .... < / ... > While the type list expects children like <item key = a key > ... < / item >