Skip to content

Commit d05b54e

Browse files
oliverkleeSam Tuke
authored and
Sam Tuke
committed
[CLEANUP] Fix some Scrutinizer warnings (#289)
1 parent 27a5094 commit d05b54e

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

src/Composer/ModuleFinder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function findGeneralConfiguration(): array
234234
$configurationSets[] = $extra['phplist/core']['configuration'];
235235
}
236236

237-
return array_replace_recursive(...$configurationSets);
237+
return /** @scrutinizer ignore-call */ array_replace_recursive(...$configurationSets);
238238
}
239239

240240
/**

src/Composer/ScriptHandler.php

+6
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,16 @@ public static function createBundleConfiguration(Event $event)
205205
* @param string $contents
206206
*
207207
* @return void
208+
*
209+
* @throws \RuntimeException
208210
*/
209211
private static function createAndWriteFile(string $path, string $contents)
210212
{
211213
$fileHandle = fopen($path, 'wb');
214+
if ($fileHandle === false) {
215+
throw new \RuntimeException('The file "' . $path . '" could not be opened for writing.', 1519851153);
216+
}
217+
212218
fwrite($fileHandle, $contents);
213219
fclose($fileHandle);
214220
}

src/Core/Bootstrap.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ protected function __clone()
7474
*/
7575
public static function getInstance(): Bootstrap
7676
{
77-
if (static::$instance === null) {
78-
static::$instance = new static();
77+
if (self::$instance === null) {
78+
self::$instance = new static();
7979
}
8080

81-
return static::$instance;
81+
return self::$instance;
8282
}
8383

8484
/**
@@ -90,7 +90,7 @@ public static function getInstance(): Bootstrap
9090
*/
9191
public static function purgeInstance()
9292
{
93-
static::$instance = null;
93+
self::$instance = null;
9494
}
9595

9696
/**
@@ -140,9 +140,9 @@ private function isDebugEnabled(): bool
140140
* @SuppressWarnings("PHPMD.ExitExpression")
141141
* @SuppressWarnings("PHPMD.Superglobals")
142142
*
143-
* @return Bootstrap fluent interface
143+
* @return Bootstrap|null fluent interface
144144
*/
145-
public function ensureDevelopmentOrTestingEnvironment(): Bootstrap
145+
public function ensureDevelopmentOrTestingEnvironment()
146146
{
147147
$usesProxy = isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']);
148148
$isOnCli = PHP_SAPI === 'cli' || PHP_SAPI === 'cli-server';

src/Core/Environment.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ private function __construct()
5959
*/
6060
public static function validateEnvironment(string $environment)
6161
{
62-
if (!in_array($environment, static::$validEnvironments, true)) {
63-
$environmentsText = '"' . implode('", ', static::$validEnvironments) . '"';
62+
if (!in_array($environment, self::$validEnvironments, true)) {
63+
$environmentsText = '"' . implode('", ', self::$validEnvironments) . '"';
6464
throw new \UnexpectedValueException(
6565
'$environment must be one of ' . $environmentsText . ', but actually was: "' . $environment . '"',
6666
1499112172

src/Domain/Repository/Identity/AdministratorTokenRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ public function removeExpired(): int
4747
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
4848
$queryBuilder->delete(AdministratorToken::class, 'token')->where('token.expiry <= CURRENT_TIMESTAMP()');
4949

50-
return $queryBuilder->getQuery()->execute();
50+
return (int)$queryBuilder->getQuery()->execute();
5151
}
5252
}

0 commit comments

Comments
 (0)