Skip to content

Commit 6b46eae

Browse files
wouterjnicolas-grekas
authored andcommitted
Add PHP types to private methods and functions
1 parent d995a7a commit 6b46eae

File tree

5 files changed

+24
-62
lines changed

5 files changed

+24
-62
lines changed

DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ private function displayDeprecations($groups, $configuration)
354354
}
355355
}
356356

357-
private static function getPhpUnitErrorHandler()
357+
private static function getPhpUnitErrorHandler(): callable
358358
{
359359
if (!$eh = self::$errorHandler) {
360360
if (class_exists(Handler::class)) {

DeprecationErrorHandler/Configuration.php

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,15 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput
154154
$this->logFile = $logFile;
155155
}
156156

157-
/**
158-
* @return bool
159-
*/
160-
public function isEnabled()
157+
public function isEnabled(): bool
161158
{
162159
return $this->enabled;
163160
}
164161

165162
/**
166163
* @param DeprecationGroup[] $deprecationGroups
167-
*
168-
* @return bool
169164
*/
170-
public function tolerates(array $deprecationGroups)
165+
public function tolerates(array $deprecationGroups): bool
171166
{
172167
$grandTotal = 0;
173168

@@ -229,10 +224,7 @@ public function toleratesForGroup(string $groupName, array $deprecationGroups):
229224
return true;
230225
}
231226

232-
/**
233-
* @return bool
234-
*/
235-
public function isBaselineDeprecation(Deprecation $deprecation)
227+
public function isBaselineDeprecation(Deprecation $deprecation): bool
236228
{
237229
if ($deprecation->isLegacy()) {
238230
return false;
@@ -260,20 +252,17 @@ public function isBaselineDeprecation(Deprecation $deprecation)
260252
return $result;
261253
}
262254

263-
/**
264-
* @return bool
265-
*/
266-
public function isGeneratingBaseline()
255+
public function isGeneratingBaseline(): bool
267256
{
268257
return $this->generateBaseline;
269258
}
270259

271-
public function getBaselineFile()
260+
public function getBaselineFile(): string
272261
{
273262
return $this->baselineFile;
274263
}
275264

276-
public function writeBaseline()
265+
public function writeBaseline(): void
277266
{
278267
$map = [];
279268
foreach ($this->baselineDeprecations as $location => $messages) {
@@ -290,47 +279,37 @@ public function writeBaseline()
290279

291280
/**
292281
* @param string $message
293-
*
294-
* @return bool
295282
*/
296-
public function shouldDisplayStackTrace($message)
283+
public function shouldDisplayStackTrace($message): bool
297284
{
298285
return '' !== $this->regex && preg_match($this->regex, $message);
299286
}
300287

301-
/**
302-
* @return bool
303-
*/
304-
public function isInRegexMode()
288+
public function isInRegexMode(): bool
305289
{
306290
return '' !== $this->regex;
307291
}
308292

309-
/**
310-
* @return bool
311-
*/
312-
public function verboseOutput($group)
293+
public function verboseOutput($group): bool
313294
{
314295
return $this->verboseOutput[$group];
315296
}
316297

317-
public function shouldWriteToLogFile()
298+
public function shouldWriteToLogFile(): bool
318299
{
319300
return null !== $this->logFile;
320301
}
321302

322-
public function getLogFile()
303+
public function getLogFile(): ?string
323304
{
324305
return $this->logFile;
325306
}
326307

327308
/**
328309
* @param string $serializedConfiguration an encoded string, for instance
329310
* max[total]=1234&max[indirect]=42
330-
*
331-
* @return self
332311
*/
333-
public static function fromUrlEncodedString($serializedConfiguration)
312+
public static function fromUrlEncodedString($serializedConfiguration): self
334313
{
335314
parse_str($serializedConfiguration, $normalizedConfiguration);
336315
foreach (array_keys($normalizedConfiguration) as $key) {
@@ -376,29 +355,20 @@ public static function fromUrlEncodedString($serializedConfiguration)
376355
);
377356
}
378357

379-
/**
380-
* @return self
381-
*/
382-
public static function inDisabledMode()
358+
public static function inDisabledMode(): self
383359
{
384360
$configuration = new self();
385361
$configuration->enabled = false;
386362

387363
return $configuration;
388364
}
389365

390-
/**
391-
* @return self
392-
*/
393-
public static function inStrictMode()
366+
public static function inStrictMode(): self
394367
{
395368
return new self(['total' => 0]);
396369
}
397370

398-
/**
399-
* @return self
400-
*/
401-
public static function inWeakMode()
371+
public static function inWeakMode(): self
402372
{
403373
$verboseOutput = [];
404374
foreach (['unsilenced', 'direct', 'indirect', 'self', 'other'] as $group) {
@@ -408,18 +378,12 @@ public static function inWeakMode()
408378
return new self([], '', $verboseOutput);
409379
}
410380

411-
/**
412-
* @return self
413-
*/
414-
public static function fromNumber($upperBound)
381+
public static function fromNumber($upperBound): self
415382
{
416383
return new self(['total' => $upperBound]);
417384
}
418385

419-
/**
420-
* @return self
421-
*/
422-
public static function fromRegex($regex)
386+
public static function fromRegex($regex): self
423387
{
424388
return new self([], $regex);
425389
}

DeprecationErrorHandler/Deprecation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private static function getVendors()
356356
return self::$vendors;
357357
}
358358

359-
private static function addSourcePathsFromPrefixes(array $prefixesByNamespace, array $paths)
359+
private static function addSourcePathsFromPrefixes(array $prefixesByNamespace, array $paths): array
360360
{
361361
foreach ($prefixesByNamespace as $prefixes) {
362362
foreach ($prefixes as $prefix) {

DeprecationErrorHandler/DeprecationGroup.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,18 @@ public function addNotice()
5050

5151
/**
5252
* @param string $message
53-
*
54-
* @return DeprecationNotice
5553
*/
56-
private function deprecationNotice($message)
54+
private function deprecationNotice($message): DeprecationNotice
5755
{
5856
return $this->deprecationNotices[$message] ?? $this->deprecationNotices[$message] = new DeprecationNotice();
5957
}
6058

61-
public function count()
59+
public function count(): int
6260
{
6361
return $this->count;
6462
}
6563

66-
public function notices()
64+
public function notices(): array
6765
{
6866
return $this->deprecationNotices;
6967
}

DeprecationErrorHandler/DeprecationNotice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public function addProceduralOccurrence()
3737
++$this->count;
3838
}
3939

40-
public function getCountsByCaller()
40+
public function getCountsByCaller(): array
4141
{
4242
return $this->countsByCaller;
4343
}
4444

45-
public function count()
45+
public function count(): int
4646
{
4747
return $this->count;
4848
}

0 commit comments

Comments
 (0)