Skip to content

Commit

Permalink
Add realodix style specification (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix authored Aug 3, 2024
1 parent ec09d73 commit b2db9a8
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 0 deletions.
121 changes: 121 additions & 0 deletions tests/Fixtures/Ruleset/realodixspec_actual.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php

use PhpCsFixer\Fixer\Basic\{EncodingFixer, BracesFixer, unused_import};
use PhpCsFixer\Fixer\PhpTag\NoClosingTagFixer;

use function is_array;
use function is_int;

/**
* @property int $a
* @property-read null|int $b
* @property-write string $c
*/
class RealodixSpec
{
use Trait2, Trait3;
use Trait1;

/**
* @var int
*/
const C2 = 2;

/** @var int */
const C1 = 1;

/** @var int */
protected static $protStatProp;

/**
* @var int
*/
public static $pubStatProp1;

public $pubProp1;

protected $protProp;

public $pubProp2;

private static $privStatProp;

private $privProp;

public static $pubStatProp2;

public $pubProp3;

public function __construct(
public int $a,
public ?int $b,
public string $c
) {}

/**
* Lorem Ipsum
*
* Lorem Ipsum is simply dummy text of the printing and typesetting industry.
*/
public function comment()
{
//
}

/**
* @param null|string|boll $a comment
* @return null|string|boll comment
*
* @throws \Exception
*/
public function exampleMethod(null|string|boll $a = null): null|string|boll
{
$a = null;
if ($a === null || ! $a === true) {
echo 'null';
}

for ($i = 0; $i < 100; $i++) {
if (true) {
continue;
}
}

$c = collect(\Illuminate\Support\Facades\Route::getRoutes()->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];
}
}
120 changes: 120 additions & 0 deletions tests/Fixtures/Ruleset/realodixspec_expected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

use PhpCsFixer\Fixer\Basic\{BracesFixer, EncodingFixer};
use PhpCsFixer\Fixer\PhpTag\NoClosingTagFixer;

use function is_array;
use function is_int;

/**
* @property int $a
* @property-read null|int $b
* @property-write string $c
*/
class RealodixSpec
{
use Trait1;
use Trait2, Trait3;

/**
* @var int
*/
const C2 = 2;

/** @var int */
const C1 = 1;

/** @var int */
protected static $protStatProp;

/**
* @var int
*/
public static $pubStatProp1;

public $pubProp1;

protected $protProp;

public $pubProp2;

private static $privStatProp;

private $privProp;

public static $pubStatProp2;

public $pubProp3;

public function __construct(
public int $a,
public ?int $b,
public string $c
) {}

/**
* Lorem Ipsum
*
* Lorem Ipsum is simply dummy text of the printing and typesetting industry.
*/
public function comment()
{
//
}

/**
* @param null|string|boll $a comment
* @return null|string|boll comment
*
* @throws \Exception
*/
public function exampleMethod(null|string|boll $a = null): null|string|boll
{
$a = null;
if ($a === null || ! $a === true) {
echo 'null';
}

for ($i = 0; $i < 100; $i++) {
if (true) {
continue;
}
}

$c = collect(\Illuminate\Support\Facades\Route::getRoutes()->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];
}
}
11 changes: 11 additions & 0 deletions tests/Integration/Config/config_realodixspec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use PhpCsFixer\Finder;
use Realodix\Relax\Config;
use Realodix\Relax\RuleSet\Sets\RelaxPlus;

$finder = (new Finder)->in('./tests/Integration/tmp');

return Config::create(new RelaxPlus)
->setFinder($finder)
->setUsingCache(false);
5 changes: 5 additions & 0 deletions tests/Integration/RelaxRulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public function testRelaxPlusRuleset(): void
{
$this->testFixture('relaxplus');
}

public function testRealodixSpec(): void
{
$this->testFixture('realodixspec');
}
}

0 comments on commit b2db9a8

Please sign in to comment.