Skip to content

Commit 80d9f93

Browse files
committed
Make XML the default configuration format
Signed-off-by: Luís Cobucci <[email protected]>
1 parent 91fcd78 commit 80d9f93

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,20 @@ vendor/bin/roave-backward-compatibility-check --help
121121

122122
## Configuration
123123

124-
The file `.roave-backward-compatibility-check.json` is read from the current working directory (when it exists) and sets configuration for the command.
124+
The file `.roave-backward-compatibility-check.xml` is read from the current working directory (when it exists) and sets configuration for the command.
125125

126-
It's expected to be a JSON encoded file that, optionally, contains the following properties:
127-
128-
* `baseline`: list of regexes used to filter detected changes; useful to avoid detection of known BC-breaks
126+
It's expected to be an XML file that follows our [schema](resources/schema.xsd):
129127

130128
**Example:**
131129

132-
```json
133-
{
134-
"baseline": [
135-
"#\\[BC\\] CHANGED: The parameter \\$a of TestArtifact\\\\TheClass\\#method()#",
136-
"#\\[BC\\] CHANGED: The parameter \\$b of TestArtifact\\\\TheClass\\#method2()#"
137-
]
138-
}
130+
```xml
131+
<?xml version="1.0" encoding="UTF-8" ?>
132+
<roave-bc-check
133+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
134+
xsi:noNamespaceSchemaLocation="vendor/roave/backward-compatibility-check/resources/schema.xsd">
135+
<baseline>
136+
<ignored-regex>#\[BC\] CHANGED: The parameter \$a of of TestArtifact\\TheClass\#method\(\)#</ignored-regex>
137+
<ignored-regex>#\[BC\] CHANGED: The parameter \$b of of TestArtifact\\TheClass\#method2\(\)#</ignored-regex>
138+
</baseline>
139+
</roave-bc-check>
139140
```

src/Command/DetermineConfigurationFromFilesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
use Psl\Type;
99
use Roave\BackwardCompatibility\Configuration\Configuration;
1010
use Roave\BackwardCompatibility\Configuration\ParseConfigurationFile;
11-
use Roave\BackwardCompatibility\Configuration\ParseJsonConfigurationFile;
11+
use Roave\BackwardCompatibility\Configuration\ParseXmlConfigurationFile;
1212
use Symfony\Component\Console\Output\OutputInterface;
1313

1414
/** @internal */
1515
final class DetermineConfigurationFromFilesystem
1616
{
1717
public function __construct(
18-
private readonly ParseConfigurationFile $parser = new ParseJsonConfigurationFile(),
18+
private readonly ParseConfigurationFile $parser = new ParseXmlConfigurationFile(),
1919
) {
2020
}
2121

test/e2e/Command/AssertBackwardsCompatibleTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ final class AssertBackwardsCompatibleTest extends TestCase
3030

3131
JSON;
3232

33-
private const BASELINE_CONFIGURATION = <<<'JSON'
34-
{
35-
"baseline": ["#\\[BC\\] CHANGED: The parameter \\$a of TestArtifact\\\\TheClass\\#method()#"]
36-
}
37-
38-
JSON;
33+
private const BASELINE_CONFIGURATION = <<<'XML'
34+
<?xml version="1.0" encoding="UTF-8" ?>
35+
<roave-bc-check>
36+
<baseline>
37+
<ignored-regex>#\[BC\] CHANGED: The parameter \$a of TestArtifact\\TheClass\#method.*#</ignored-regex>
38+
</baseline>
39+
</roave-bc-check>
40+
XML;
3941

4042
private const CLASS_VERSIONS = [
4143
<<<'PHP'
@@ -273,15 +275,15 @@ public function testWillPickLatestTaggedVersionOnNoGivenFrom(): void
273275

274276
public function testWillAllowSpecifyingBaselineConfiguration(): void
275277
{
276-
File\write($this->sourcesRepository . '/.roave-backward-compatibility-check.json', self::BASELINE_CONFIGURATION);
278+
File\write($this->sourcesRepository . '/.roave-backward-compatibility-check.xml', self::BASELINE_CONFIGURATION);
277279

278280
$output = Shell\execute(__DIR__ . '/../../../bin/roave-backward-compatibility-check', [
279281
'--from=' . $this->versions[0],
280282
'--to=' . $this->versions[1],
281283
], $this->sourcesRepository, [], Shell\ErrorOutputBehavior::Append);
282284

283285
self::assertStringContainsString(
284-
'.roave-backward-compatibility-check.json" as configuration file',
286+
'.roave-backward-compatibility-check.xml" as configuration file',
285287
$output,
286288
);
287289
}

0 commit comments

Comments
 (0)