Filters out boolish items that resemble none "truthy" values.

@return array
356
public static function compact($array, $reindex = false)
    {
        $out = array_filter($array, function ($item) {
            return false !== (bool)$item;
        });

        return false !== $reindex && self::isList($out) ? array_values($out) : $out;
    }
821266
private function getMatches()
    {

        if (empty($this->urlPart) || !$this->validate($this->urlPart)) {
            return [];
        }

        if (!preg_match($this->_current_pattern, $this->urlPart, $matches)) {
            return [];
        }

        return $matches;
    }
1248542
public function filterNotBlankTranslations()
    {
        return array_filter($this->getTranslations()->getArrayCopy(), function (TranslationInterface $translation) {
            $content = $translation->getContent();

            return !empty($content);
        });
    }
221957
public function exceptValues($excluded = [])
    {
        Arguments::define(
            Boa::arrOf(
                Boa::either(
                    Boa::string(),
                    Boa::integer()
                )
            )
        )->check($excluded);

        return $this->filter(
            function ($value) use ($excluded) {
                return !in_array($value, $excluded);
            }
        );
    }
320566
public function toNative()
    {
        if ($this->valueEquals($this->getAttribute()->getNullValue())) {
            return [];
        }

        $links = [];
        foreach ($this->getValue() as $link) {
            $links[] = $link->toNative();
        }

        return $links;
    }
818838
public function convertBooleans($item)
    {
        if (is_array($item)) {
            foreach ($item as $key => $value) {
                if (is_bool($value)) {
                    $item[$key] = ($value) ? 'true' : 'false';
                } elseif (is_numeric($value)) {
                    $item[$key] = ($value > 0) ? 'true' : 'false';
                }
            }
        } else {
            if (is_bool($item)) {
                $item = ($item) ? 'true' : 'false';
            } elseif (is_numeric($item)) {
                $item = ($item > 0) ? 'true' : 'false';
            }
        }

        return $item;
    }
838571
public function isFilterable()
    {
        $hasFilters = false;

        foreach ($this->columns as $column) {
            if ($column->isFilterable()) {
                $hasFilters = true;
                break;
            }
        }

        return $hasFilters;
    }
426999
public function getBlacklistFilter()
    {
        $blacklist = $this->getBlacklist();
        $base = '/^'
              . preg_quote($this->getBasePath() . DIRECTORY_SEPARATOR, '/')
              . '/';

        return function (SplFileInfo $file) use ($base, $blacklist) {
            $path = Path::canonical(
                preg_replace($base, '', $file->getPathname())
            );

            if (in_array($path, $blacklist)) {
                return false;
            }

            return null;
        };
    }
387857
public function toBool()
    {
        return (!is_null($this->returnValue)) &&
            (!empty($this->returnValue)) &&
            (!in_array(strtolower($this->returnValue), $this->falseStrings));
    }
545035
public function boolean()
    {
        $message = ['%s is {{not|}} a boolean', $this->value];
        $this->assert(is_bool($this->value), $message);

        return $this;
    }
388497
public function uncastItems()
    {
        $items = $this->toArray();

        return array_map(function ($v) {
            if ($v instanceof \DateTime) {
                return $v->format(\DateTime::ISO8601);
            }

            return $v;
        }, $items);
    }
949154
public function getCheckedList()
    {
        $ids = array();
        foreach ($this->list as $id => $item) {
            if ($this->list[$id]['value'] === true) {
                $ids[] = $id;
            }
        }
        return $ids;
    }
695951
private function filtersBooleanOverride(array $filters): array
    {
        foreach ($filters as $key => $filter) {
            $builderType = $filter['type'];

            switch ($builderType) {
                case 'boolean':
                    $filter['values'] = [
                        1 => 'Yes',
                        0 => 'No',
                    ];
                    $filter['input'] = 'radio';
                    $filter['colors'] = [
                        1 => 'success',
                        0 => 'danger',
                    ];

                    break;
            }

            $filters[$key] = $filter;
        }

        return $filters;
    }
260560
private function applyFilters()
    {
        // Only apply filters if this is mutable.
        if ($this->isImmutable) {
            return;
        }

        // Reset to original items before filtering.
        $this->exchangeArray($this->originalItems);

        // Apply filter to items.
        if (count($this->filters) > 0) {
            $filtered_array = array_filter(
                $this->getArrayCopy(),
                function ($item) {
                    foreach ($this->filters as $callback) {
                        if (call_user_func($callback, $item) === true) {
                            return true;
                        }
                    }
                    return false;
                }
            );
            $this->exchangeArray(array_values($filtered_array));
        }

        // Filter nested items.
        foreach ($this->getArrayCopy() as $item) {
            if ($item instanceof MultiValue) {
                foreach ($this->filters as $callback) {
                    $item->filter($callback);
                }
            }
        }
    }
19941
public function filter()
    {
        $bad_words = collect($this->badWords())->pluck('word')->toArray();

        return collect(explode(' ', $this->text))->map(function ($value) use ($bad_words) {
            if ($this->strict) {
                return (str_contains(strtolower($value), $bad_words)) ? $this->blockWord($value) : $value;
            }

            return in_array(strtolower($value), $bad_words) ? $this->blockWord($value) : $value;
        })->implode(' ');
    }
990763
public function stripEmpty(): self
    {
        return $this->filter(
            static function ($item) {
                if ($item === null) {
                    return false;
                }

                return (bool) \trim((string) $item);
            }
        );
    }
1244366
protected function _emptyValue($value)
    {
        if ($value === true) {
            return ['' => ''];
        }
        if (is_scalar($value)) {
            return ['' => $value];
        }
        if (is_array($value)) {
            return $value;
        }

        return [];
    }