Commaaa2
This commit is contained in:
@@ -27,19 +27,11 @@ abstract class AbstractProviderFactory implements ProviderFactoryInterface
|
||||
|
||||
protected function getUser(Dsn $dsn): string
|
||||
{
|
||||
if (null === $user = $dsn->getUser()) {
|
||||
throw new IncompleteDsnException('User is not set.', $dsn->getOriginalDsn());
|
||||
}
|
||||
|
||||
return $user;
|
||||
return $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.', $dsn->getScheme().'://'.$dsn->getHost());
|
||||
}
|
||||
|
||||
protected function getPassword(Dsn $dsn): string
|
||||
{
|
||||
if (null === $password = $dsn->getPassword()) {
|
||||
throw new IncompleteDsnException('Password is not set.', $dsn->getOriginalDsn());
|
||||
}
|
||||
|
||||
return $password;
|
||||
return $dsn->getPassword() ?? throw new IncompleteDsnException('Password is not set.', $dsn->getOriginalDsn());
|
||||
}
|
||||
}
|
||||
|
||||
34
vendor/symfony/translation/Provider/Dsn.php
vendored
34
vendor/symfony/translation/Provider/Dsn.php
vendored
@@ -29,29 +29,29 @@ final class Dsn
|
||||
private array $options = [];
|
||||
private string $originalDsn;
|
||||
|
||||
public function __construct(string $dsn)
|
||||
public function __construct(#[\SensitiveParameter] string $dsn)
|
||||
{
|
||||
$this->originalDsn = $dsn;
|
||||
|
||||
if (false === $parsedDsn = parse_url($dsn)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" translation provider DSN is invalid.', $dsn));
|
||||
if (false === $params = parse_url($dsn)) {
|
||||
throw new InvalidArgumentException('The translation provider DSN is invalid.');
|
||||
}
|
||||
|
||||
if (!isset($parsedDsn['scheme'])) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" translation provider DSN must contain a scheme.', $dsn));
|
||||
if (!isset($params['scheme'])) {
|
||||
throw new InvalidArgumentException('The translation provider DSN must contain a scheme.');
|
||||
}
|
||||
$this->scheme = $parsedDsn['scheme'];
|
||||
$this->scheme = $params['scheme'];
|
||||
|
||||
if (!isset($parsedDsn['host'])) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" translation provider DSN must contain a host (use "default" by default).', $dsn));
|
||||
if (!isset($params['host'])) {
|
||||
throw new InvalidArgumentException('The translation provider DSN must contain a host (use "default" by default).');
|
||||
}
|
||||
$this->host = $parsedDsn['host'];
|
||||
$this->host = $params['host'];
|
||||
|
||||
$this->user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;
|
||||
$this->password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null;
|
||||
$this->port = $parsedDsn['port'] ?? null;
|
||||
$this->path = $parsedDsn['path'] ?? null;
|
||||
parse_str($parsedDsn['query'] ?? '', $this->options);
|
||||
$this->user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null;
|
||||
$this->password = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null;
|
||||
$this->port = $params['port'] ?? null;
|
||||
$this->path = $params['path'] ?? null;
|
||||
parse_str($params['query'] ?? '', $this->options);
|
||||
}
|
||||
|
||||
public function getScheme(): string
|
||||
@@ -74,17 +74,17 @@ final class Dsn
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function getPort(int $default = null): ?int
|
||||
public function getPort(?int $default = null): ?int
|
||||
{
|
||||
return $this->port ?? $default;
|
||||
}
|
||||
|
||||
public function getOption(string $key, mixed $default = null)
|
||||
public function getOption(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return $this->options[$key] ?? $default;
|
||||
}
|
||||
|
||||
public function getRequiredOption(string $key)
|
||||
public function getRequiredOption(string $key): mixed
|
||||
{
|
||||
if (!\array_key_exists($key, $this->options) || '' === trim($this->options[$key])) {
|
||||
throw new MissingRequiredOptionException($key);
|
||||
|
||||
@@ -21,7 +21,7 @@ use Symfony\Component\Translation\TranslatorBagInterface;
|
||||
*/
|
||||
class FilteringProvider implements ProviderInterface
|
||||
{
|
||||
private $provider;
|
||||
private ProviderInterface $provider;
|
||||
private array $locales;
|
||||
private array $domains;
|
||||
|
||||
@@ -37,9 +37,6 @@ class FilteringProvider implements ProviderInterface
|
||||
return (string) $this->provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(TranslatorBagInterface $translatorBag): void
|
||||
{
|
||||
$this->provider->write($translatorBag);
|
||||
|
||||
@@ -14,10 +14,8 @@ namespace Symfony\Component\Translation\Provider;
|
||||
use Symfony\Component\Translation\TranslatorBag;
|
||||
use Symfony\Component\Translation\TranslatorBagInterface;
|
||||
|
||||
interface ProviderInterface
|
||||
interface ProviderInterface extends \Stringable
|
||||
{
|
||||
public function __toString(): string;
|
||||
|
||||
/**
|
||||
* Translations available in the TranslatorBag only must be created.
|
||||
* Translations available in both the TranslatorBag and on the provider
|
||||
|
||||
@@ -21,7 +21,7 @@ final class TranslationProviderCollection
|
||||
/**
|
||||
* @var array<string, ProviderInterface>
|
||||
*/
|
||||
private $providers;
|
||||
private array $providers;
|
||||
|
||||
/**
|
||||
* @param array<string, ProviderInterface> $providers
|
||||
|
||||
Reference in New Issue
Block a user