1
0
Fork 0

Remove redundant boolean type casts (#12033)

pull/12043/head
Quỳnh Nguyễn 2024-07-10 16:04:20 +07:00 committed by GitHub
parent 03bbfdd8f4
commit 6ec76db926
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 15 deletions

View File

@ -53,7 +53,7 @@ class Cache
$this->root = rtrim($cacheDir, '/\\') . '/'; $this->root = rtrim($cacheDir, '/\\') . '/';
$this->allowlist = $allowlist; $this->allowlist = $allowlist;
$this->filesystem = $filesystem ?: new Filesystem(); $this->filesystem = $filesystem ?: new Filesystem();
$this->readOnly = (bool) $readOnly; $this->readOnly = $readOnly;
if (!self::isUsable($cacheDir)) { if (!self::isUsable($cacheDir)) {
$this->enabled = false; $this->enabled = false;
@ -65,7 +65,7 @@ class Cache
*/ */
public function setReadOnly(bool $readOnly) public function setReadOnly(bool $readOnly)
{ {
$this->readOnly = (bool) $readOnly; $this->readOnly = $readOnly;
} }
/** /**

View File

@ -125,7 +125,7 @@ class Config
$this->config = static::$defaultConfig; $this->config = static::$defaultConfig;
$this->repositories = static::$defaultRepositories; $this->repositories = static::$defaultRepositories;
$this->useEnvironment = (bool) $useEnvironment; $this->useEnvironment = $useEnvironment;
$this->baseDir = is_string($baseDir) && '' !== $baseDir ? $baseDir : null; $this->baseDir = is_string($baseDir) && '' !== $baseDir ? $baseDir : null;
foreach ($this->config as $configKey => $configValue) { foreach ($this->config as $configKey => $configValue) {

View File

@ -90,7 +90,7 @@ class EventDispatcher
*/ */
public function setRunScripts(bool $runScripts = true): self public function setRunScripts(bool $runScripts = true): self
{ {
$this->runScripts = (bool) $runScripts; $this->runScripts = $runScripts;
return $this; return $this;
} }

View File

@ -1173,7 +1173,7 @@ class Installer
*/ */
public function setDryRun(bool $dryRun = true): self public function setDryRun(bool $dryRun = true): self
{ {
$this->dryRun = (bool) $dryRun; $this->dryRun = $dryRun;
return $this; return $this;
} }
@ -1205,7 +1205,7 @@ class Installer
*/ */
public function setPreferSource(bool $preferSource = true): self public function setPreferSource(bool $preferSource = true): self
{ {
$this->preferSource = (bool) $preferSource; $this->preferSource = $preferSource;
return $this; return $this;
} }
@ -1217,7 +1217,7 @@ class Installer
*/ */
public function setPreferDist(bool $preferDist = true): self public function setPreferDist(bool $preferDist = true): self
{ {
$this->preferDist = (bool) $preferDist; $this->preferDist = $preferDist;
return $this; return $this;
} }
@ -1229,7 +1229,7 @@ class Installer
*/ */
public function setOptimizeAutoloader(bool $optimizeAutoloader): self public function setOptimizeAutoloader(bool $optimizeAutoloader): self
{ {
$this->optimizeAutoloader = (bool) $optimizeAutoloader; $this->optimizeAutoloader = $optimizeAutoloader;
if (!$this->optimizeAutoloader) { if (!$this->optimizeAutoloader) {
// Force classMapAuthoritative off when not optimizing the // Force classMapAuthoritative off when not optimizing the
// autoloader // autoloader
@ -1247,7 +1247,7 @@ class Installer
*/ */
public function setClassMapAuthoritative(bool $classMapAuthoritative): self public function setClassMapAuthoritative(bool $classMapAuthoritative): self
{ {
$this->classMapAuthoritative = (bool) $classMapAuthoritative; $this->classMapAuthoritative = $classMapAuthoritative;
if ($this->classMapAuthoritative) { if ($this->classMapAuthoritative) {
// Force optimizeAutoloader when classmap is authoritative // Force optimizeAutoloader when classmap is authoritative
$this->setOptimizeAutoloader(true); $this->setOptimizeAutoloader(true);
@ -1276,7 +1276,7 @@ class Installer
*/ */
public function setUpdate(bool $update): self public function setUpdate(bool $update): self
{ {
$this->update = (bool) $update; $this->update = $update;
return $this; return $this;
} }
@ -1288,7 +1288,7 @@ class Installer
*/ */
public function setInstall(bool $install): self public function setInstall(bool $install): self
{ {
$this->install = (bool) $install; $this->install = $install;
return $this; return $this;
} }
@ -1300,7 +1300,7 @@ class Installer
*/ */
public function setDevMode(bool $devMode = true): self public function setDevMode(bool $devMode = true): self
{ {
$this->devMode = (bool) $devMode; $this->devMode = $devMode;
return $this; return $this;
} }
@ -1314,7 +1314,7 @@ class Installer
*/ */
public function setDumpAutoloader(bool $dumpAutoloader = true): self public function setDumpAutoloader(bool $dumpAutoloader = true): self
{ {
$this->dumpAutoloader = (bool) $dumpAutoloader; $this->dumpAutoloader = $dumpAutoloader;
return $this; return $this;
} }
@ -1353,7 +1353,7 @@ class Installer
*/ */
public function setVerbose(bool $verbose = true): self public function setVerbose(bool $verbose = true): self
{ {
$this->verbose = (bool) $verbose; $this->verbose = $verbose;
return $this; return $this;
} }

View File

@ -40,7 +40,7 @@ class StrictConfirmationQuestion extends Question
*/ */
public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y(?:es)?$/i', string $falseAnswerRegex = '/^no?$/i') public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y(?:es)?$/i', string $falseAnswerRegex = '/^no?$/i')
{ {
parent::__construct($question, (bool) $default); parent::__construct($question, $default);
$this->trueAnswerRegex = $trueAnswerRegex; $this->trueAnswerRegex = $trueAnswerRegex;
$this->falseAnswerRegex = $falseAnswerRegex; $this->falseAnswerRegex = $falseAnswerRegex;