Mistři v programování na #hovnokod

PHP #4577

trim je zrejme malo sofistikovany

private static function checkWhitespaces(string $argument): void
	{
		$charlist = preg_quote(" \t\n\r\0\x0B\xC2\xA0", '#');
		preg_replace('#^[' . $charlist . ']+|[' . $charlist . ']+\z#u', '', $argument);
		if ($argument !== preg_replace('#^[' . $charlist . ']+|[' . $charlist . ']+\z#u', '', $argument)) {
			throw new \InvalidArgumentException('Argument starts or ends with whitespace.');
		}
	}

Anonymous,