Cast boolean string values to boolean
@param  mixed $input
@return mixed
976077
public function fixStringBooleanValues(&$input) {

        if (!\is_array($input)) {

			if (\is_string($input) && ($input === 'true' || $input === 'false')) {
				$input = filter_var($input, FILTER_VALIDATE_BOOLEAN);
			}
            return $input;
        }

        foreach ($input as $k => $v) {

            if (\is_array($input[$k])) {
                $input[$k] = $this->fixStringBooleanValues($input[$k]);
            }

            if (\is_string($v) && ($v === 'true' || $v === 'false')) {
				$v = \filter_var($v, FILTER_VALIDATE_BOOLEAN);
            }

            $input[$k] = $v;
        }

        return $input;
    }
741411
public static Boolean[] asBooleanArray(List<Boolean> input) {
		Boolean[] result = new Boolean[input.size()];

		for (int i = 0; i < result.length; i++) {
			result[i] = input.get(i);
		}

		return result;
	}
467327
protected function validate_boolean($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        $bool = filter_var($input[$field], FILTER_VALIDATE_BOOLEAN);

        if (!is_bool($bool)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
526957
function strToBool(input, defaultValue = false) {
  const value = String(input)
    .trim()
    .toLowerCase()
  if (['1', 'true', 'on', 'yes'].includes(value)) return true
  if (['0', 'false', 'off', 'no'].includes(value)) return false
  return defaultValue
}
124684
public static function toFloat($input = false) {

        if ($input && Validate::isNumber($input)) {

            $float = (float) $input;
            if (Validate::isFloat($float)) {

                return $float;
            }
        }

        return false;
    }
1300340
public static function decode($input, $serialized = false)
    {
        // use Base64 encoding to workaround issues with invalid
        // or null characters in serialized string (#1489142)
        if ($serialized) {
            // Keep backward compatybility where base64 wasn't used
            if (strpos(substr($input, 0, 16), ':') !== false) {
                return self::decode(@unserialize($input));
            }

            return @unserialize(base64_decode($input));
        }

        if (is_object($input)) {
            foreach (get_object_vars($input) as $idx => $value) {
                $input->$idx = self::decode($value);
            }
            return $input;
        }
        else if (is_array($input)) {
            foreach ($input as $idx => $value) {
                $input[$idx] = self::decode($value);
            }
            return $input;
        }

        return utf8_decode($input);
    }
600538
public function validate($input): bool
    {
        if (\is_array($this->haystack)) {
            return \in_array($input, $this->haystack, false);
        }

        if (!\is_string($this->haystack)) {
            return false;
        }

        if (empty($input)) {
            return false;
        }

        $enc = mb_detect_encoding($input);

        return mb_stripos($this->haystack, $input, 0, $enc) !== false;
    }
1352445
public static function toBoolean($value)
    {
        if (is_string($value)) {
            if ($value === 'true') {
                $value = true;
            } else {
                $value = false;
            }
        } elseif (is_bool($value) === false) {
            $value = false;
        }

        return $value;
    }
963762
private function _convertToBin($input, $base)
    {
        switch ($base) {
            case 2:
                return DataConverter::pad($input, $this->binSize);
            case 10:
                return DataConverter::decToBin($input, $this->binSize);
            case 16:
                return DataConverter::hexToBin($input, $this->binSize);
        }
    }
93259
public static function boolean($input, $field_name = 'boolean')
    {
        //Define trivial model
        $model = [
            $field_name => ['type' => Validate::TYPE_BOOLEAN, Validate::REQUIRED]
        ];

        $parameters = [$field_name => $input];
        Validate::model($parameters, $model);

        return $parameters[$field_name];
    }
1066010
public static function toObject($input = false) {

        if ($input) {

            switch (Data::type($input)) {
                case 'array':
                    $object = self::arrayToObject($input);
                    break;
                case 'object':
                    $object = $input;
                    break;
            }

            if (Validate::isObject($object)) {

                return $object;
            }
        }

        return false;
    }
1283187
public static function toArray($input = false) {

        if ($input) {

            switch (Data::type($input)) {
                case 'array':
                    $array = $input;
                    break;
                case 'object':
                    $array = self::arrayToObject($input);
                    break;
            }

            if (Validate::isObject($input)) {

                return $input;
            }
        }

        return false;
    }
1307086
public function filterBoolean($value)
    {
        if ($value === null) {
            return null;
        }
        $booleanFormat = [
            $this->booleanFormat[0] => false, $this->booleanFormat[1] => true,
            'false'                 => false, 'true' => true,
            '0'                     => false, '1' => true,
            ''                      => false,
        ];
        $map = [];
        foreach ($booleanFormat as $label => $key) {
            $label = mb_strtolower($label, 'UTF-8');
            $map[$label] = $key;
            if (mb_strlen($label, 'UTF-8') > 1) {
                $map[mb_substr($label, 0, 1, 'UTF-8')] = $key;
            }
        }
        $value = mb_strtolower($value, 'UTF-8');

        return !isset($map[$value]) ? null : (int)$map[$value];
    }
728364
protected function isString($input)
    {
        return is_scalar($input) || is_null($input) || (is_object($input) && method_exists($input, '__toString'));
    }
1123124
private static Boolean castToBoolean(Object val) //was BooleanValue
  {
    if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(cclass, "castToBoolean", val);
    Boolean theReturn = null;
    if (val instanceof String)
    {
      String stringVal = (String) val;
      if (stringVal.equalsIgnoreCase("true"))
        theReturn = Boolean.TRUE; // was BooleanValue.TRUE
      else
        if (stringVal.equalsIgnoreCase("false"))
          theReturn = Boolean.FALSE; // was BooleanValue.FALSE
    }
    if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(cclass, "castToBoolean", theReturn);    
    return theReturn;
  }
109324
public function validate($input): bool
    {
        // for array
        if (\is_array($input)) {
            return \in_array($this->containsValue, $input, false);
        }
        // for string
        if (\is_string($input)) {
            return false !== mb_stripos($input, $this->containsValue, 0, mb_detect_encoding($input));
        }
        // can't compare
        return false;
    }
1271484
protected function castToBool($value, bool $nullable = true)
    {
        if (null === $value && $nullable) {
            return null;
        }

        return (bool) $value;
    }