Skip to content

Commit

Permalink
relaxplus: add phpdoc_to_comment
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Aug 5, 2024
1 parent a8e1ae5 commit 849d027
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/RuleSet/Sets/RelaxPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function mainRules(): array

// Cleanup
'phpdoc_no_alias_tag' => ['replacements' => ['type' => 'var', 'link' => 'see']],
'phpdoc_to_comment' => ['ignored_tags' => ['var']],
'general_phpdoc_annotation_remove' => [
'annotations' => [
// https://github.com/doctrine/coding-standard/blob/3e88327/lib/Doctrine/ruleset.xml#L227
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixtures/Ruleset/realodixspec_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public function exampleMethod(null|string|boll $a = null): null|string|boll
->unique()->sort()
->toArray();

$u = withCount([
'visits as unique_visit_count' => function (Builder $query) {
/** @var Builder<\App\Models\Visit> $query */
$query->where('is_first_click', true);
},
]);

return null;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/Fixtures/Ruleset/realodixspec_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public function exampleMethod(string|boll|null $a = null): string|boll|null
->unique()->sort()
->toArray();

$u = withCount([
'visits as unique_visit_count' => function (Builder $query) {
/** @var Builder<\App\Models\Visit> $query */
$query->where('is_first_click', true);
},
]);

return null;
}

Expand Down
15 changes: 11 additions & 4 deletions tests/Fixtures/Ruleset/relax_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,21 @@ public function phpdoc__phpdoc_summary() {}
public function phpdoc__phpdoc_to_comment()
{
/** This should be a comment */
$foo = true;
foreach ([] as $key => $sqlite) {
$sqlite->open('');
}

// ignored_tags
// TODO: This should be a PHPDoc as the tag is on "ignored_tags" list
$bar = true;
/** @todo This should be a PHPDoc as the tag is on "ignored_tags" list */
Url::withCount([
'visits as unique_visit_count' => function (Builder $query) {
/** @var Builder<\App\Models\Visit> $query */
$query->where('is_first_click', true);
},
]);

// allow_before_return_statement
/** @var class-string */
/** \stdClass::class */
return \stdClass::class;
}

Expand Down
15 changes: 11 additions & 4 deletions tests/Fixtures/Ruleset/relax_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,21 @@ public function phpdoc__phpdoc_summary() {}
public function phpdoc__phpdoc_to_comment()
{
/** This should be a comment */
$foo = true;
foreach ([] as $key => $sqlite) {
$sqlite->open('');
}

// ignored_tags
// TODO: This should be a PHPDoc as the tag is on "ignored_tags" list
$bar = true;
/** @todo This should be a PHPDoc as the tag is on "ignored_tags" list */
Url::withCount([
'visits as unique_visit_count' => function (Builder $query) {
/** @var Builder<\App\Models\Visit> $query */
$query->where('is_first_click', true);
},
]);

// allow_before_return_statement
/** @var class-string */
/** \stdClass::class */
return \stdClass::class;
}

Expand Down
20 changes: 20 additions & 0 deletions tests/Fixtures/Ruleset/relaxplus_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ public function phpdoc__phpdoc_no_alias_tag()
/** @type string */
$foo = 'https://github.com/PHP-CS-Fixer/PHP-CS-Fixer';
}
public function phpdoc__phpdoc_to_comment()
{
/** This should be a comment */
foreach ([] as $key => $sqlite) {
$sqlite->open('');
}

// ignored_tags
/** @todo This should be a PHPDoc as the tag is on "ignored_tags" list */
Url::withCount([
'visits as unique_visit_count' => function (Builder $query) {
/** @var Builder<\App\Models\Visit> $query */
$query->where('is_first_click', true);
},
]);

// allow_before_return_statement
/** \stdClass::class */
return \stdClass::class;
}

public function string_notation__explicit_string_variable()
{
Expand Down
21 changes: 21 additions & 0 deletions tests/Fixtures/Ruleset/relaxplus_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ public function phpdoc__phpdoc_no_alias_tag()
$foo = 'https://github.com/PHP-CS-Fixer/PHP-CS-Fixer';
}

public function phpdoc__phpdoc_to_comment()
{
/* This should be a comment */
foreach ([] as $key => $sqlite) {
$sqlite->open('');
}

// ignored_tags
/* @todo This should be a PHPDoc as the tag is on "ignored_tags" list */
Url::withCount([
'visits as unique_visit_count' => function (Builder $query) {
/** @var Builder<\App\Models\Visit> $query */
$query->where('is_first_click', true);
},
]);

// allow_before_return_statement
/* \stdClass::class */
return \stdClass::class;
}

public function string_notation__explicit_string_variable()
{
$name = 'foo';
Expand Down

0 comments on commit 849d027

Please sign in to comment.