Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Dec 9, 2023
1 parent ff64d0d commit 20ed12b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions doc/rules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ PHPDoc
PHPDoc should contain ``@param`` for all params.
- `phpdoc_align <./phpdoc/phpdoc_align.rst>`_

All items of the given phpdoc tags must be either left-aligned or (by default) aligned vertically.
All items of the given PHPDoc tags must be either left-aligned or (by default) aligned vertically.
- `phpdoc_annotation_without_dot <./phpdoc/phpdoc_annotation_without_dot.rst>`_

PHPDoc annotation descriptions should not be a sentence.
Expand Down Expand Up @@ -748,7 +748,7 @@ PHPDoc
Classy that does not inherit must not have ``@inheritdoc`` tags.
- `phpdoc_order_by_value <./phpdoc/phpdoc_order_by_value.rst>`_

Order phpdoc tags by value.
Order PHPDoc tags by value.
- `phpdoc_order <./phpdoc/phpdoc_order.rst>`_

Annotations in PHPDoc should be ordered in defined sequence.
Expand Down
2 changes: 1 addition & 1 deletion doc/rules/phpdoc/phpdoc_align.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Rule ``phpdoc_align``
=====================

All items of the given phpdoc tags must be either left-aligned or (by default)
All items of the given PHPDoc tags must be either left-aligned or (by default)
aligned vertically.

Configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/rules/phpdoc/phpdoc_order_by_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Rule ``phpdoc_order_by_value``
==============================

Order phpdoc tags by value.
Order PHPDoc tags by value.

Configuration
-------------
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocAlignFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function getDefinition(): FixerDefinitionInterface
EOF;

return new FixerDefinition(
'All items of the given phpdoc tags must be either left-aligned or (by default) aligned vertically.',
'All items of the given PHPDoc tags must be either left-aligned or (by default) aligned vertically.',
[
new CodeSample($code),
new CodeSample($code, ['align' => self::ALIGN_VERTICAL]),
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocOrderByValueFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class PhpdocOrderByValueFixer extends AbstractFixer implements Configurabl
public function getDefinition(): FixerDefinitionInterface
{
return new FixerDefinition(
'Order phpdoc tags by value.',
'Order PHPDoc tags by value.',
[
new CodeSample(
'<?php
Expand Down
20 changes: 16 additions & 4 deletions tests/Test/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,21 @@ protected function lintSource(string $source): ?string
return null;
}

protected static function assertCorrectCasing(string $haystack, string $needle, string $message): void
protected static function assertCorrectCasing(string $haystack, string $needle, string $fixerName, string $descriptionType): void
{
self::assertSame(substr_count(strtolower($haystack), strtolower($needle)), substr_count($haystack, $needle), $message);
$exceptions = [
'PHPUnit' => [
'description' => [
'ordered_class_elements' => 1,
],
],
];

self::assertSame(
substr_count(strtolower($haystack), strtolower($needle)),
substr_count($haystack, $needle) + ($exceptions[$needle][$descriptionType][$fixerName] ?? 0),
sprintf('[%s] `%s` must be in correct casing in %s.', $fixerName, $needle, $descriptionType)
);
}

private function getLinter(): LinterInterface
Expand All @@ -483,8 +495,8 @@ private static function assertValidDescription(string $fixerName, string $descri
{
self::assertMatchesRegularExpression('/^[A-Z`].+\.$/s', $description, sprintf('[%s] The %s must start with capital letter or a ` and end with dot.', $fixerName, $descriptionType));
self::assertStringNotContainsString('phpdocs', $description, sprintf('[%s] `PHPDoc` must not be in the plural in %s.', $fixerName, $descriptionType));
self::assertCorrectCasing($description, 'PHPDoc', sprintf('[%s] `PHPDoc` must be in correct casing in %s.', $fixerName, $descriptionType));
self::assertCorrectCasing($description, 'PHPUnit', sprintf('[%s] `PHPUnit` must be in correct casing in %s.', $fixerName, $descriptionType));
self::assertCorrectCasing($description, 'PHPDoc', $fixerName, $descriptionType);
self::assertCorrectCasing($description, 'PHPUnit', $fixerName, $descriptionType);
self::assertFalse(strpos($descriptionType, '``'), sprintf('[%s] The %s must no contain sequential backticks.', $fixerName, $descriptionType));
}

Expand Down

0 comments on commit 20ed12b

Please sign in to comment.