Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 7 additions & 26 deletions src/Symfony/Bridge/PhpUnit/ClassExistsMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ class ClassExistsMock
* Configures the classes to be checked upon existence.
*
* @param array $classes Mocked class names as keys (case-sensitive, without leading root namespace slash) and booleans as values
*
* @return void
*/
public static function withMockedClasses(array $classes)
public static function withMockedClasses(array $classes): void
{
self::$classes = $classes;
}
Expand All @@ -36,59 +34,42 @@ public static function withMockedClasses(array $classes)
* Configures the enums to be checked upon existence.
*
* @param array $enums Mocked enums names as keys (case-sensitive, without leading root namespace slash) and booleans as values
*
* @return void
*/
public static function withMockedEnums(array $enums)
public static function withMockedEnums(array $enums): void
{
self::$enums = $enums;
self::$classes += $enums;
}

/**
* @return bool
*/
public static function class_exists($name, $autoload = true)
public static function class_exists($name, $autoload = true): bool
{
$name = ltrim($name, '\\');

return isset(self::$classes[$name]) ? (bool) self::$classes[$name] : \class_exists($name, $autoload);
}

/**
* @return bool
*/
public static function interface_exists($name, $autoload = true)
public static function interface_exists($name, $autoload = true): bool
{
$name = ltrim($name, '\\');

return isset(self::$classes[$name]) ? (bool) self::$classes[$name] : \interface_exists($name, $autoload);
}

/**
* @return bool
*/
public static function trait_exists($name, $autoload = true)
public static function trait_exists($name, $autoload = true): bool
{
$name = ltrim($name, '\\');

return isset(self::$classes[$name]) ? (bool) self::$classes[$name] : \trait_exists($name, $autoload);
}

/**
* @return bool
*/
public static function enum_exists($name, $autoload = true)
public static function enum_exists($name, $autoload = true):bool
{
$name = ltrim($name, '\\');

return isset(self::$enums[$name]) ? (bool) self::$enums[$name] : \enum_exists($name, $autoload);
}

/**
* @return void
*/
public static function register($class)
public static function register($class): void
{
$self = static::class;

Expand Down
38 changes: 10 additions & 28 deletions src/Symfony/Bridge/PhpUnit/ClockMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ class ClockMock
{
private static $now;

/**
* @return bool|null
*/
public static function withClockMock($enable = null)
public static function withClockMock($enable = null): ?bool
{
if (null === $enable) {
return null !== self::$now;
Expand All @@ -33,10 +30,7 @@ public static function withClockMock($enable = null)
return null;
}

/**
* @return int
*/
public static function time()
public static function time(): int
{
if (null === self::$now) {
return \time();
Expand All @@ -45,10 +39,7 @@ public static function time()
return (int) self::$now;
}

/**
* @return int
*/
public static function sleep($s)
public static function sleep($s): int
{
if (null === self::$now) {
return \sleep($s);
Expand All @@ -59,10 +50,7 @@ public static function sleep($s)
return 0;
}

/**
* @return void
*/
public static function usleep($us)
public static function usleep($us): void
{
if (null === self::$now) {
\usleep($us);
Expand All @@ -71,6 +59,9 @@ public static function usleep($us)
}
}

/**
* @return string|float
*/
public static function microtime($asFloat = false)
{
if (null === self::$now) {
Expand All @@ -84,10 +75,7 @@ public static function microtime($asFloat = false)
return sprintf('%0.6f00 %d', self::$now - (int) self::$now, (int) self::$now);
}

/**
* @return string
*/
public static function date($format, $timestamp = null)
public static function date($format, $timestamp = null): string
{
if (null === $timestamp) {
$timestamp = self::time();
Expand All @@ -96,10 +84,7 @@ public static function date($format, $timestamp = null)
return \date($format, $timestamp);
}

/**
* @return string
*/
public static function gmdate($format, $timestamp = null)
public static function gmdate($format, $timestamp = null): string
{
if (null === $timestamp) {
$timestamp = self::time();
Expand All @@ -124,10 +109,7 @@ public static function hrtime($asNumber = false)
return [(int) self::$now, (int) $ns];
}

/**
* @return void
*/
public static function register($class)
public static function register($class): void
{
$self = static::class;

Expand Down
19 changes: 4 additions & 15 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,7 @@ private function getConfiguration()
return $this->configuration = Configuration::fromUrlEncodedString((string) $mode);
}

/**
* @param string $str
* @param bool $red
*
* @return string
*/
private static function colorize($str, $red)
private static function colorize(string $str, bool $red): string
{
if (!self::hasColorSupport()) {
return $str;
Expand All @@ -296,12 +290,9 @@ private static function colorize($str, $red)
}

/**
* @param string[] $groups
* @param Configuration $configuration
*
* @throws \InvalidArgumentException
* @param string[] $groups
*/
private function displayDeprecations($groups, $configuration)
private function displayDeprecations(array $groups, Configuration $configuration): void
{
$cmp = function ($a, $b) {
return $b->count() - $a->count();
Expand Down Expand Up @@ -397,10 +388,8 @@ private static function getPhpUnitErrorHandler(): callable
*
* Reference: Composer\XdebugHandler\Process::supportsColor
* https://github.com/composer/xdebug-handler
*
* @return bool
*/
private static function hasColorSupport()
private static function hasColorSupport(): bool
{
if (!\defined('STDOUT')) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Configuration
* @param string $baselineFile The path to the baseline file
* @param string|null $logFile The path to the log file
*/
private function __construct(array $thresholds = [], $regex = '', $verboseOutput = [], $ignoreFile = '', $generateBaseline = false, $baselineFile = '', $logFile = null)
private function __construct(array $thresholds = [], string $regex = '', array $verboseOutput = [], string $ignoreFile = '', bool $generateBaseline = false, string $baselineFile = '', string $logFile = null)
{
$groups = ['total', 'indirect', 'direct', 'self'];

Expand Down Expand Up @@ -279,10 +279,7 @@ public function writeBaseline(): void
file_put_contents($this->baselineFile, json_encode($map, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
}

/**
* @param string $message
*/
public function shouldDisplayStackTrace($message): bool
public function shouldDisplayStackTrace(string $message): bool
{
return '' !== $this->regex && preg_match($this->regex, $message);
}
Expand All @@ -308,10 +305,9 @@ public function getLogFile(): ?string
}

/**
* @param string $serializedConfiguration an encoded string, for instance
* max[total]=1234&max[indirect]=42
* @param string $serializedConfiguration An encoded string, for instance max[total]=1234&max[indirect]=42
*/
public static function fromUrlEncodedString($serializedConfiguration): self
public static function fromUrlEncodedString(string $serializedConfiguration): self
{
parse_str($serializedConfiguration, $normalizedConfiguration);
foreach (array_keys($normalizedConfiguration) as $key) {
Expand Down
Loading