@@ -84,11 +84,9 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c
84
84
$ params = $ this ->prepareParams ($ params );
85
85
86
86
// Is the output cached?
87
- $ cacheName = ! empty ($ cacheName )
88
- ? $ cacheName
89
- : str_replace (['\\' , '/ ' ], '' , $ class ) . $ method . md5 (serialize ($ params ));
87
+ $ cacheName ??= str_replace (['\\' , '/ ' ], '' , $ class ) . $ method . md5 (serialize ($ params ));
90
88
91
- if (! empty ( $ this -> cache ) && $ output = $ this ->cache ->get ($ cacheName )) {
89
+ if ($ output = $ this ->cache ->get ($ cacheName )) {
92
90
return $ output ;
93
91
}
94
92
@@ -105,7 +103,7 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c
105
103
: $ this ->renderSimpleClass ($ instance , $ method , $ params , $ class );
106
104
107
105
// Can we cache it?
108
- if (! empty ( $ this -> cache ) && $ ttl !== 0 ) {
106
+ if ($ ttl !== 0 ) {
109
107
$ this ->cache ->save ($ cacheName , $ output , $ ttl );
110
108
}
111
109
@@ -119,11 +117,14 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c
119
117
*
120
118
* @param array|string|null $params
121
119
*
122
- * @return array|null
120
+ * @return array
123
121
*/
124
122
public function prepareParams ($ params )
125
123
{
126
- if (empty ($ params ) || (! is_string ($ params ) && ! is_array ($ params ))) {
124
+ if (
125
+ ($ params === null || $ params === '' || $ params === [])
126
+ || (! is_string ($ params ) && ! is_array ($ params ))
127
+ ) {
127
128
return [];
128
129
}
129
130
@@ -139,7 +140,7 @@ public function prepareParams($params)
139
140
unset($ separator );
140
141
141
142
foreach ($ params as $ p ) {
142
- if (! empty ( $ p ) ) {
143
+ if ($ p !== '' ) {
143
144
[$ key , $ val ] = explode ('= ' , $ p );
144
145
145
146
$ newParams [trim ($ key )] = trim ($ val , ', ' );
@@ -175,7 +176,7 @@ protected function determineClass(string $library): array
175
176
176
177
[$ class , $ method ] = explode (': ' , $ library );
177
178
178
- if (empty ( $ class) ) {
179
+ if ($ class === '' ) {
179
180
throw ViewException::forNoCellClass ();
180
181
}
181
182
@@ -187,7 +188,7 @@ protected function determineClass(string $library): array
187
188
throw ViewException::forInvalidCellClass ($ class );
188
189
}
189
190
190
- if (empty ( $ method) ) {
191
+ if ($ method === '' ) {
191
192
$ method = 'index ' ;
192
193
}
193
194
@@ -274,7 +275,7 @@ final protected function renderSimpleClass($instance, string $method, array $par
274
275
$ refParams = $ refMethod ->getParameters ();
275
276
276
277
if ($ paramCount === 0 ) {
277
- if (! empty ( $ params) ) {
278
+ if ($ params !== [] ) {
278
279
throw ViewException::forMissingCellParameters ($ class , $ method );
279
280
}
280
281
0 commit comments