mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 11:48:08 +08:00
Fixed bug.
This commit is contained in:
parent
2c9dadfda4
commit
e8a6d8238d
@ -267,16 +267,14 @@ class Translator implements TranslatorInterface
|
||||
$parsed = $this->parseNamespacedSegments($key);
|
||||
}
|
||||
|
||||
if (is_null($parsed[0])) {
|
||||
$parsed[0] = '*';
|
||||
}
|
||||
|
||||
// Once we have the parsed array of this key's elements, such as its groups
|
||||
// and namespace, we will cache each array inside a simple list that has
|
||||
// the key and the parsed array for quick look-ups for later requests.
|
||||
$segments = $this->parsed[$key] = $parsed;
|
||||
|
||||
if (is_null($segments[0])) {
|
||||
$segments[0] = '*';
|
||||
}
|
||||
|
||||
return $segments;
|
||||
return $this->parsed[$key] = $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,6 +393,7 @@ class Translator implements TranslatorInterface
|
||||
if (is_string($line)) {
|
||||
return $this->makeReplacements($line, $replace);
|
||||
}
|
||||
|
||||
if (is_array($line) && count($line) > 0) {
|
||||
foreach ($line as $key => $value) {
|
||||
$line[$key] = $this->makeReplacements($value, $replace);
|
||||
@ -406,8 +405,11 @@ class Translator implements TranslatorInterface
|
||||
|
||||
/**
|
||||
* Make the place-holder replacements on a line.
|
||||
*
|
||||
* @param array|string $line
|
||||
* @return array|string
|
||||
*/
|
||||
protected function makeReplacements(string $line, array $replace): string
|
||||
protected function makeReplacements($line, array $replace)
|
||||
{
|
||||
if (empty($replace)) {
|
||||
return $line;
|
||||
|
@ -462,7 +462,7 @@ trait ValidatesAttributes
|
||||
$column,
|
||||
$value,
|
||||
$parameters
|
||||
) >= $expected;
|
||||
) >= $expected;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -514,7 +514,7 @@ trait ValidatesAttributes
|
||||
$id,
|
||||
$idColumn,
|
||||
$extra
|
||||
) == 0;
|
||||
) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1449,7 +1449,7 @@ trait ValidatesAttributes
|
||||
{
|
||||
return Carbon::hasTestNow() && is_string($value) && (
|
||||
$value === 'now' || Carbon::hasRelativeKeywords($value)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,7 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Validation;
|
||||
|
||||
use Closure;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Translation\Contracts\Translator;
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Utils\Str;
|
||||
use Hyperf\Validation\Contracts\Validation\Factory as FactoryContract;
|
||||
use Psr\Container\ContainerInterface;
|
||||
@ -24,7 +23,7 @@ class Factory implements FactoryContract
|
||||
/**
|
||||
* The Translator implementation.
|
||||
*
|
||||
* @var \Hyperf\Translation\Contracts\Translator
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
@ -86,11 +85,8 @@ class Factory implements FactoryContract
|
||||
|
||||
/**
|
||||
* Create a new Validator factory instance.
|
||||
*
|
||||
* @param null|\Hyperf\Translation\Contracts\Translator $translator
|
||||
* @param Container
|
||||
*/
|
||||
public function __construct(Translator $translator, ContainerInterface $container = null)
|
||||
public function __construct(TranslatorInterface $translator, ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->translator = $translator;
|
||||
@ -220,7 +216,7 @@ class Factory implements FactoryContract
|
||||
/**
|
||||
* Get the Translator implementation.
|
||||
*
|
||||
* @return \Hyperf\Translation\Contracts\Translator
|
||||
* @return TranslatorInterface
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
|
@ -13,9 +13,9 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Validation;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\HttpMessage\Upload\UploadedFile;
|
||||
use Hyperf\Translation\Contracts\Translator;
|
||||
use Hyperf\Utils\Arr;
|
||||
use Hyperf\Utils\Fluent;
|
||||
use Hyperf\Utils\Str;
|
||||
@ -76,7 +76,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* The Translator implementation.
|
||||
*
|
||||
* @var \Hyperf\Translation\Contracts\Translator
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
@ -205,14 +205,14 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Create a new Validator instance.
|
||||
*
|
||||
* @param \Hyperf\Translation\Contracts\Translator $translator
|
||||
* @param TranslatorInterface $translator
|
||||
* @param array $data
|
||||
* @param array $rules
|
||||
* @param array $messages
|
||||
* @param array $customAttributes
|
||||
*/
|
||||
public function __construct(
|
||||
Translator $translator,
|
||||
TranslatorInterface $translator,
|
||||
array $data,
|
||||
array $rules,
|
||||
array $messages = [],
|
||||
@ -826,7 +826,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Get the Translator implementation.
|
||||
*
|
||||
* @return \Hyperf\Translation\Contracts\Translator
|
||||
* @return TranslatorInterface
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
@ -836,9 +836,9 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Set the Translator implementation.
|
||||
*
|
||||
* @param \Hyperf\Translation\Contracts\Translator $translator
|
||||
* @param TranslatorInterface $translator
|
||||
*/
|
||||
public function setTranslator(Translator $translator)
|
||||
public function setTranslator(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
@ -12,15 +12,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\Validation;
|
||||
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Database\ConnectionResolverInterface;
|
||||
use Hyperf\Translation\Contracts\Translator;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ValidatorFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$translator = $container->get(Translator::class);
|
||||
$translator = $container->get(TranslatorInterface::class);
|
||||
|
||||
$validator = make(Factory::class, compact('translator', 'container'));
|
||||
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace HyperfTest\Validation\Cases;
|
||||
|
||||
use Hyperf\Translation\Contracts\Translator as TranslatorInterface;
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Validation\Factory;
|
||||
use Hyperf\Validation\PresenceVerifierInterface;
|
||||
use Hyperf\Validation\Validator;
|
||||
|
@ -15,11 +15,11 @@ namespace HyperfTest\Validation\Cases;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Hyperf\Contract\TranslatorInterface as TranslatorContract;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Di\Definition\DefinitionSourceInterface;
|
||||
use Hyperf\HttpMessage\Upload\UploadedFile;
|
||||
use Hyperf\Translation\ArrayLoader;
|
||||
use Hyperf\Translation\Contracts\Translator as TranslatorContract;
|
||||
use Hyperf\Translation\Translator;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Arr;
|
||||
|
Loading…
Reference in New Issue
Block a user