Updates to vendors etc

This commit is contained in:
Chris Hunt
2025-07-11 15:57:48 +01:00
parent d972cbcd0a
commit 8fb6438254
8043 changed files with 248005 additions and 189479 deletions

View File

@@ -11,6 +11,7 @@
namespace Symfony\Component\String;
use Random\Randomizer;
use Symfony\Component\String\Exception\ExceptionInterface;
use Symfony\Component\String\Exception\InvalidArgumentException;
use Symfony\Component\String\Exception\RuntimeException;
@@ -45,7 +46,7 @@ class ByteString extends AbstractString
public static function fromRandom(int $length = 16, ?string $alphabet = null): self
{
if ($length <= 0) {
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
throw new InvalidArgumentException(\sprintf('A strictly positive length is expected, "%d" given.', $length));
}
$alphabet ??= self::ALPHABET_ALPHANUMERIC;
@@ -55,6 +56,10 @@ class ByteString extends AbstractString
throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
}
if (\PHP_VERSION_ID >= 80300) {
return new static((new Randomizer())->getBytesFromString($alphabet, $length));
}
$ret = '';
while ($length > 0) {
$urandomLength = (int) ceil(2 * $length * $bits / 8.0);
@@ -335,7 +340,7 @@ class ByteString extends AbstractString
public function slice(int $start = 0, ?int $length = null): static
{
$str = clone $this;
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
$str->string = substr($this->string, $start, $length ?? \PHP_INT_MAX);
return $str;
}
@@ -436,7 +441,7 @@ class ByteString extends AbstractString
}
if (!$validEncoding) {
throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
throw new InvalidArgumentException(\sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
}
$u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');