Skip to content

Commit 01e0e27

Browse files
Use stricter comparison
1 parent 8b01495 commit 01e0e27

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/Event/Value/ComparisonFailureBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function from(Throwable $t): ?ComparisonFailure
2828
return null;
2929
}
3030

31-
if (!$t->getComparisonFailure()) {
31+
if ($t->getComparisonFailure() === null) {
3232
return null;
3333
}
3434

src/Framework/Constraint/Constraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function fail(mixed $other, string $description, ?ComparisonFailure $c
9494

9595
$additionalFailureDescription = $this->additionalFailureDescription($other);
9696

97-
if ($additionalFailureDescription) {
97+
if ($additionalFailureDescription !== '') {
9898
$failureDescription .= "\n" . $additionalFailureDescription;
9999
}
100100

src/Framework/Constraint/JsonMatches.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function matches(mixed $other): bool
5959
return false;
6060
}
6161

62-
return $recodedOther == $recodedValue;
62+
return $recodedOther === $recodedValue;
6363
}
6464

6565
/**

src/Framework/MockObject/Runtime/Invocation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function toString(): string
130130
$this->parameters,
131131
),
132132
),
133-
$this->returnType ? sprintf(': %s', $this->returnType) : '',
133+
$this->returnType !== '' ? sprintf(': %s', $this->returnType) : '',
134134
);
135135
}
136136

src/Framework/MockObject/Runtime/Matcher.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function invoked(Invocation $invocation): mixed
9797
->__phpunit_getInvocationHandler()
9898
->lookupMatcher($this->afterMatchBuilderId);
9999

100-
if (!$matcher) {
100+
if ($matcher === null) {
101101
throw new MatchBuilderNotFoundException($this->afterMatchBuilderId);
102102
}
103103
}
@@ -118,7 +118,7 @@ public function invoked(Invocation $invocation): mixed
118118
);
119119
}
120120

121-
if ($this->stub) {
121+
if ($this->stub !== null) {
122122
return $this->stub->invoke($invocation);
123123
}
124124

@@ -138,7 +138,7 @@ public function matches(Invocation $invocation): bool
138138
->__phpunit_getInvocationHandler()
139139
->lookupMatcher($this->afterMatchBuilderId);
140140

141-
if (!$matcher) {
141+
if ($matcher === null) {
142142
throw new MatchBuilderNotFoundException($this->afterMatchBuilderId);
143143
}
144144

src/Framework/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ private function verifyMockObjects(): void
13541354
*/
13551355
private function checkRequirements(): void
13561356
{
1357-
if (!$this->methodName || !method_exists($this, $this->methodName)) {
1357+
if ($this->methodName === '' || !method_exists($this, $this->methodName)) {
13581358
return;
13591359
}
13601360

@@ -1770,7 +1770,7 @@ private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after):
17701770
*/
17711771
private function compareGlobalStateSnapshotPart(array $before, array $after, string $header): void
17721772
{
1773-
if ($before != $after) {
1773+
if ($before !== $after) {
17741774
$differ = new Differ(new UnifiedDiffOutputBuilder($header));
17751775

17761776
Event\Facade::emitter()->testConsideredRisky(

src/Runner/PHPT/PhptTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function run(): void
224224
} elseif ($e instanceof ExpectationFailedException) {
225225
$comparisonFailure = $e->getComparisonFailure();
226226

227-
if ($comparisonFailure) {
227+
if ($comparisonFailure !== null) {
228228
$diff = $comparisonFailure->getDiff();
229229
} else {
230230
$diff = $e->getMessage();
@@ -238,7 +238,7 @@ public function run(): void
238238
(string) $trace[0]['file'],
239239
(int) $trace[0]['line'],
240240
$trace,
241-
$comparisonFailure ? $diff : '',
241+
$comparisonFailure !== null ? $diff : '',
242242
);
243243
}
244244

0 commit comments

Comments
 (0)