From 8bf7f410f7ff9cfb43f927fb4ec978505beb11d8 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Fri, 28 Apr 2023 14:21:20 +0200 Subject: [PATCH] Add missing return types --- Catalogue/AbstractOperation.php | 2 ++ Command/XliffLintCommand.php | 14 ++++++++++---- Extractor/PhpExtractor.php | 6 ++++-- Util/ArrayConverter.php | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Catalogue/AbstractOperation.php b/Catalogue/AbstractOperation.php index 419ba95e..65eea0bb 100644 --- a/Catalogue/AbstractOperation.php +++ b/Catalogue/AbstractOperation.php @@ -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); } diff --git a/Command/XliffLintCommand.php b/Command/XliffLintCommand.php index 91001c56..ba68635d 100644 --- a/Command/XliffLintCommand.php +++ b/Command/XliffLintCommand.php @@ -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), @@ -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; @@ -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)) { @@ -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), @@ -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); diff --git a/Extractor/PhpExtractor.php b/Extractor/PhpExtractor.php index 6b59c7ca..7ff27f7c 100644 --- a/Extractor/PhpExtractor.php +++ b/Extractor/PhpExtractor.php @@ -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(); @@ -178,7 +178,7 @@ private function seekToNextRelevantToken(\Iterator $tokenIterator) } } - private function skipMethodArgument(\Iterator $tokenIterator) + private function skipMethodArgument(\Iterator $tokenIterator): void { $openBraces = 0; @@ -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) { diff --git a/Util/ArrayConverter.php b/Util/ArrayConverter.php index 2f1738de..8938e54f 100644 --- a/Util/ArrayConverter.php +++ b/Util/ArrayConverter.php @@ -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;