function twig_test_empty in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/Extension/Core.php \twig_test_empty()
Checks if a variable is empty.
<pre> {# evaluates to true if the foo variable is null, false, or the empty string #} {% if foo is empty %} {# ... #} {% endif %} </pre>
Parameters
mixed $value A variable:
Return value
bool true if the value is empty, false otherwise
1 call to twig_test_empty()
- _twig_default_filter in vendor/
Twig/ Extension/ Core.php
1 string reference to 'twig_test_empty'
- Twig_Extension_Core::getTests in vendor/
Twig/ Extension/ Core.php - Returns a list of tests to add to the existing list.
File
- vendor/
Twig/ Extension/ Core.php, line 1373
Code
function twig_test_empty($value) {
if ($value instanceof Countable) {
return 0 == count($value);
}
return '' === $value || false === $value || null === $value || array() === $value;
}