From 2e099e1392543ab5bde0c317786a8c71b352db76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sat, 2 Sep 2023 13:57:41 +0200 Subject: [PATCH] Fix: Use boolean expressions --- src/Faker/Core/Version.php | 8 ++++---- src/Faker/Extension/Helper.php | 2 +- src/Faker/Provider/Base.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Faker/Core/Version.php b/src/Faker/Core/Version.php index ce484e6ad8..f5e7cf5a08 100644 --- a/src/Faker/Core/Version.php +++ b/src/Faker/Core/Version.php @@ -25,8 +25,8 @@ public function semver(bool $preRelease = false, bool $build = false): string mt_rand(0, 9), mt_rand(0, 99), mt_rand(0, 99), - $preRelease && mt_rand(0, 1) ? '-' . $this->semverPreReleaseIdentifier() : '', - $build && mt_rand(0, 1) ? '+' . $this->semverBuildIdentifier() : '', + $preRelease && mt_rand(0, 1) === 1 ? '-' . $this->semverPreReleaseIdentifier() : '', + $build && mt_rand(0, 1) === 1 ? '+' . $this->semverBuildIdentifier() : '', ); } @@ -37,7 +37,7 @@ private function semverPreReleaseIdentifier(): string { $ident = Helper::randomElement($this->semverCommonPreReleaseIdentifiers); - if (!mt_rand(0, 1)) { + if (mt_rand(0, 1) !== 1) { return $ident; } @@ -49,7 +49,7 @@ private function semverPreReleaseIdentifier(): string */ private function semverBuildIdentifier(): string { - if (mt_rand(0, 1)) { + if (mt_rand(0, 1) === 1) { // short git revision syntax: https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection return substr(sha1(Helper::lexify('??????')), 0, 7); } diff --git a/src/Faker/Extension/Helper.php b/src/Faker/Extension/Helper.php index 27a66143fe..d6245313f9 100644 --- a/src/Faker/Extension/Helper.php +++ b/src/Faker/Extension/Helper.php @@ -83,7 +83,7 @@ public static function lexify(string $string): string public static function bothify(string $string): string { $string = self::replaceWildcard($string, '*', static function () { - return mt_rand(0, 1) ? '#' : '?'; + return mt_rand(0, 1) === 1 ? '#' : '?'; }); return static::lexify(static::numerify($string)); diff --git a/src/Faker/Provider/Base.php b/src/Faker/Provider/Base.php index d91552c8a3..a590afb478 100644 --- a/src/Faker/Provider/Base.php +++ b/src/Faker/Provider/Base.php @@ -491,7 +491,7 @@ public static function lexify($string = '????') public static function bothify($string = '## ??') { $string = self::replaceWildcard($string, '*', static function () { - return mt_rand(0, 1) ? '#' : '?'; + return mt_rand(0, 1) === 1 ? '#' : '?'; }); return static::lexify(static::numerify($string));