8000 [PropertyInfo] Extract property type from property declaration by tsantos84 · Pull Request #31798 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PropertyInfo] Extract property type from property declaration #31798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[PropertyInfo] Change exception
  • Loading branch information
tsantos84 committed Jun 9, 2019
commit bc8d70cfa744cd625306f50ad2d7dfeeec86fe13
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private function extractFromDefaultValue(string $class, string $property)
}

/**
* @param \ReflectionType $reflectionType
* @param \ReflectionType $reflectionType
* @param \ReflectionMethod|\ReflectionProperty $reflector
*
* @return Type
Expand All @@ -333,27 +333,27 @@ private function extractFromReflectionType(\ReflectionType $reflectionType, $ref
} elseif ($reflector instanceof \ReflectionMethod || $reflector instanceof \ReflectionProperty) {
$type = new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $this->resolveTypeName($phpTypeOrClass, $reflector));
} else {
throw new \BadMethodCallException(
throw new \InvalidArgumentException(
'$reflector should be an instance of ReflectionMethod or ReflectionProperty, '
.\get_class($reflector).' given'
.(\is_object($reflector) ? \get_class($reflector) : \gettype($reflector)).' given'
);
}

return $type;
}

/**
* @param string $name
* @param string $name
* @param \ReflectionMethod|\ReflectionProperty $reflector
*
* @return string
*/
private function resolveTypeName(string $name, $reflector): string
{
if (!($reflector instanceof \ReflectionMethod || $reflector instanceof \ReflectionProperty)) {
throw new \BadMethodCallException(
throw new \InvalidArgumentException(
'$reflector should be an instance of ReflectionMethod or ReflectionProperty, '
.\get_class($reflector).' given'
.(\is_object($reflector) ? \get_class($reflector) : \gettype($reflector)).' given'
);
}

Expand Down
0