diff --git a/src/Framework/Constraint/String/StringContains.php b/src/Framework/Constraint/String/StringContains.php index 7ba71587e58..7a805edde38 100644 --- a/src/Framework/Constraint/String/StringContains.php +++ b/src/Framework/Constraint/String/StringContains.php @@ -127,7 +127,7 @@ private function getDetectedEncoding(mixed $other): string $detectedEncoding = mb_detect_encoding($other, null, true); - if (!$detectedEncoding) { + if ($detectedEncoding === false) { return 'Encoding detection failed'; } diff --git a/src/Framework/TestRunner.php b/src/Framework/TestRunner.php index c7f31d7c1d1..f6bf682af2e 100644 --- a/src/Framework/TestRunner.php +++ b/src/Framework/TestRunner.php @@ -451,7 +451,7 @@ private function saveConfigurationForChildProcess(): string { $path = tempnam(sys_get_temp_dir(), 'phpunit_'); - if (!$path) { + if ($path === false) { throw new ProcessIsolationException; } diff --git a/src/Metadata/Api/DataProvider.php b/src/Metadata/Api/DataProvider.php index 2774f63bc89..93e85770dd4 100644 --- a/src/Metadata/Api/DataProvider.php +++ b/src/Metadata/Api/DataProvider.php @@ -236,7 +236,7 @@ private function dataProvidedByTestWithAnnotation(string $className, string $met { $docComment = (new ReflectionMethod($className, $methodName))->getDocComment(); - if (!$docComment) { + if ($docComment === false) { return null; } diff --git a/src/Runner/PhptTestCase.php b/src/Runner/PhptTestCase.php index 20577a694ec..4a6636df787 100644 --- a/src/Runner/PhptTestCase.php +++ b/src/Runner/PhptTestCase.php @@ -217,8 +217,8 @@ public function run(): void $failure = new PhptAssertionFailedError( $e->getMessage(), 0, - $trace[0]['file'], - $trace[0]['line'], + (string) $trace[0]['file'], + (int) $trace[0]['line'], $trace, $comparisonFailure ? $diff : '', ); diff --git a/src/TextUI/Application.php b/src/TextUI/Application.php index fc64589c6a8..47a917b1368 100644 --- a/src/TextUI/Application.php +++ b/src/TextUI/Application.php @@ -332,7 +332,7 @@ private function buildCliConfiguration(array $argv): CliConfiguration private function loadXmlConfiguration(false|string $configurationFile): XmlConfiguration { - if (!$configurationFile) { + if ($configurationFile === false) { return DefaultConfiguration::create(); } @@ -387,7 +387,7 @@ private function executeCommandsThatOnlyRequireCliConfiguration(CliConfiguration } if ($cliConfiguration->migrateConfiguration()) { - if (!$configurationFile) { + if ($configurationFile === false) { $this->exitWithErrorMessage('No configuration file found to migrate'); } diff --git a/src/TextUI/Configuration/Builder.php b/src/TextUI/Configuration/Builder.php index 48fc057880e..6ada9b4a1c9 100644 --- a/src/TextUI/Configuration/Builder.php +++ b/src/TextUI/Configuration/Builder.php @@ -33,7 +33,7 @@ public function build(array $argv): Configuration $configurationFile = (new XmlConfigurationFileFinder)->find($cliConfiguration); $xmlConfiguration = DefaultConfiguration::create(); - if ($configurationFile) { + if ($configurationFile !== false) { $xmlConfiguration = (new Loader)->load($configurationFile); } diff --git a/src/TextUI/Configuration/Cli/XmlConfigurationFileFinder.php b/src/TextUI/Configuration/Cli/XmlConfigurationFileFinder.php index 55a89c1e185..79cbfd15e60 100644 --- a/src/TextUI/Configuration/Cli/XmlConfigurationFileFinder.php +++ b/src/TextUI/Configuration/Cli/XmlConfigurationFileFinder.php @@ -27,7 +27,7 @@ public function find(Configuration $configuration): false|string if (is_dir($configuration->configurationFile())) { $candidate = $this->configurationFileInDirectory($configuration->configurationFile()); - if ($candidate) { + if ($candidate !== false) { return $candidate; } @@ -40,7 +40,7 @@ public function find(Configuration $configuration): false|string if ($useDefaultConfiguration) { $candidate = $this->configurationFileInDirectory(getcwd()); - if ($candidate) { + if ($candidate !== false) { return $candidate; } } diff --git a/src/TextUI/Configuration/Xml/Loader.php b/src/TextUI/Configuration/Xml/Loader.php index 3b8c8b7c5e6..991618d9552 100644 --- a/src/TextUI/Configuration/Xml/Loader.php +++ b/src/TextUI/Configuration/Xml/Loader.php @@ -474,7 +474,7 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage ); } - private function getBoolean(string $value, bool|string $default): bool|string + private function getBoolean(string $value, bool $default): bool { if (strtolower($value) === 'false') { return false; @@ -487,6 +487,19 @@ private function getBoolean(string $value, bool|string $default): bool|string return $default; } + private function getValue(string $value): bool|string + { + if (strtolower($value) === 'false') { + return false; + } + + if (strtolower($value) === 'true') { + return true; + } + + return $value; + } + private function readFilterDirectories(string $filename, DOMXPath $xpath, string $query): FilterDirectoryCollection { $directories = []; @@ -556,7 +569,7 @@ private function getBooleanAttribute(DOMElement $element, string $attribute, boo return $default; } - return (bool) $this->getBoolean( + return $this->getBoolean( $element->getAttribute($attribute), false, ); @@ -635,7 +648,7 @@ private function php(string $filename, DOMXPath $xpath): Php $constants[] = new Constant( $const->getAttribute('name'), - $this->getBoolean($value, $value), + $this->getValue($value), ); } @@ -660,7 +673,7 @@ private function php(string $filename, DOMXPath $xpath): Php $verbatim = false; if ($var->hasAttribute('force')) { - $force = (bool) $this->getBoolean($var->getAttribute('force'), false); + $force = $this->getBoolean($var->getAttribute('force'), false); } if ($var->hasAttribute('verbatim')) { @@ -668,7 +681,7 @@ private function php(string $filename, DOMXPath $xpath): Php } if (!$verbatim) { - $value = $this->getBoolean($value, $value); + $value = $this->getValue($value); } $variables[$array][] = new Variable($name, $value, $force);