From 607de8b219b3dcc24003e6091888a17d63130a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 27 Dec 2021 12:45:39 +0100 Subject: [PATCH 1/2] Enhancement: Use Php73 rule set --- .php-cs-fixer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index def17ee..720c23b 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -26,7 +26,7 @@ $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, ]); From c4eb4a0522290c29254e01497f1a80caffab7aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 27 Dec 2021 12:46:07 +0100 Subject: [PATCH 2/2] Fix: Run 'make coding-standards' --- .php-cs-fixer.php | 4 ++-- src/Printer.php | 6 +++--- test/Unit/PrinterTest.php | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 720c23b..cc0b1c4 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -18,10 +18,10 @@ __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(); diff --git a/src/Printer.php b/src/Printer.php index 5b856ba..897aac0 100644 --- a/src/Printer.php +++ b/src/Printer.php @@ -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, )); } diff --git a/test/Unit/PrinterTest.php b/test/Unit/PrinterTest.php index 82f5e0e..1607442 100644 --- a/test/Unit/PrinterTest.php +++ b/test/Unit/PrinterTest.php @@ -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); @@ -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, ); } @@ -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, ); } @@ -184,7 +184,7 @@ public function testPrintPrintsPrettyWithIndent(): void $printed = $printer->print( $json, - $indent + $indent, ); self::assertSame($expected, $printed); @@ -215,7 +215,7 @@ public function testPrintPrintsPrettyWithIndentAndNewLine(string $newLine): void $expectedWithNewLine = \str_replace( \PHP_EOL, $newLine, - $expected + $expected, ); $printer = new Printer(); @@ -223,7 +223,7 @@ public function testPrintPrintsPrettyWithIndentAndNewLine(string $newLine): void $printed = $printer->print( $json, $indent, - $newLine + $newLine, ); self::assertSame($expectedWithNewLine, $printed);