Skip to content
Snippets Groups Projects

Fix callables that are expected to return bool but don't

Closed Michael Strelan requested to merge issue/drupal-3471932:3471932-callables into 11.x
2 unresolved threads

Closes #3471932

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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
  • 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(...));
  • added 1 commit

    Compare with previous version

  • added 1 commit

    • acd764e9 - Add new FilterArray class instead

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    • 464f9a35 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • closed

  • Please register or sign in to reply
    Loading