From b2db9a8b6f7c9970327a0661dcdbb667ded69c60 Mon Sep 17 00:00:00 2001 From: Kei Date: Sat, 3 Aug 2024 08:32:25 +0700 Subject: [PATCH] Add realodix style specification (#17) --- .../Fixtures/Ruleset/realodixspec_actual.php | 121 ++++++++++++++++++ .../Ruleset/realodixspec_expected.php | 120 +++++++++++++++++ .../Config/config_realodixspec.php | 11 ++ tests/Integration/RelaxRulesetTest.php | 5 + 4 files changed, 257 insertions(+) create mode 100644 tests/Fixtures/Ruleset/realodixspec_actual.php create mode 100644 tests/Fixtures/Ruleset/realodixspec_expected.php create mode 100644 tests/Integration/Config/config_realodixspec.php diff --git a/tests/Fixtures/Ruleset/realodixspec_actual.php b/tests/Fixtures/Ruleset/realodixspec_actual.php new file mode 100644 index 0000000..beed595 --- /dev/null +++ b/tests/Fixtures/Ruleset/realodixspec_actual.php @@ -0,0 +1,121 @@ +get()) + ->map(fn(\Illuminate\Routing\Route $route) => $route->uri) + ->reject(fn($value) => ! preg_match('/^[a-zA-Z\-]+$/', $value)) + ->unique()->sort() + ->toArray(); + + return null; + } + + public function array() + { + return [ + '@PER-CS' => true, + '@PER-CS2.0' => true, + '@DoctrineAnnotation' => true, + '@PHP84Migration' => true, + '@PhpCsFixer' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + ]; + } + + /** @test */ + public function test_a(): void {} + + /** + * @test + * + * @dataProvider validTypesProvider + */ + public function test_b(?int $a): void {} + + public function realodixSpec() + { + $func = [is_array(null), is_int(null)]; + $class = [new EncodingFixer, new BracesFixer, new NoClosingTagFixer]; + } +} diff --git a/tests/Fixtures/Ruleset/realodixspec_expected.php b/tests/Fixtures/Ruleset/realodixspec_expected.php new file mode 100644 index 0000000..47cbd4d --- /dev/null +++ b/tests/Fixtures/Ruleset/realodixspec_expected.php @@ -0,0 +1,120 @@ +get()) + ->map(fn(\Illuminate\Routing\Route $route) => $route->uri) + ->reject(fn($value) => ! preg_match('/^[a-zA-Z\-]+$/', $value)) + ->unique()->sort() + ->toArray(); + + return null; + } + + public function array() + { + return [ + '@PER-CS' => true, + '@PER-CS2.0' => true, + '@DoctrineAnnotation' => true, + '@PHP84Migration' => true, + '@PhpCsFixer' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + ]; + } + + /** @test */ + public function test_a(): void {} + + /** + * @test + * @dataProvider validTypesProvider + */ + public function test_b(?int $a): void {} + + public function realodixSpec() + { + $func = [is_array(null), is_int(null)]; + $class = [new EncodingFixer, new BracesFixer, new NoClosingTagFixer]; + } +} diff --git a/tests/Integration/Config/config_realodixspec.php b/tests/Integration/Config/config_realodixspec.php new file mode 100644 index 0000000..023671c --- /dev/null +++ b/tests/Integration/Config/config_realodixspec.php @@ -0,0 +1,11 @@ +in('./tests/Integration/tmp'); + +return Config::create(new RelaxPlus) + ->setFinder($finder) + ->setUsingCache(false); diff --git a/tests/Integration/RelaxRulesetTest.php b/tests/Integration/RelaxRulesetTest.php index c0d8f3a..8e1c755 100644 --- a/tests/Integration/RelaxRulesetTest.php +++ b/tests/Integration/RelaxRulesetTest.php @@ -33,4 +33,9 @@ public function testRelaxPlusRuleset(): void { $this->testFixture('relaxplus'); } + + public function testRealodixSpec(): void + { + $this->testFixture('realodixspec'); + } }