Permalink
Browse files

strict type fixes

  • Loading branch information...
dg committed Mar 21, 2018
1 parent b94ef05 commit bed396f55025a5375cdf6112390099bec89d42aa
@@ -25,9 +25,9 @@ public static function purge($dir)
}
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $entry) {
if ($entry->isDir()) {
rmdir($entry);
rmdir((string) $entry);
} else {
unlink($entry);
unlink((string) $entry);
}
}
}
@@ -83,7 +83,7 @@ public function runTest($method, array $args = null)
} elseif (is_array($info['throws'])) {
throw new TestCaseException("Annotation @throws for {$method->getName()}() can be specified only once.");
} else {
$throws = preg_split('#\s+#', $info['throws'], 2);
$throws = is_string($info['throws']) ? preg_split('#\s+#', $info['throws'], 2) : [];
}
$data = [];
@@ -59,8 +59,8 @@ public function run()
}
$runner = $this->createRunner();
$runner->setEnvironmentVariable(Environment::RUNNER, 1);
$runner->setEnvironmentVariable(Environment::COLORS, (int) Environment::$useColors);
$runner->setEnvironmentVariable(Environment::RUNNER, '1');
$runner->setEnvironmentVariable(Environment::COLORS, (string) (int) Environment::$useColors);
if (isset($coverageFile)) {
$runner->setEnvironmentVariable(Environment::COVERAGE, $coverageFile);
}
@@ -101,7 +101,7 @@ public function finish(Test $test)
fwrite($this->file, $outputs[$test->getResult()]);
$title = ($test->title ? "$test->title | " : '') . substr($test->getSignature(), strlen($this->baseDir));
$message = ' ' . str_replace("\n", "\n ", trim($test->message)) . "\n\n";
$message = ' ' . str_replace("\n", "\n ", trim((string) $test->message)) . "\n\n";
if ($test->getResult() === Test::FAILED) {
$this->buffer .= Dumper::color('red', "-- FAILED: $title") . "\n$message";
} elseif ($test->getResult() === Test::SKIPPED && $this->displaySkipped) {
@@ -60,7 +60,7 @@ public function prepare(Test $test)
public function finish(Test $test)
{
$this->results[$test->getResult()]++;
$message = ' ' . str_replace("\n", "\n ", Tester\Dumper::removeColors(trim($test->message)));
$message = ' ' . str_replace("\n", "\n ", Tester\Dumper::removeColors(trim((string) $test->message)));
$outputs = [
Test::PASSED => "-- OK: {$test->getSignature()}",
Test::SKIPPED => "-- Skipped: {$test->getSignature()}\n$message",
@@ -48,7 +48,7 @@ public function prepare(Test $test)
public function finish(Test $test)
{
$this->results[$test->getResult()]++;
$message = str_replace("\n", "\n# ", trim($test->message));
$message = str_replace("\n", "\n# ", trim((string) $test->message));
$outputs = [
Test::PASSED => "ok {$test->getSignature()}",
Test::SKIPPED => "ok {$test->getSignature()} #skip $message",
@@ -130,7 +130,7 @@ public function run()
while ($threads && $this->jobs) {
$running[] = $job = array_shift($this->jobs);
$async = $this->threadCount > 1 && (count($running) + count($this->jobs) > 1);
$job->setEnvironmentVariable(Environment::THREAD, array_shift($threads));
$job->setEnvironmentVariable(Environment::THREAD, (string) array_shift($threads));
$job->run($async ? $job::RUN_ASYNC : 0);
}
@@ -292,7 +292,7 @@ private function getLastResult(Test $test)
$file = $this->getLastResultFilename($test);
if (is_file($file)) {
return $this->lastResults[$signature] = file_get_contents($file);
return $this->lastResults[$signature] = (int) file_get_contents($file);
}
return $this->lastResults[$signature] = Test::PREPARED;
@@ -27,7 +27,7 @@
$phar->startBuffering();
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/../../src', RecursiveDirectoryIterator::SKIP_DOTS)) as $file) {
echo "adding: {$iterator->getSubPathname()}\n";
$phar[$iterator->getSubPathname()] = php_strip_whitespace($file);
$phar[$iterator->getSubPathname()] = php_strip_whitespace((string) $file);
}
$phar->stopBuffering();

0 comments on commit bed396f

Please sign in to comment.