for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Paysera\Bundle\ApiBundle\Service\Annotation;
use Paysera\Bundle\ApiBundle\Exception\ConfigurationException;
use ReflectionMethod;
use ReflectionParameter;
/**
* @internal
*/
class ReflectionMethodWrapper
{
private $reflectionMethod;
public function __construct(ReflectionMethod $reflectionMethod)
$this->reflectionMethod = $reflectionMethod;
}
public function getParameterByName(string $name): ReflectionParameter
foreach ($this->reflectionMethod->getParameters() as $parameter) {
if ($parameter->getName() === $name) {
$parameter->name
getName()
return $parameter;
throw new ConfigurationException(sprintf(
'Parameter %s is configured but not found in method %s',
'$' . $name,
$this->getFriendlyName()
));
public function getNonBuiltInTypeForParameter(string $name): string
$parameter = $this->getParameterByName($name);
$type = $parameter->getType();
if ($type === null || $type->isBuiltin()) {
'Expected non built-in type-hint for %s in %s',
'$' . $parameter->getName(),
// `$type->getName()` should be used when 7.0 support is dropped
return (string)$type;
public function getFriendlyName()
return sprintf(
'%s::%s',
$this->reflectionMethod->getDeclaringClass()->getName(),
$this->reflectionMethod->class
$this->reflectionMethod->getName()
$this->reflectionMethod->name
);