Skip to content

Commit

Permalink
提交
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjincheng committed May 17, 2019
1 parent 68c5ae7 commit 9f55dd5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/Validate/Annotation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ public function build($name)


/**
* @param ReflectionClass $reflectionClass
* @param ReflectionClass|string $reflectionClass
* @param $values
* @return array
* @throws DependencyException
* @throws \DI\NotFoundException
* @throws \ReflectionException
*/
public static function filter(ReflectionClass $reflectionClass, $values)
public static function filter($reflectionClass, $values)
{
$filterRole = self::buildRole($reflectionClass);
if (!empty($filterRole)) {
Expand All @@ -178,14 +179,21 @@ public static function filter(ReflectionClass $reflectionClass, $values)
}

/**
* @param ReflectionClass $reflectionClass
* @param ReflectionClass|string $reflectionClass
* @return array
* @throws DependencyException
* @throws \DI\NotFoundException
* @throws \DI\DependencyException
* @throws \ReflectionException
*/
public static function buildRole(ReflectionClass $reflectionClass)
public static function buildRole($reflectionClass)
{
if (is_string($reflectionClass)) {
if (array_key_exists($reflectionClass, self::$cache)) {
return self::$cache[$reflectionClass];
}
$reflectionClass = new ReflectionClass($reflectionClass);
}
if (array_key_exists($reflectionClass->name, self::$cache)) {
return self::$cache[$reflectionClass->name];
}
Expand Down
16 changes: 12 additions & 4 deletions src/Validate/Annotation/Validated.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,14 @@ public function build($name)
}

/**
* @param ReflectionClass $reflectionClass
* @param ReflectionClass|string $reflectionClass
* @param $values
* @throws ValidationException
* @throws DependencyException
* @throws \DI\NotFoundException
* @throws \ReflectionException
*/
public static function valid(ReflectionClass $reflectionClass, $values)
public static function valid($reflectionClass, $values)
{
$validRole = self::buildRole($reflectionClass);
if (!empty($validRole)) {
Expand All @@ -332,13 +333,20 @@ public static function valid(ReflectionClass $reflectionClass, $values)
}

/**
* @param ReflectionClass $reflectionClass
* @param ReflectionClass|string $reflectionClass
* @return array
* @throws DependencyException
* @throws \DI\NotFoundException
* @throws \ReflectionException
*/
public static function buildRole(ReflectionClass $reflectionClass)
public static function buildRole($reflectionClass)
{
if (is_string($reflectionClass)) {
if (array_key_exists($reflectionClass, self::$cache)) {
return self::$cache[$reflectionClass];
}
$reflectionClass = new ReflectionClass($reflectionClass);
}
if (array_key_exists($reflectionClass->name, self::$cache)) {
return self::$cache[$reflectionClass->name];
}
Expand Down

0 comments on commit 9f55dd5

Please sign in to comment.