- Issue created by @Chi
- 🇳🇿New Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies → .
The Drupal\Core\TypedData\ListInterface provides an isEmpty() method to check if a list has no values. However, there is no corresponding method to check if a list has values, leading to redundant negations like:
if (!$list->isEmpty()) { // The list has values. }
A dedicated method would improve readability, making the code more intuitive and aligning with other API conventions.
ListInterface instance.!isEmpty() instead of a dedicated method.hasValues() method, requiring a negation.hasValues() method to Drupal\Core\TypedData\ListInterface.hasValues() in Drupal\Core\TypedData\Plugin\DataType\ItemList and other necessary classes.TRUE if the list contains at least one value, and FALSE otherwise.Example Usage:
if ($this->get('field_example')->hasValues()) { // The list has values. }
hasValues() in ItemList.ListInterface.ListInterface.Active
11.1 🔥
base system
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies → .