Skip to content

Commit 8254eb7

Browse files
committed
refactor: replace empty()
1 parent 424444f commit 8254eb7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

system/Test/Fabricator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function __construct($model, ?array $formatters = null, ?string $locale =
128128

129129
// Determine eligible date fields
130130
foreach (['createdField', 'updatedField', 'deletedField'] as $field) {
131-
if (! empty($this->model->{$field})) {
131+
if (isset($this->model->{$field})) {
132132
$this->dateFields[] = $this->model->{$field};
133133
}
134134
}
@@ -152,7 +152,7 @@ public static function resetCounts()
152152
*/
153153
public static function getCount(string $table): int
154154
{
155-
return empty(self::$tableCounts[$table]) ? 0 : self::$tableCounts[$table];
155+
return ! isset(self::$tableCounts[$table]) ? 0 : self::$tableCounts[$table];
156156
}
157157

158158
/**
@@ -282,7 +282,7 @@ protected function detectFormatters(): self
282282
{
283283
$this->formatters = [];
284284

285-
if (! empty($this->model->allowedFields)) {
285+
if (isset($this->model->allowedFields)) {
286286
foreach ($this->model->allowedFields as $field) {
287287
$this->formatters[$field] = $this->guessFormatter($field);
288288
}
@@ -513,12 +513,12 @@ protected function createMock(?int $count = null)
513513
// Determine which fields we will need
514514
$fields = [];
515515

516-
if (! empty($this->model->useTimestamps)) {
516+
if ($this->model->useTimestamps) {
517517
$fields[$this->model->createdField] = $datetime;
518518
$fields[$this->model->updatedField] = $datetime;
519519
}
520520

521-
if (! empty($this->model->useSoftDeletes)) {
521+
if ($this->model->useSoftDeletes) {
522522
$fields[$this->model->deletedField] = null;
523523
}
524524

system/Test/FeatureTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function call(string $method, string $path, ?array $params = null)
186186
->run($routes, true);
187187

188188
$output = \ob_get_contents();
189-
if (empty($response->getBody()) && ! ($output === '' || $output === false)) {
189+
if (($response->getBody() === null) && ! ($output === '' || $output === false)) {
190190
$response->setBody($output);
191191
}
192192

system/Test/Mock/MockCache.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MockCache extends BaseHandler implements CacheInterface
2222
/**
2323
* Mock cache storage.
2424
*
25-
* @var array
25+
* @var array<string, mixed>
2626
*/
2727
protected $cache = [];
2828

@@ -155,7 +155,7 @@ public function increment(string $key, int $offset = 1)
155155
$key = static::validateKey($key, $this->prefix);
156156
$data = $this->cache[$key] ?: null;
157157

158-
if (empty($data)) {
158+
if ($data === null) {
159159
$data = 0;
160160
} elseif (! is_int($data)) {
161161
return false;
@@ -175,7 +175,7 @@ public function decrement(string $key, int $offset = 1)
175175

176176
$data = $this->cache[$key] ?: null;
177177

178-
if (empty($data)) {
178+
if ($data === null) {
179179
$data = 0;
180180
} elseif (! is_int($data)) {
181181
return false;
@@ -281,9 +281,9 @@ public function assertHasValue(string $key, $value = null)
281281
{
282282
$item = $this->get($key);
283283

284-
// Let assertHas handle throwing the error for consistency
284+
// Let assertHas() handle throwing the error for consistency
285285
// if the key is not found
286-
if (empty($item)) {
286+
if ($item === null) {
287287
$this->assertHas($key);
288288
}
289289

system/Test/Mock/MockConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s
6262

6363
$query->setQuery($sql, $binds, $setEscapeFlags);
6464

65-
if (! empty($this->swapPre) && ! empty($this->DBPrefix)) {
65+
if ($this->swapPre !== '' && $this->DBPrefix !== '') {
6666
$query->swapPrefix($this->DBPrefix, $this->swapPre);
6767
}
6868

0 commit comments

Comments
 (0)