Skip to content

Commit 6179de3

Browse files
Use stricter comparison
1 parent 3376585 commit 6179de3

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

src/Framework/TestRunner/TestRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private function shouldTimeLimitBeEnforced(TestCase $test): bool
283283
return false;
284284
}
285285

286-
if (!(($this->configuration->defaultTimeLimit() || $test->size()->isKnown()))) {
286+
if (!(($this->configuration->defaultTimeLimit() > 0 || $test->size()->isKnown()))) {
287287
return false;
288288
}
289289

src/Logging/EventLogger.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ public function trace(Event $event): void
4141
{
4242
$telemetryInfo = $this->telemetryInfo($event);
4343
$indentation = PHP_EOL . str_repeat(' ', strlen($telemetryInfo));
44-
$lines = preg_split('/\r\n|\r|\n/', $event->asString()) ?: [];
45-
46-
$flags = FILE_APPEND;
44+
$flags = FILE_APPEND;
4745

4846
if (!(PHP_OS_FAMILY === 'Windows' || PHP_OS_FAMILY === 'Darwin') ||
4947
$this->path !== 'php://stdout') {
5048
$flags |= LOCK_EX;
5149
}
5250

51+
$lines = preg_split('/\r\n|\r|\n/', $event->asString());
52+
53+
if ($lines === false) {
54+
$lines = [];
55+
}
56+
5357
file_put_contents(
5458
$this->path,
5559
$telemetryInfo . implode($indentation, $lines) . PHP_EOL,

src/Logging/JUnit/JunitXmlLogger.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ public function __construct(Printer $printer, Facade $facade)
104104

105105
public function flush(): void
106106
{
107-
$this->printer->print($this->document->saveXML() ?: '');
107+
$xml = $this->document->saveXML();
108108

109+
if ($xml === false) {
110+
$xml = '';
111+
}
112+
113+
$this->printer->print($xml);
109114
$this->printer->flush();
110115
}
111116

src/Metadata/Api/Requirements.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@ public function requirementsNotSatisfiedFor(string $className, string $methodNam
7070
if ($metadata->isRequiresPhpExtension()) {
7171
assert($metadata instanceof RequiresPhpExtension);
7272

73+
$extensionVersion = phpversion($metadata->extension());
74+
75+
if ($extensionVersion === false) {
76+
$extensionVersion = '';
77+
}
78+
7379
if (!extension_loaded($metadata->extension()) ||
7480
($metadata->hasVersionRequirement() &&
75-
!$metadata->versionRequirement()->isSatisfiedBy(phpversion($metadata->extension()) ?: ''))) {
81+
!$metadata->versionRequirement()->isSatisfiedBy($extensionVersion))) {
7682
$notSatisfied[] = sprintf(
7783
'PHP extension %s%s is required.',
7884
$metadata->extension(),

src/Runner/BackedUpEnvironmentVariable.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@
4040
*/
4141
public static function create(string $name): array
4242
{
43+
$getenv = getenv($name);
44+
45+
if ($getenv === false) {
46+
$getenv = null;
47+
}
48+
4349
return [
4450
new self(self::FROM_SUPERGLOBAL, $name, $_ENV[$name] ?? null),
45-
new self(self::FROM_GETENV, $name, getenv($name) ?: null),
51+
new self(self::FROM_GETENV, $name, $getenv),
4652
];
4753
}
4854

0 commit comments

Comments
 (0)