Skip to content

Commit ab11663

Browse files
authored
Allow d in short names (#116)
1 parent 9e216d5 commit ab11663

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/ObjectCalisthenics/Rules/NoShortNameRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class NoShortNameRule extends AbstractSymplifyRule implements Configurable
3636
*/
3737
public function __construct(
3838
private readonly int $minNameLength,
39-
private readonly array $allowedShortNames = ['i', 'j', 'y', 'z']
39+
private readonly array $allowedShortNames = ['i', 'j', 'y', 'z', 'd', 'dd']
4040
) {
4141
}
4242

@@ -130,6 +130,9 @@ private function isNameValid(string $name): bool
130130
return true;
131131
}
132132

133+
dump($name);
134+
dump(in_array($name, $this->allowedShortNames, true));
135+
133136
return in_array($name, $this->allowedShortNames, true);
134137
}
135138
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
function d()
6+
{
7+
// handle dump
8+
}

tests/ObjectCalisthenics/Rules/NoShortNameRule/NoShortNameRuleTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ public static function provideData(): Iterator
2626
yield [__DIR__ . '/Fixture/SkipId.php', []];
2727

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

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

36+
yield [__DIR__ . '/Fixture/AllowD.php', []];
37+
3638
$errorMessage = sprintf(NoShortNameRule::ERROR_MESSAGE, 'n', 3);
3739
yield [
3840
__DIR__ . '/Fixture/ShortAssignParameter.php',

tests/ObjectCalisthenics/Rules/NoShortNameRule/config/configured_rule.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ services:
99
minNameLength: 3
1010
allowedShortNames:
1111
- id
12+
- d

0 commit comments

Comments
 (0)