Skip to content

Commit 29fc000

Browse files
committed
misc
1 parent 5f5a1ef commit 29fc000

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Analyzer/UnusedDefinitionsAnalyzer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
final readonly class UnusedDefinitionsAnalyzer
2020
{
21+
/**
22+
* @var string
23+
*/
24+
private const MASK_VALUE_REGEX = '#(\:[\W\w]+)#';
25+
2126
public function __construct(
2227
private SymfonyStyle $symfonyStyle,
2328
private DefinitionMasksResolver $definitionMasksResolver,
@@ -93,7 +98,7 @@ private function isMaskUsed(AbstractMask $mask, array $featureInstructions): boo
9398

9499
if ($mask instanceof NamedMask) {
95100
// normalize :mask definition to regex
96-
$regexMask = '#' . Strings::replace($mask->mask, '#(\:[\W\w]+)#', '(.*?)') . '#';
101+
$regexMask = '#' . Strings::replace($mask->mask, self::MASK_VALUE_REGEX, '(.*?)') . '#';
97102
if ($this->isRegexDefinitionUsed($regexMask, $featureInstructions)) {
98103
return true;
99104
}

src/Command/DuplicatedDefinitionsCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5959
$classMethodContextDefinitionByClassMethodHash
6060
);
6161

62-
foreach ($classMethodContextDefinitionByClassMethodHash as $i => $classAndMethods) {
62+
$i = 0;
63+
foreach ($classMethodContextDefinitionByClassMethodHash as $classAndMethods) {
6364
$this->symfonyStyle->section(sprintf('%d)', $i + 1));
6465

6566
foreach ($classAndMethods as $classMethodContextDefinition) {
@@ -78,6 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7879
}
7980

8081
$this->symfonyStyle->newLine();
82+
++$i;
8183
}
8284

8385
$this->symfonyStyle->error(
@@ -92,8 +94,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9294
/**
9395
* @template TItem as object
9496
*
95-
* @param TItem[] $items
96-
* @return array<int, TItem>
97+
* @param array<string, TItem[]> $items
98+
* @return array<string, TItem[]>
9799
*/
98100
private function filterOutNotDuplicated(array $items): array
99101
{
@@ -103,6 +105,6 @@ private function filterOutNotDuplicated(array $items): array
103105
}
104106
}
105107

106-
return array_values($items);
108+
return $items;
107109
}
108110
}

0 commit comments

Comments
 (0)