private function castableToString(array $choices, array &$cache = [])
    {
        foreach ($choices as $choice) {
            if (\is_array($choice)) {
                if (!$this->castableToString($choice, $cache)) {
                    return false;
                }

                continue;
            } elseif (!is_scalar($choice)) {
                return false;
            }

            // prevent having false casted to the empty string by isset()
            $choice = false === $choice ? '0' : (string) $choice;

            if (isset($cache[$choice])) {
                return false;
            }

            $cache[$choice] = true;
        }

        return true;
    }
private function castableToString(array $choices, array &$cache = [])
    {
        foreach ($choices as $choice) {
            if (\is_array($choice)) {
                if (!$this->castableToString($choice, $cache)) {
                    return false;
                }

                continue;
            } elseif (!is_scalar($choice)) {
                return false;
            }

            // prevent having false casted to the empty string by isset()
            $choice = false === $choice ? '0' : (string) $choice;

            if (isset($cache[$choice])) {
                return false;
            }

            $cache[$choice] = true;
        }

        return true;
    }
private function castableToString ( array $ choices , array & $ cache = [ ] ) { foreach ( $ choices as $ choice ) { if ( \ is_array ( $ choice ) ) { if ( ! $ this -> castableToString ( $ choice , $ cache ) ) { return false ; } continue ; } elseif ( ! is_scalar ( $ choice ) ) { return false ; } // prevent having false casted to the empty string by isset() $ choice = false === $ choice ? '0' : ( string ) $ choice ; if ( isset ( $ cache [ $ choice ] ) ) { return false ; } $ cache [ $ choice ] = true ; } return true ; }
Checks whether the given choices can be cast to strings without
generating duplicates.
This method is responsible for preventing conflict between scalar values
and the empty value.

@param array      $choices The choices
@param array|null $cache   The cache for previously checked entries. Internal

@return bool returns true if the choices can be cast to strings and
false otherwise
Checks whether the given choices can be cast to strings without generating duplicates . This method is responsible for preventing conflict between scalar values and the empty value .