Are Arguments Valid

@param array    $args
@param string[] $accepted

@return null|bool
511413
protected function areArgumentsValid($args, array $accepted)
    {
        if ($args == null)
        {
            return;
        }

        foreach ($accepted as $accept)
        {
            if (array_key_exists($accept, $args))
            {
                return true;
            }
        }

        throw new \InvalidArgumentException('This call only accepts these arguments: ' . implode(" | ",$accepted));
    }
893495
public static boolean checkArgs(String[] args) {
	if (args.length < 5) {
	    return false;
	}
	
	if (!(args[0].compareToIgnoreCase("-all") == 0 ||
		    args[0].compareToIgnoreCase("-trn") == 0 ||
		    args[0].compareToIgnoreCase("-tst") == 0) || 
		    args[0].compareToIgnoreCase("-cont") == 0) {
	    return false;
	}
	
	if (args[1].compareToIgnoreCase("-d") != 0) {
	    return false;
	}
	
	if (args[3].compareToIgnoreCase("-o") != 0)
		return false; 
	
	return true;
    }
929579
public static function notNull($argValue, $argName = '')
    {
        $valid = ($argValue !== null);
        if (!$valid) {
            $message = implode(' ', array_filter(['Argument', $argName, 'must not be null']));
            throw new \InvalidArgumentException($message);
        }
        return $valid;
    }
314805
public function validate($args)
    {
        $check = $this->normalizeArgs(is_array($args) ? $args : []);

        return is_array($check) ? true : $check;
    }
126109
function verifyArguments(args) {
	const isInvalid = args.some((arg) => typeof arg !== 'string');
	if (isInvalid) {
		const argsString = args.map((arg) => util.format('%j', arg)).join(', ');
		const msg = util.format('Transaction arguments must be strings: %s', argsString);
		logger.error('verifyArguments:', msg);
		throw new Error(msg);
	}
}
400252
public function parseArguments(array $args)
    {
        if (!isset($args['action']) || empty($args['action'])) {
            if (isset($args['version']) ||  isset($args['V'])) {
                $this->action = 'Version';
                $this->arguments = $args;
                return $this->arguments;
            }
            if (isset($args['help']) || isset($args['h'])) {
                $this->action = 'Help';
                $this->arguments = $args;
                return $this->arguments;
            }
            throw new RequestException($this, "No valid action argument specified.");
        }
        $this->action = $args['action'];
        unset($args['action']);
        $this->arguments = $args;
        return $this->arguments;
    }
859983
protected function processArguments($arguments)
    {
        if (false === is_array($arguments)) {
            return $arguments;
        }

        return array_map(function ($argument) {
            return (string) $argument;
        }, $arguments);
    }
916504
public function check(...$args)
    {
        if (count($args) !== count($this->constraints)) {
            throw new InvalidArgumentException(
                'Argument number mismatch.'
            );
        }

        foreach ($args as $key => $arg) {
            if (!$this->constraints[$key]->check($arg, $args)) {
                throw new InvalidArgumentException(vsprintf(
                    'Argument %s does not meet its constraints.'
                    . "\nFailed constraint: %s\nValue provided:%s",
                    [
                        $key,
                        $this->constraints[$key]->toString(),
                        print_r($arg, true)
                    ]
                ));
            }
        }
    }
276294
protected function validateArgs()
    {
        $message = null;
        foreach ($this->getMandatoryArgs() as $arg) {
            if (!isset($this->args[$arg])) {
                $message = "Argument $arg was not present in supplied job args for job " . get_class($this);
                $this->errorLog($message);
                throw new \Exception($message);
            }
        }
        if ($this->configRequired) {
            $this->ensureConfig();
        }
    }
748645
protected function validateMissingArguments(array $arguments): bool
    {
        $missingArguments = \array_filter($arguments, function ($argument) {
            return empty($this->argument($argument));
        });

        if (\count($missingArguments) > 1) {
            throw new RuntimeException(\sprintf('Not enough arguments (missing: "%s").', \implode(', ', $missingArguments)));
        }

        return true;
    }
