Skip to content

Commit

Permalink
Merge pull request #405 from ergebnis/feature/php73
Browse files Browse the repository at this point in the history
Enhancement: Use `Php73` rule set
  • Loading branch information
localheinz committed Dec 27, 2021
2 parents 6a588b3 + c4eb4a0 commit def18ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .php-cs-fixer.php
Expand Up @@ -18,15 +18,15 @@
__DIR__ . '/LICENSE.md',
License\Range::since(
License\Year::fromString('2018'),
new \DateTimeZone('UTC')
new \DateTimeZone('UTC'),
),
License\Holder::fromString('Andreas M枚ller'),
License\Url::fromString('https://github.com/ergebnis/json-printer')
License\Url::fromString('https://github.com/ergebnis/json-printer'),
);

$license->save();

$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php72($license->header()), [
$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php73($license->header()), [
'escape_implicit_backslashes' => false,
'mb_str_functions' => false,
]);
Expand Down
6 changes: 3 additions & 3 deletions src/Printer.php
Expand Up @@ -41,21 +41,21 @@ public function print(string $json, string $indent = ' ', string $newLine = \
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
$json,
));
}

if (1 !== \preg_match('/^( +|\t+)$/', $indent)) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not a valid indent.',
$indent
$indent,
));
}

if (1 !== \preg_match('/^(?>\r\n|\n|\r)$/', $newLine)) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not a valid new-line character sequence.',
$newLine
$newLine,
));
}

Expand Down
16 changes: 8 additions & 8 deletions test/Unit/PrinterTest.php
Expand Up @@ -41,7 +41,7 @@ public function testPrintRejectsInvalidJson(): void
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(\sprintf(
'"%s" is not valid JSON.',
$json
$json,
));

$printer->print($json);
Expand All @@ -61,12 +61,12 @@ public function testPrintRejectsInvalidIndent(string $indent): void
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(\sprintf(
'"%s" is not a valid indent.',
$indent
$indent,
));

$printer->print(
$json,
$indent
$indent,
);
}

Expand Down Expand Up @@ -103,13 +103,13 @@ public function testPrintRejectsInvalidNewLine(string $newLine): void
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(\sprintf(
'"%s" is not a valid new-line character sequence.',
$newLine
$newLine,
));

$printer->print(
$json,
$indent,
$newLine
$newLine,
);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public function testPrintPrintsPrettyWithIndent(): void

$printed = $printer->print(
$json,
$indent
$indent,
);

self::assertSame($expected, $printed);
Expand Down Expand Up @@ -215,15 +215,15 @@ public function testPrintPrintsPrettyWithIndentAndNewLine(string $newLine): void
$expectedWithNewLine = \str_replace(
\PHP_EOL,
$newLine,
$expected
$expected,
);

$printer = new Printer();

$printed = $printer->print(
$json,
$indent,
$newLine
$newLine,
);

self::assertSame($expectedWithNewLine, $printed);
Expand Down

0 comments on commit def18ee

Please sign in to comment.