1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Don’t error on existing Psalm configs cc @ostrolucky

This commit is contained in:
Matthew Brown 2018-04-21 19:05:26 -04:00
parent 2295756793
commit da69e60cf3
3 changed files with 25 additions and 5 deletions

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="https://getpsalm.org/schema/config"
targetNamespace="https://getpsalm.org/schema/config"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="https://getpsalm.org/schema/config"
targetNamespace="https://getpsalm.org/schema/config"
elementFormDefault="qualified"
>
<xs:element name="psalm" type="PsalmType" />

View File

@ -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"
>
<projectFiles>
<directory name="src" />

View File

@ -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);