Skip to content

Commit e670425

Browse files
committed
refactor: replace empty()
1 parent 839abfb commit e670425

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

app/Config/Kint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Kint extends BaseConfig
2727
*/
2828

2929
/**
30-
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>
30+
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
3131
*/
3232
public $plugins;
3333

@@ -45,12 +45,12 @@ class Kint extends BaseConfig
4545
public int $richSort = AbstractRenderer::SORT_FULL;
4646

4747
/**
48-
* @var array<string, class-string<ValuePluginInterface>>
48+
* @var array<string, class-string<ValuePluginInterface>>|null
4949
*/
5050
public $richObjectPlugins;
5151

5252
/**
53-
* @var array<string, class-string<TabPluginInterface>>
53+
* @var array<string, class-string<TabPluginInterface>>|null
5454
*/
5555
public $richTabPlugins;
5656

system/CodeIgniter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class CodeIgniter
108108
/**
109109
* Controller to use.
110110
*
111-
* @var (Closure(mixed...): ResponseInterface|string)|string
111+
* @var (Closure(mixed...): ResponseInterface|string)|string|null
112112
*/
113113
protected $controller;
114114

@@ -138,7 +138,7 @@ class CodeIgniter
138138
/**
139139
* Request path to use.
140140
*
141-
* @var string
141+
* @var string|null
142142
*
143143
* @deprecated No longer used.
144144
*/
@@ -302,7 +302,7 @@ private function configureKint(): void
302302
Kint::$display_called_from = $config->displayCalledFrom;
303303
Kint::$expanded = $config->expanded;
304304

305-
if (! empty($config->plugins) && is_array($config->plugins)) {
305+
if (isset($config->plugins) && is_array($config->plugins)) {
306306
Kint::$plugins = $config->plugins;
307307
}
308308

@@ -315,10 +315,10 @@ private function configureKint(): void
315315
RichRenderer::$theme = $config->richTheme;
316316
RichRenderer::$folder = $config->richFolder;
317317
RichRenderer::$sort = $config->richSort;
318-
if (! empty($config->richObjectPlugins) && is_array($config->richObjectPlugins)) {
318+
if (isset($config->richObjectPlugins) && is_array($config->richObjectPlugins)) {
319319
RichRenderer::$value_plugins = $config->richObjectPlugins;
320320
}
321-
if (! empty($config->richTabPlugins) && is_array($config->richTabPlugins)) {
321+
if (isset($config->richTabPlugins) && is_array($config->richTabPlugins)) {
322322
RichRenderer::$tab_plugins = $config->richTabPlugins;
323323
}
324324

@@ -848,7 +848,7 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
848848
*/
849849
protected function determinePath()
850850
{
851-
if (! empty($this->path)) {
851+
if (isset($this->path)) {
852852
return $this->path;
853853
}
854854

@@ -892,7 +892,7 @@ protected function startController()
892892
}
893893

894894
// No controller specified - we don't know what to do now.
895-
if (empty($this->controller)) {
895+
if (! isset($this->controller)) {
896896
throw PageNotFoundException::forEmptyController();
897897
}
898898

@@ -1091,7 +1091,7 @@ public function spoofRequestMethod()
10911091

10921092
$method = $this->request->getPost('_method');
10931093

1094-
if (empty($method)) {
1094+
if ($method === null) {
10951095
return;
10961096
}
10971097

system/View/Table.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function addRow()
217217
{
218218
$tmpRow = $this->_prepArgs(func_get_args());
219219

220-
if ($this->syncRowsWithHeading && ! empty($this->heading)) {
220+
if ($this->syncRowsWithHeading && $this->heading !== []) {
221221
// each key has an index
222222
$keyIndex = array_flip(array_keys($this->heading));
223223

@@ -303,7 +303,7 @@ public function generate($tableData = null)
303303
{
304304
// The table data can optionally be passed to this function
305305
// either as a database result object or an array
306-
if (! empty($tableData)) {
306+
if ($tableData !== null && $tableData !== []) {
307307
if ($tableData instanceof BaseResult) {
308308
$this->_setFromDBResult($tableData);
309309
} elseif (is_array($tableData)) {
@@ -312,7 +312,7 @@ public function generate($tableData = null)
312312
}
313313

314314
// Is there anything to display? No? Smite them!
315-
if (empty($this->heading) && $this->rows === []) {
315+
if ($this->heading === [] && $this->rows === []) {
316316
return 'Undefined table data';
317317
}
318318

@@ -333,7 +333,7 @@ public function generate($tableData = null)
333333
}
334334

335335
// Is there a table heading to display?
336-
if (! empty($this->heading)) {
336+
if ($this->heading !== []) {
337337
$headerTag = null;
338338

339339
if (preg_match('/(<)(td|th)(?=\h|>)/i', $this->template['heading_cell_start'], $matches) === 1) {
@@ -399,7 +399,7 @@ public function generate($tableData = null)
399399
}
400400

401401
// Any table footing to display?
402-
if (! empty($this->footing)) {
402+
if ($this->footing !== []) {
403403
$footerTag = null;
404404

405405
if (preg_match('/(<)(td|th)(?=\h|>)/i', $this->template['footing_cell_start'], $matches)) {
@@ -458,7 +458,7 @@ public function clear()
458458
protected function _setFromDBResult($object)
459459
{
460460
// First generate the headings from the table column names
461-
if ($this->autoHeading && empty($this->heading)) {
461+
if ($this->autoHeading && $this->heading === []) {
462462
$this->heading = $this->_prepArgs($object->getFieldNames());
463463
}
464464

@@ -476,7 +476,7 @@ protected function _setFromDBResult($object)
476476
*/
477477
protected function _setFromArray($data)
478478
{
479-
if ($this->autoHeading && empty($this->heading)) {
479+
if ($this->autoHeading && $this->heading === []) {
480480
$this->heading = $this->_prepArgs(array_shift($data));
481481
}
482482

system/View/View.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
178178

179179
$fileExt = pathinfo($view, PATHINFO_EXTENSION);
180180
// allow Views as .html, .tpl, etc (from CI3)
181-
$this->renderVars['view'] = empty($fileExt) ? $view . '.php' : $view;
181+
$this->renderVars['view'] = ($fileExt === '') ? $view . '.php' : $view;
182182

183183
$this->renderVars['options'] = $options ?? [];
184184

@@ -207,12 +207,12 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
207207
$this->renderVars['file'] = $this->loader->locateFile(
208208
$this->renderVars['view'],
209209
'Views',
210-
empty($fileExt) ? 'php' : $fileExt
210+
($fileExt === '') ? 'php' : $fileExt
211211
);
212212
}
213213

214-
// locateFile will return an empty string if the file cannot be found.
215-
if (empty($this->renderVars['file'])) {
214+
// locateFile() will return false if the file cannot be found.
215+
if ($this->renderVars['file'] === false) {
216216
throw ViewException::forInvalidFile($this->renderVars['view']);
217217
}
218218

0 commit comments

Comments
 (0)