544823
public function unapprove( $args, $assoc_args ) {
		$this->check_server_name();
		foreach ( $args as $id ) {
			$this->set_status( $id, 'hold', 'Unapproved' );
		}
	}
72965
protected function validateArray($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        $count = $args[0] ?? null;

        if ($count !== null) {
            if ($count == '' || !is_numeric($count)) {
                throw new ValidatorConfigException("Invalid array count definition for parameter {$parameter}");
            }

            $count = (int)$count;

            if ($count < 0) {
                throw new ValidatorConfigException("Invalid array count definition for parameter {$parameter}, argument can not be negative");
            }
        }

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (is_string($value) && $value === '') {
            return null;
        }

        if (!is_array($value)) {
            return Message::getMessage(Message::IS_NOT_ARRAY, [
                'param' => $parameter
            ]);
        }

        if ($count !== null) {
            $currentCount = count($value);

            if ($currentCount != $count) {
                if (ctype_digit($parameter)) {
                    $parameter = "Element on position {$parameter}";
                }

                return Message::getMessage(Message::ARRAY_WRONG_COUNT, [
                    'param' => $parameter,
                    'requiredCount' => $count,
                    'currentCount' => $currentCount
                ]);
            }
        }

        return null;
    }
969931
public static function evaluateArgs(array $args)
    {

        $parsedArgs = [];

        foreach ($args as $key=>$value) {

            if ($value instanceof self) {
                $parsedArgs[$key] = static::callFast($value);
                continue;
            }
            $parsedArgs[$key] = $args[$key];
        }

        return $parsedArgs;

    }
1091719
function parseExtensionArgs($args)
    {
        // preferred_auth_policies is a space-separated list of policy
        // URIs
        $this->preferred_auth_policies = array();

        $policies_str = Auth_OpenID::arrayGet($args, 'preferred_auth_policies');
        if ($policies_str) {
            foreach (explode(' ', $policies_str) as $uri) {
                if (!in_array($uri, $this->preferred_auth_policies)) {
                    $this->preferred_auth_policies[] = $uri;
                }
            }
        }

        // max_auth_age is base-10 integer number of seconds
        $max_auth_age_str = Auth_OpenID::arrayGet($args, 'max_auth_age');
        if ($max_auth_age_str) {
            $this->max_auth_age = Auth_OpenID::intval($max_auth_age_str);
        } else {
            $this->max_auth_age = null;
        }
    }
1044869
private void checkArgument(boolean argument, String msg, Object... args) {
        if (!argument) {
            throw new IllegalArgumentException(String.format(msg, args));
        }
    }
1331561
public static function findMatches(array $accepted, array $available = []) {
		$matches = [];
		if (!$available) {
			$available = static::parseLanguageList();
		}
		foreach ($accepted as $acceptedValue) {
			foreach ($available as $availableQuality => $availableValues) {
				$availableQuality = (float)$availableQuality;
				if ($availableQuality === 0.0) {
					continue;
				}

				foreach ($availableValues as $availableValue) {
					$matchingGrade = static::_matchLanguage($acceptedValue, $availableValue);
					if ($matchingGrade > 0) {
						$q = (string)($availableQuality * $matchingGrade);
						if ($q === '1') {
							$q = '1.0';
						}
						if (!isset($matches[$q])) {
							$matches[$q] = [];
						}
						if (!in_array($availableValue, $matches[$q])) {
							$matches[$q][] = $availableValue;
						}
					}
				}
			}
		}
		krsort($matches);
		return $matches;
	}
1352532
private function validate_input( $assoc_args, $grouping ) {
		// Check if valid arguments were passed.
		$arg_match = preg_grep( '/^set-(\w+)/i', array_keys( $assoc_args ) );

		// Verify passed-arguments.
		if ( empty( $grouping ) && empty( $arg_match ) ) {
			WP_CLI::error( 'No valid arguments passed.' );
		}

		// Check whether passed arguments contain value or not.
		$assoc_arg_values = array_filter( array_intersect_key( $assoc_args, array_flip( $arg_match ) ) );

		if ( empty( $grouping ) && empty( $assoc_arg_values ) ) {
			WP_CLI::error( 'No value passed to arguments.' );
		}
	}