src/PeekAndPoke/Aviator/ServiceContainer/Builder.php
public function buildInjectionForClass(\ReflectionClass $class, ?\ReflectionMethod $creatorMethod) : InjectionDefinition
    {
        $creatorInjection = new MethodInjection([], '__construct');

        // TODO: can we reshape this ? The check here seems to be out of place
        // is this service create by a factory method ?
        if ($creatorMethod) {
            $creatorInjection = $this->createPublicMethodInjection($creatorMethod);
        } else {
            // else do we have a constructor ?
            $ctor = $class->getConstructor();

            if ($ctor) {
                $creatorInjection = $this->createPublicMethodInjection($ctor);
            }
        }

        /** @var MethodInjection[] $setterInjections */
        $setterInjections = [];

        // build setter injections
        foreach ($class->getMethods() as $method) {
            // only non-static public methods that are marked for injection
            if (! $method->isStatic() &&
                $method->isPublic() &&
                ! $method->isConstructor() &&
                $this->reader->getMethodAnnotation($method, Di\SetterInject::class)
            ) {
                // build and add the injection
                $setterInjections[] = $this->createPublicMethodInjection($method);
            }
        }

        return new InjectionDefinition($creatorInjection, $setterInjections);
    }
public function buildInjectionForClass(\ReflectionClass $class, ?\ReflectionMethod $creatorMethod) : InjectionDefinition
    {
        $creatorInjection = new MethodInjection([], '__construct');

        // TODO: can we reshape this ? The check here seems to be out of place
        // is this service create by a factory method ?
        if ($creatorMethod) {
            $creatorInjection = $this->createPublicMethodInjection($creatorMethod);
        } else {
            // else do we have a constructor ?
            $ctor = $class->getConstructor();

            if ($ctor) {
                $creatorInjection = $this->createPublicMethodInjection($ctor);
            }
        }

        /** @var MethodInjection[] $setterInjections */
        $setterInjections = [];

        // build setter injections
        foreach ($class->getMethods() as $method) {
            // only non-static public methods that are marked for injection
            if (! $method->isStatic() &&
                $method->isPublic() &&
                ! $method->isConstructor() &&
                $this->reader->getMethodAnnotation($method, Di\SetterInject::class)
            ) {
                // build and add the injection
                $setterInjections[] = $this->createPublicMethodInjection($method);
            }
        }

        return new InjectionDefinition($creatorInjection, $setterInjections);
    }
@param \ReflectionClass       $class         The class to be injected into.
@param null|\ReflectionMethod $creatorMethod An optional creator method. If not provided we will search for constructor.

@return InjectionDefinition