Skip to content

Commit

Permalink
Add missing return types
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Apr 28, 2023
1 parent 4d9725b commit 8bf7f41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Catalogue/AbstractOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public function moveMessagesToIntlDomainsIfPossible(string $batch = self::ALL_BA
* stores the results.
*
* @param string $domain The domain which the operation will be performed for
*
* @return void
*/
abstract protected function processDomain(string $domain);
}
14 changes: 10 additions & 4 deletions Command/XliffLintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private function validate(string $content, string $file = null): array
return ['file' => $file, 'valid' => 0 === \count($errors), 'messages' => $errors];
}

private function display(SymfonyStyle $io, array $files)
private function display(SymfonyStyle $io, array $files): int
{
return match ($this->format) {
'txt' => $this->displayTxt($io, $files),
Expand Down Expand Up @@ -196,7 +196,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGit
return min($erroredFiles, 1);
}

private function displayJson(SymfonyStyle $io, array $filesInfo)
private function displayJson(SymfonyStyle $io, array $filesInfo): int
{
$errors = 0;

Expand All @@ -212,6 +212,9 @@ private function displayJson(SymfonyStyle $io, array $filesInfo)
return min($errors, 1);
}

/**
* @return iterable<\SplFileInfo>
*/
private function getFiles(string $fileOrDirectory): iterable
{
if (is_file($fileOrDirectory)) {
Expand All @@ -229,7 +232,10 @@ private function getFiles(string $fileOrDirectory): iterable
}
}

private function getDirectoryIterator(string $directory)
/**
* @return iterable<\SplFileInfo>
*/
private function getDirectoryIterator(string $directory): iterable
{
$default = fn ($directory) => new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
Expand All @@ -243,7 +249,7 @@ private function getDirectoryIterator(string $directory)
return $default($directory);
}

private function isReadable(string $fileOrDirectory)
private function isReadable(string $fileOrDirectory): bool
{
$default = fn ($fileOrDirectory) => is_readable($fileOrDirectory);

Expand Down
6 changes: 4 additions & 2 deletions Extractor/PhpExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function normalizeToken(mixed $token): ?string
/**
* Seeks to a non-whitespace token.
*/
private function seekToNextRelevantToken(\Iterator $tokenIterator)
private function seekToNextRelevantToken(\Iterator $tokenIterator): void
{
for (; $tokenIterator->valid(); $tokenIterator->next()) {
$t = $tokenIterator->current();
Expand All @@ -178,7 +178,7 @@ private function seekToNextRelevantToken(\Iterator $tokenIterator)
}
}

private function skipMethodArgument(\Iterator $tokenIterator)
private function skipMethodArgument(\Iterator $tokenIterator): void
{
$openBraces = 0;

Expand Down Expand Up @@ -261,6 +261,8 @@ private function getValue(\Iterator $tokenIterator): string

/**
* Extracts trans message from PHP tokens.
*
* @return void
*/
protected function parseTokens(array $tokens, MessageCatalogue $catalog, string $filename)
{
Expand Down
2 changes: 1 addition & 1 deletion Util/ArrayConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function expandToTree(array $messages): array
return $tree;
}

private static function &getElementByPath(array &$tree, array $parts)
private static function &getElementByPath(array &$tree, array $parts): mixed
{
$elem = &$tree;
$parentOfElem = null;
Expand Down

0 comments on commit 8bf7f41

Please sign in to comment.