diff --git a/config.xsd b/config.xsd index 1b8519c31..6e6d82868 100644 --- a/config.xsd +++ b/config.xsd @@ -1,9 +1,9 @@ diff --git a/psalm.xml.dist b/psalm.xml.dist index a29f052ca..0cf1ba819 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -7,7 +7,8 @@ rememberPropertyAssignmentsAfterCall="true" throwExceptionOnError="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="config.xsd" + xmlns="https://getpsalm.org/schema/config" + xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd" > diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index abe991e64..6a64aa497 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -362,6 +362,25 @@ class Config $dom_document = new \DOMDocument(); $dom_document->loadXML($file_contents); + $psalm_nodes = $dom_document->getElementsByTagName('psalm'); + + /** @var \DomElement|null */ + $psalm_node = $psalm_nodes->item(0); + + if (!$psalm_node) { + throw new ConfigException( + 'Missing psalm node' + ); + } + + if (!$psalm_node->hasAttribute('xmlns')) { + $psalm_node->setAttribute('xmlns', 'https://getpsalm.org/schema/config'); + + $old_dom_document = $dom_document; + $dom_document = new \DOMDocument(); + $dom_document->loadXML($old_dom_document->saveXml()); + } + // Enable user error handling libxml_use_internal_errors(true);