Skip to content

Commit 1f78f81

Browse files
committed
refactor: fix non-booleans in if conditions
1 parent 9b14ad9 commit 1f78f81

File tree

5 files changed

+6
-21
lines changed

5 files changed

+6
-21
lines changed

system/View/Parser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
115115
$view = ($fileExt === '') ? $view . '.php' : $view; // allow Views as .html, .tpl, etc (from CI3)
116116

117117
$cacheName = $options['cache_name'] ?? str_replace('.php', '', $view);
118+
$output = cache($cacheName);
118119

119120
// Was it cached?
120-
if (isset($options['cache']) && ($output = cache($cacheName))) {
121+
if (isset($options['cache']) && is_string($output) && $output !== '') {
121122
$this->logPerformance($start, microtime(true), $view);
122123

123124
return $output;

system/View/View.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
186186

187187
$this->renderVars['cacheName'] = $cacheName;
188188

189-
if ($output = cache($this->renderVars['cacheName'])) {
189+
$output = cache($this->renderVars['cacheName']);
190+
191+
if (is_string($output) && $output !== '') {
190192
$this->logPerformance(
191193
$this->renderVars['start'],
192194
microtime(true),

utils/phpstan-baseline/booleanAnd.rightNotBoolean.neon

Lines changed: 0 additions & 8 deletions
This file was deleted.

utils/phpstan-baseline/if.condNotBoolean.neon

Lines changed: 0 additions & 8 deletions
This file was deleted.

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# total 3271 errors
1+
# total 3269 errors
22
includes:
33
- argument.type.neon
44
- assign.propertyType.neon
5-
- booleanAnd.rightNotBoolean.neon
65
- codeigniter.cacheHandlerInstance.neon
76
- codeigniter.getReassignArray.neon
87
- codeigniter.modelArgumentType.neon
98
- codeigniter.superglobalAccess.neon
109
- codeigniter.superglobalAccessAssign.neon
1110
- deadCode.unreachable.neon
1211
- empty.notAllowed.neon
13-
- if.condNotBoolean.neon
1412
- method.alreadyNarrowedType.neon
1513
- method.childParameterType.neon
1614
- method.childReturnType.neon

0 commit comments

Comments
 (0)