Permalink
Browse files

added missing typehints

  • Loading branch information...
dg committed Oct 5, 2018
1 parent 2b45308 commit 2c04b766aa185f6e8ce93a6bef41c222383b6886
@@ -51,7 +51,7 @@ public static function start(string $file): void
throw new \LogicException('Code coverage functionality requires Xdebug extension or phpdbg SAPI.');
}
register_shutdown_function(function () {
register_shutdown_function(function (): void {
register_shutdown_function([__CLASS__, 'save']);
});
}
@@ -51,7 +51,7 @@ public function __construct(string $file, array $sources = [])
throw new \Exception("Content of file '$file' is invalid.");
}
$this->data = array_filter($this->data, function (string $path) {
$this->data = array_filter($this->data, function (string $path): bool {
return @is_file($path); // @ some files or wrappers may not exist, i.e. mock://
}, ARRAY_FILTER_USE_KEY);
@@ -134,5 +134,5 @@ protected static function getCommonFilesPath(array $files): string
}
abstract protected function renderSelf();
abstract protected function renderSelf(): void;
}
@@ -40,7 +40,7 @@ class Assert
'%(\[.+\][+*?{},\d]*)%' => '$1', // range
];
/** @var callable function (AssertException $exception) */
/** @var callable function (AssertException $exception): void */
public static $onFailure;
/** @var int the count of assertions */
@@ -91,18 +91,18 @@ public static function setupErrors(): void
set_exception_handler([__CLASS__, 'handleException']);
set_error_handler(function (int $severity, string $message, string $file, int $line) {
set_error_handler(function (int $severity, string $message, string $file, int $line): ?bool {
if (in_array($severity, [E_RECOVERABLE_ERROR, E_USER_ERROR], true) || ($severity & error_reporting()) === $severity) {
self::handleException(new \ErrorException($message, 0, $severity, $file, $line));
}
return false;
});
register_shutdown_function(function () {
register_shutdown_function(function (): void {
Assert::$onFailure = [__CLASS__, 'handleException'];
$error = error_get_last();
register_shutdown_function(function () use ($error) {
register_shutdown_function(function () use ($error): void {
if (in_array($error['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) {
if (($error['type'] & error_reporting()) !== $error['type']) { // show fatal errors hidden by @shutup
self::removeOutputBuffers();
@@ -114,7 +114,7 @@ public function runTest(string $method, array $args = null): void
if ($this->prevErrorHandler === false) {
$this->prevErrorHandler = set_error_handler(function (int $severity) {
$this->prevErrorHandler = set_error_handler(function (int $severity): ?bool {
if ($this->handleErrors && ($severity & error_reporting()) === $severity) {
$this->handleErrors = false;
$this->silentTearDown();
@@ -133,7 +133,7 @@ public function runTest(string $method, array $args = null): void
$params = array_values($params);
try {
if ($info['throws']) {
$e = Assert::error(function () use ($method, $params) {
$e = Assert::error(function () use ($method, $params): void {
[$this, $method->getName()](...$params);
}, ...$throws);
if ($e instanceof AssertException) {
@@ -211,7 +211,7 @@ private function createRunner(): Runner
}
if ($this->options['--setup']) {
(function () use ($runner) {
(function () use ($runner): void {
require func_get_arg(0);
})($this->options['--setup']);
}
@@ -224,7 +224,7 @@ public function getInterpreter(): PhpInterpreter
private function installInterruptHandler(): void
{
if (extension_loaded('pcntl')) {
pcntl_signal(SIGINT, function () {
pcntl_signal(SIGINT, function (): void {
pcntl_signal(SIGINT, SIG_DFL);
$this->interrupted = true;
});
@@ -141,15 +141,15 @@ private function initiateDataProvider(Test $test, string $provider)
return $test->withResult(empty($optional) ? Test::FAILED : Test::SKIPPED, $e->getMessage());
}
return array_map(function ($item) use ($test, $dataFile) {
return array_map(function (string $item) use ($test, $dataFile): Test {
return $test->withArguments(['dataprovider' => "$item|$dataFile"]);
}, array_keys($data));
}
private function initiateMultiple(Test $test, $count): array
{
return array_map(function ($i) use ($test) {
return array_map(function (int $i) use ($test): Test {
return $test->withArguments(['multiple' => $i]);
}, range(0, (int) $count - 1));
}
@@ -170,7 +170,7 @@ private function initiateTestCase(Test $test, $foo, PhpInterpreter $interpreter)
return $test->withResult(Test::SKIPPED, "TestCase in file '{$test->getFile()}' does not contain test methods.");
}
return array_map(function ($method) use ($test) {
return array_map(function (string $method) use ($test): Test {
return $test->withArguments(['method' => $method]);
}, explode(',', $m[1]));
}
@@ -12,7 +12,7 @@
date_default_timezone_set('Europe/Prague');
function test(\Closure $function)
function test(\Closure $function): void
{
$function();
}

0 comments on commit 2c04b76

Please sign in to comment.