Skip to content

Allow d in short names #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ObjectCalisthenics/Rules/NoShortNameRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class NoShortNameRule extends AbstractSymplifyRule implements Configurable
*/
public function __construct(
private readonly int $minNameLength,
private readonly array $allowedShortNames = ['i', 'j', 'y', 'z']
private readonly array $allowedShortNames = ['i', 'j', 'y', 'z', 'd', 'dd']
) {
}

Expand Down Expand Up @@ -130,6 +130,9 @@ private function isNameValid(string $name): bool
return true;
}

dump($name);
dump(in_array($name, $this->allowedShortNames, true));

return in_array($name, $this->allowedShortNames, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

function d()
{
// handle dump
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ public static function provideData(): Iterator
yield [__DIR__ . '/Fixture/SkipId.php', []];

$errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'em', 3);
$yeErrorMEssage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'YE', 3);
yield [__DIR__ . '/Fixture/ShortNamingClass.php', [[$errorMessage, 9], [$yeErrorMEssage, 11]]];
$yeErrorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'YE', 3);
yield [__DIR__ . '/Fixture/ShortNamingClass.php', [[$errorMessage, 9], [$yeErrorMessage, 11]]];

$errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'n', 3);
yield [__DIR__ . '/Fixture/ShortClosureParam.php', [[$errorMessage, 11]]];
yield [__DIR__ . '/Fixture/ShortParam.php', [[$errorMessage, 9]]];

yield [__DIR__ . '/Fixture/AllowD.php', []];

$errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'n', 3);
yield [
__DIR__ . '/Fixture/ShortAssignParameter.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ services:
minNameLength: 3
allowedShortNames:
- id
- d
Loading