for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Ray\Di;
use Ray\Aop\ReflectionClass;
use Ray\Aop\ReflectionMethod;
use Ray\Di\Di\InjectInterface;
use ReflectionAttribute;
final class AnnotatedClassMethods
{
/**
* @phpstan-param ReflectionClass<object> $class
*/
public function getConstructorName(ReflectionClass $class): Name
$constructor = $class->getConstructor();
if (! $constructor) {
$constructor
Ray\Aop\ReflectionMethod
true
return new Name(Name::ANY);
}
$reflMethod = new \ReflectionMethod($class->getName(), '__construct');
$name = Name::withAttributes($reflMethod);
if ($name) {
return $name;
public function getSetterMethod(ReflectionMethod $method): ?SetterMethod
$inject = $method->getAnnotation(InjectInterface::class, ReflectionAttribute::IS_INSTANCEOF);
if (! $inject instanceof InjectInterface) {
return null;
$name = $this->getName($method);
$setterMethod = new SetterMethod($method, $name);
if ($inject->isOptional()) {
$setterMethod->setOptional();
return $setterMethod;
private function getName(ReflectionMethod $method): Name
$name = Name::withAttributes($method);