function ProcessUtils::validateInput
Validates and normalizes a Process input.
Parameters
string $caller The name of method call that validates the input:
mixed $input The input to validate:
Throws
InvalidArgumentException In case the input is not valid
2 calls to ProcessUtils::validateInput()
- InputStream::write in vendor/
symfony/ process/ InputStream.php - Appends an input to the write buffer.
- Process::setInput in vendor/
symfony/ process/ Process.php - Sets the input.
File
-
vendor/
symfony/ process/ ProcessUtils.php, line 40
Class
- ProcessUtils
- ProcessUtils is a bunch of utility methods.
Namespace
Symfony\Component\ProcessCode
public static function validateInput(string $caller, mixed $input) : mixed {
if (null !== $input) {
if (\is_resource($input)) {
return $input;
}
if (\is_scalar($input)) {
return (string) $input;
}
if ($input instanceof Process) {
return $input->getIterator($input::ITER_SKIP_ERR);
}
if ($input instanceof \Iterator) {
return $input;
}
if ($input instanceof \Traversable) {
return new \IteratorIterator($input);
}
throw new InvalidArgumentException(\sprintf('"%s" only accepts strings, Traversable objects or stream resources.', $caller));
}
return $input;
}