Skip to content

Commit

Permalink
relax: modify class_attributes_separation
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Aug 3, 2024
1 parent 84c1829 commit 2372e63
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/RuleSet/Sets/Relax.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public function mainRules(): array
'default' => 'single_space',
'operators' => ['=>' => 'at_least_single_space'],
],
'class_attributes_separation' => [
'elements' => [
'trait_import' => 'none',
'const' => 'none',
'property' => 'one',
'method' => 'one',
],
],
'class_definition' => ['inline_constructor_arguments' => false, 'space_before_parenthesis' => true],
'braces_position' => ['anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end'],
'function_declaration' => ['closure_fn_spacing' => 'none'],
Expand Down
5 changes: 5 additions & 0 deletions tests/Fixtures/Ruleset/realodixspec_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class RealodixSpec
/** @var int */
const C1 = 1;

const C3 = 3;
const C4 = 4;

const C5 = 5;

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

Expand Down
4 changes: 4 additions & 0 deletions tests/Fixtures/Ruleset/realodixspec_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class RealodixSpec
/** @var int */
const C1 = 1;

const C3 = 3;
const C4 = 4;
const C5 = 5;

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

Expand Down
24 changes: 21 additions & 3 deletions tests/Fixtures/Ruleset/relax-commonbox_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,31 @@ class ClassAttributesSeparation
use trait_b;
private $a;
private $b;
/**
* @var int
*/
const C2 = 2;

/** @var int */
const SECOND = 1;
/** @var int */
const MINUTE = 60;
const C1 = 1;

const C3 = 3;
const C4 = 4;


const C5 = 5;
protected function foo() {}
protected function bar() {}
}
enum ClassAttributesSeparationEnum
{
case Case1;

case Case2;
case Case3;

case Case4;
}

/**
* class_definition
Expand Down
23 changes: 18 additions & 5 deletions tests/Fixtures/Ruleset/relax-commonbox_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,31 @@ class ClassAttributesSeparation

private $b;

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

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

const C3 = 3;
const C4 = 4;
const C5 = 5;

protected function foo() {}

protected function bar() {}
}
enum ClassAttributesSeparationEnum
{
case Case1;

case Case2;
case Case3;

case Case4;
}

/**
* class_definition
Expand All @@ -109,7 +124,6 @@ final class OrderedClassElements
protected static $protStatProp;

const C1 = 1;

const C2 = 2;

public static $pubStatProp1;
Expand Down Expand Up @@ -184,7 +198,6 @@ public function func() {}
class SingleClassElementPerStatement
{
const FOO_1 = 1;

const FOO_2 = 2;

private static $bar1 = [1, 2, 3];
Expand Down
1 change: 0 additions & 1 deletion tests/Fixtures/Ruleset/relaxplus_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ final class OrderedClassElements
use TraiB;

const C1 = 1;

const C2 = 2;

protected static $protStatProp;
Expand Down

0 comments on commit 2372e63

Please sign in to comment.