Skip to content

Commit e108a60

Browse files
derrabusnicolas-grekas
authored andcommitted
Add types to constructors and private/final/internal methods (Batch III)
1 parent 110e3e9 commit e108a60

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Command/LintCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function validate(string $content, int $flags, string $file = null)
137137
return ['file' => $file, 'valid' => true];
138138
}
139139

140-
private function display(SymfonyStyle $io, array $files)
140+
private function display(SymfonyStyle $io, array $files): int
141141
{
142142
switch ($this->format) {
143143
case 'txt':
@@ -149,7 +149,7 @@ private function display(SymfonyStyle $io, array $files)
149149
}
150150
}
151151

152-
private function displayTxt(SymfonyStyle $io, array $filesInfo)
152+
private function displayTxt(SymfonyStyle $io, array $filesInfo): int
153153
{
154154
$countFiles = \count($filesInfo);
155155
$erroredFiles = 0;
@@ -178,7 +178,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo)
178178
return min($erroredFiles, 1);
179179
}
180180

181-
private function displayJson(SymfonyStyle $io, array $filesInfo)
181+
private function displayJson(SymfonyStyle $io, array $filesInfo): int
182182
{
183183
$errors = 0;
184184

@@ -198,7 +198,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo)
198198
return min($errors, 1);
199199
}
200200

201-
private function getFiles(string $fileOrDirectory)
201+
private function getFiles(string $fileOrDirectory): iterable
202202
{
203203
if (is_file($fileOrDirectory)) {
204204
yield new \SplFileInfo($fileOrDirectory);
@@ -225,7 +225,7 @@ private function getStdin(): string
225225
return $yaml;
226226
}
227227

228-
private function getParser()
228+
private function getParser(): Parser
229229
{
230230
if (!$this->parser) {
231231
$this->parser = new Parser();
@@ -234,7 +234,7 @@ private function getParser()
234234
return $this->parser;
235235
}
236236

237-
private function getDirectoryIterator(string $directory)
237+
private function getDirectoryIterator(string $directory): iterable
238238
{
239239
$default = function ($directory) {
240240
return new \RecursiveIteratorIterator(
@@ -250,7 +250,7 @@ private function getDirectoryIterator(string $directory)
250250
return $default($directory);
251251
}
252252

253-
private function isReadable(string $fileOrDirectory)
253+
private function isReadable(string $fileOrDirectory): bool
254254
{
255255
$default = function ($fileOrDirectory) {
256256
return is_readable($fileOrDirectory);

Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ private function getLineTag(string $value, int $flags, bool $nextLineCheck = tru
11341134
throw new ParseException(sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
11351135
}
11361136

1137-
private function parseQuotedString($yaml)
1137+
private function parseQuotedString(string $yaml): ?string
11381138
{
11391139
if ('' === $yaml || ('"' !== $yaml[0] && "'" !== $yaml[0])) {
11401140
throw new \InvalidArgumentException(sprintf('"%s" is not a quoted string.', $yaml));
@@ -1223,7 +1223,7 @@ private function lexInlineMapping(string $yaml): string
12231223
return implode("\n", $lines);
12241224
}
12251225

1226-
private function lexInlineSequence($yaml)
1226+
private function lexInlineSequence(string $yaml): string
12271227
{
12281228
if ('' === $yaml || '[' !== $yaml[0]) {
12291229
throw new \InvalidArgumentException(sprintf('"%s" is not a sequence.', $yaml));

0 commit comments

Comments
 (0)