Validate that the params array includes at least one of
the keys in a given array

@param string[] $atLeastOneOf allowed properties
@param array $params       array to check

@return boolean

@throws MissingArgumentException
177773
protected function validateAtLeastOneOf(array $atLeastOneOf, array $params)
    {
        foreach ($atLeastOneOf as $param) {
            if (isset($params[$param])) {
                return true;
            }
        }

        throw new MissingArgumentException(sprintf(
            'You need to provide at least one of the following parameters "%s".',
            implode('", "', $atLeastOneOf)
        ));
    }
85720
protected function validate_required($field, $input, $param = null)
    {
        if (isset($input[$field]) && ($input[$field] === false || $input[$field] === 0 || $input[$field] === 0.0 || $input[$field] === '0' || !empty($input[$field]))) {
            return;
        }

        return array(
            'field' => $field,
            'value' => null,
            'rule' => __FUNCTION__,
            'param' => $param,
        );
    }
350359
protected function checkEmptyHook($params)
    {
        $hookName = $this->getParam($params, 'rel');

        if (null == $hookName) {
            throw new \InvalidArgumentException(
                $this->translator->trans("Missing 'rel' parameter in ifhook/elsehook arguments")
            );
        }

        if (!isset($this->hookResults[$hookName])) {
            $exception = new \InvalidArgumentException(
                $this->translator->trans("Related hook name '%name' is not defined.", ['%name' => $hookName])
            );

            Tlog::getInstance()->error($exception->getMessage());

            if ($this->debug) {
                throw $exception;
            }

            return true;
        }

        return (is_string($this->hookResults[$hookName]) && '' === $this->hookResults[$hookName]
            || !is_string($this->hookResults[$hookName]) && $this->hookResults[$hookName]->isEmpty()
        );
    }
354278
protected function configure(array $params)
    {
        $required = array('hostname', 'base_dn');
        $missing = array();
        foreach ($required as $key) {
            if (! array_key_exists($key, $params)) {
                $missing[] = $key;
            }
        }
        if (count($missing) > 0) {
            throw new \InvalidArgumentException(
                'Required parameters missing: ' . implode(', ', $missing)
            );
        }

        $idx = strpos($params['hostname'], '://');
        $enforceSSL = false;
        if (false !== $idx) {
            $prefix = strtolower(substr($params['hostname'], 0, $idx));
            if ($prefix === 'ldaps') {
                $enforceSSL = true;
            }
            $params['hostname'] = substr($params['hostname'], $idx+3);
        }

        $params['withSSL'] = false;
        $params['withTLS'] = false;
        if (array_key_exists('security', $params)) {
            switch($params['security']) {
            case 'SSL':
                $params['withSSL'] = true;
                break;
            case 'TLS':
                $params['withTLS'] = true;
                break;
            default:
                throw new \InvalidArgumentException(
                    sprintf(
                        'Security mode %s not supported - only SSL or TLS are supported',
                        $params['security']
                    )
                );
            }
        } elseif ($enforceSSL) {
            $params['withSSL'] = true;
        }

        if (! array_key_exists('port', $params)) {
            if ($params['withSSL']) {
                $params['port'] = 636;
            } else {
                $params['port'] = 389;
            }
        }

        if (! array_key_exists('options', $params)) {
            $params['options'] = array();
        }

        $params['bind_anonymous'] = false;
        if ((! array_key_exists('bind_dn', $params)) || (strlen(trim($params['bind_dn'])) == 0)) {
            $params['bind_anonymous'] = true;
            $params['bind_dn']        = '';
            $params['bind_password']  = '';
        }
        if (! array_key_exists('bind_password', $params)) {
            $params['bind_password']  = '';
        }

        $this->configuration = $params;
    }
1346548
public static function validateEquality($paramName, array $data,
                                            array $params = [])
    {
        $result = true;

        if (!isset($data[$paramName])) {
            throw new \Exception('Parameter is not set');
        }
        if (!isset($params['equalTo'])) {
            throw new \Exception('Parameter \'equalTo\' is required');
        }

        if ($data[$paramName] !== $data[$params['equalTo']]) {
            $result = false;
        }

        return $result;
    }
1250069
public static function assertHas(
        array $params,
        string $key,
        $context = null
    ) {
        if (self::has($params, $key)) {
            return;
        }

        $message = self::buildErrorMessage(
            $params,
            $key,
            "Property ({$key}) is missing and is required",
            $context
        );

        self::throwParamException(
            $params,
            $key,
            new ArrayPropertyMissing($message)
        );
    }
202340
private static function _checkParams(array $params) : void
    {
        // check existence of mandatory parameters

        // driver
        if (! isset($params['driver']) && ! isset($params['driverClass'])) {
            throw DBALException::driverRequired();
        }

        // check validity of parameters

        // driver
        if (isset($params['driver']) && ! isset(self::$_driverMap[$params['driver']])) {
            throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap));
        }

        if (isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass'], true))) {
            throw DBALException::invalidDriverClass($params['driverClass']);
        }
    }
