Fix callables that are expected to return bool but don't
2 unresolved threads
2 unresolved threads
Closes #3471932
Merge request reports
Activity
404 /** 405 * Checks whether a string is empty. 406 * 407 * This can be used as a callback to functions like array_filter() to avoid 408 * filtering falsy values like 0. 409 * 410 * @param string $text 411 * The text to check. 412 * 413 * @return bool 414 * TRUE if the string is empty, FALSE if not. 415 */ 416 public static function isEmptyString(string $text): bool { 417 return $text === ''; 418 } 419 changed this line in version 3 of the diff
345 346 // \Drupal\Core\Datetime\Element\Datelist::valueCallback(). 346 347 unset($input['object']); 347 348 // Filters out empty array values, any valid value would have a string length. 348 $filtered_input = array_filter($input, 'strlen'); 349 $filtered_input = array_filter($input, Unicode::isEmptyString(...)); - Comment on lines -348 to +349
This is using First class callable syntax. If that's a problem for some reason we can change this to ye olde style callables, e.g.
[Unicode::className, 'isEmptyString']
. changed this line in version 2 of the diff
- Resolved by catch
Please register or sign in to reply