794156
private function isMethodIncluded($methodName, $attr)
    {
        if (empty($attr[self::CONFIG_INCLUDE]) || !is_array($attr[self::CONFIG_INCLUDE])) {
            return true;
        }
        
        return in_array($methodName, $attr[self::CONFIG_INCLUDE]);
    }
1194971
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['rcf_username']) || empty($params['rcf_api'])) {
                return false;
            }
            
            return m62Rcf::getRemoteClient($params, false);
        } catch (\Exception $e) {
            return false;
        }
    }
551696
protected function checkRequiredParameters()
    {
        $missing = array_diff(
            $this->getRequiredOptions(),
            array_keys($this->getOptions())
        );
        if (!empty($missing)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Missing required parameters: %s',
                    implode(', ', $missing)
                ),
                self::STATE_UNKNOWN
            );
        }

        return $this;
    }
341859
final public static function findBy(array $criteria, bool $withTrash = false)
    {
        $criteria = self::criteriaWithSoftDelete($criteria, $withTrash);
        $instance = static::getRepository()
            ->findOneBy($criteria);
        // use this to avoid lint error in idea
        if ($instance instanceof static) {
            return $instance;
        } else {
            return null;
        }
    }
927036
protected function validate_street_address($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        // Theory: 1 number, 1 or more spaces, 1 or more words
        $hasLetter = preg_match('/[a-zA-Z]/', $input[$field]);
        $hasDigit = preg_match('/\d/', $input[$field]);
        $hasSpace = preg_match('/\s/', $input[$field]);

        $passes = $hasLetter && $hasDigit && $hasSpace;

        if (!$passes) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
1056607
public function getValidationRules($attrList = [], $values = [])
    {
        $allRules = isset($this->validationRules)
            ? $this->validationRules
            : [];

        foreach ($allRules as &$item) {
            $keys = $this->getRuleAttr($item);

            foreach ($keys as $key) {
                $value = isset($values[$key]) ? $values[$key] : 'NULL';
                $item = str_replace('{$' . $key . '}', $value, $item);
            }
        }
        unset($item);

        if (empty($attrList))
            return $allRules;

        foreach ($attrList as $attr)
            $rules[$attr] = isset($allRules[$attr]) ? $allRules[$attr] : '';

        return $rules;
    }
942584
protected function validate_boolean($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field]) && $input[$field] !== 0) {
            return;
        }

        $booleans = array('1','true',true,1,'0','false',false,0,'yes','no','on','off');
        if (in_array($input[$field], $booleans, true )) {
            return;
        }

        return array(
            'field' => $field,
            'value' => $input[$field],
            'rule' => __FUNCTION__,
            'param' => $param,
        );
    }
809017
protected function checkEmptyLoop($params)
    {
        $loopName = $this->getParam($params, 'rel');

        if (null == $loopName) {
            throw new \InvalidArgumentException(
                $this->translator->trans("Missing 'rel' parameter in ifloop/elseloop arguments")
            );
        }

        if (! isset($this->loopstack[$loopName])) {
            throw new \InvalidArgumentException(
                $this->translator->trans("Related loop name '%name'' is not defined.", ['%name' => $loopName])
            );
        }

        return $this->loopstack[$loopName]->isEmpty();
    }
466007
private function validateAndSetBotParamsSpecial(array $params)
    {
        // Special case, where secret MUST be defined if we have a webhook.
        if (($params['webhook']['url'] ?? null) && !($params['secret'] ?? null)) {
            // This does not apply when using CLI, but make sure it gets tested for!
            if ('cli' !== PHP_SAPI || BotManager::inTest()) {
                throw new InvalidParamsException('Some vital info is missing: secret');
            }
        }
    }
534644
public function checkParamSpecialChars(& $sValue, $aRaw = null)
    {
        if (is_object($sValue)) {
            return $sValue;
        }

        if (is_array($sValue)) {
            $newValue = [];
            foreach ($sValue as $sKey => $sVal) {
                $sValidKey = $sKey;
                if (!$aRaw || !in_array($sKey, $aRaw)) {
                    $this->checkParamSpecialChars($sValidKey);
                    $this->checkParamSpecialChars($sVal);
                    if ($sValidKey != $sKey) {
                        unset($sValue[$sKey]);
                    }
                }
                $newValue[$sValidKey] = $sVal;
            }
            $sValue = $newValue;
        } elseif (is_string($sValue)) {
            $sValue = str_replace(
                ['&', '<', '>', '"', "'", chr(0), '\\', "\n", "\r"],
                ['&amp;', '&lt;', '&gt;', '&quot;', '&#039;', '', '&#092;', '&#10;', '&#13;'],
                $sValue
            );
        }

        return $sValue;
    }