src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/BeanMethod.php
public static function generateMethod(
        MethodReflection $originalMethod,
        Bean $beanMetadata,
        ?ReflectionType $beanType,
        ForceLazyInitProperty $forceLazyInitProperty,
        SessionBeansProperty $sessionBeansProperty,
        BeanPostProcessorsProperty $postProcessorsProperty,
        BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty,
        GetParameter $parameterValuesMethod,
        WrapBeanAsLazy $wrapBeanAsLazy
    ): MethodGenerator {
        if (null === $beanType) {
            throw new InvalidProxiedClassException(
                sprintf(
                    'Method "%s" on "%s" is missing the return type hint!',
                    $originalMethod->name,
                    $originalMethod->class
                )
            );
        }
        $beanType = (string) $beanType;

        $method = static::fromReflection($originalMethod);
        $methodParams = static::convertMethodParamsToString($beanMetadata->getParameters(), $parameterValuesMethod);
        $beanId = $originalMethod->name;
        $body = '';

        if (in_array($beanType, ['array', 'callable', 'bool', 'float', 'int', 'string'], true)) {
            // return type is a primitive, simply call parent method and return immediately
            $body .= 'return parent::' . $beanId . '(' . $methodParams . ');' . PHP_EOL;
        } elseif (class_exists($beanType) || interface_exists($beanType)) {
            if ($beanMetadata->isLazy()) {
                $body = static::generateLazyBeanCode(
                    '',
                    $beanId,
                    $beanType,
                    $beanMetadata,
                    $methodParams,
                    $forceLazyInitProperty,
                    $sessionBeansProperty,
                    $postProcessorsProperty,
                    $beanFactoryConfigurationProperty
                );
            } else {
                $body = static::generateNonLazyBeanCode(
                    '',
                    $beanId,
                    $beanType,
                    $beanMetadata,
                    $methodParams,
                    $forceLazyInitProperty,
                    $sessionBeansProperty,
                    $postProcessorsProperty,
                    $wrapBeanAsLazy
                );
            }
        } else {
            // return type is unknown, throw an exception
            throw new InvalidProxiedClassException(
                sprintf(
                    'Return type of method "%s" on "%s" cannot be found! Did you use the full qualified name?',
                    $originalMethod->getName(),
                    $originalMethod->getDeclaringClass()->getName()
                )
            );
        }

        $method->setBody($body);
        $method->setDocBlock('{@inheritDoc}');
        return $method;
    }
public static function generateMethod(
        MethodReflection $originalMethod,
        Bean $beanMetadata,
        ?ReflectionType $beanType,
        ForceLazyInitProperty $forceLazyInitProperty,
        SessionBeansProperty $sessionBeansProperty,
        BeanPostProcessorsProperty $postProcessorsProperty,
        BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty,
        GetParameter $parameterValuesMethod,
        WrapBeanAsLazy $wrapBeanAsLazy
    ): MethodGenerator {
        if (null === $beanType) {
            throw new InvalidProxiedClassException(
                sprintf(
                    'Method "%s" on "%s" is missing the return type hint!',
                    $originalMethod->name,
                    $originalMethod->class
                )
            );
        }
        $beanType = (string) $beanType;

        $method = static::fromReflection($originalMethod);
        $methodParams = static::convertMethodParamsToString($beanMetadata->getParameters(), $parameterValuesMethod);
        $beanId = $originalMethod->name;
        $body = '';

        if (in_array($beanType, ['array', 'callable', 'bool', 'float', 'int', 'string'], true)) {
            // return type is a primitive, simply call parent method and return immediately
            $body .= 'return parent::' . $beanId . '(' . $methodParams . ');' . PHP_EOL;
        } elseif (class_exists($beanType) || interface_exists($beanType)) {
            if ($beanMetadata->isLazy()) {
                $body = static::generateLazyBeanCode(
                    '',
                    $beanId,
                    $beanType,
                    $beanMetadata,
                    $methodParams,
                    $forceLazyInitProperty,
                    $sessionBeansProperty,
                    $postProcessorsProperty,
                    $beanFactoryConfigurationProperty
                );
            } else {
                $body = static::generateNonLazyBeanCode(
                    '',
                    $beanId,
                    $beanType,
                    $beanMetadata,
                    $methodParams,
                    $forceLazyInitProperty,
                    $sessionBeansProperty,
                    $postProcessorsProperty,
                    $wrapBeanAsLazy
                );
            }
        } else {
            // return type is unknown, throw an exception
            throw new InvalidProxiedClassException(
                sprintf(
                    'Return type of method "%s" on "%s" cannot be found! Did you use the full qualified name?',
                    $originalMethod->getName(),
                    $originalMethod->getDeclaringClass()->getName()
                )
            );
        }

        $method->setBody($body);
        $method->setDocBlock('{@inheritDoc}');
        return $method;
    }
public static function generateMethod ( MethodReflection $ originalMethod , Bean $ beanMetadata , ? ReflectionType $ beanType , ForceLazyInitProperty $ forceLazyInitProperty , SessionBeansProperty $ sessionBeansProperty , BeanPostProcessorsProperty $ postProcessorsProperty , BeanFactoryConfigurationProperty $ beanFactoryConfigurationProperty , GetParameter $ parameterValuesMethod , WrapBeanAsLazy $ wrapBeanAsLazy ) : MethodGenerator { if ( null === $ beanType ) { throw new InvalidProxiedClassException ( sprintf ( 'Method "%s" on "%s" is missing the return type hint!' , $ originalMethod -> name , $ originalMethod -> class ) ) ; } $ beanType = ( string ) $ beanType ; $ method = static :: fromReflection ( $ originalMethod ) ; $ methodParams = static :: convertMethodParamsToString ( $ beanMetadata -> getParameters ( ) , $ parameterValuesMethod ) ; $ beanId = $ originalMethod -> name ; $ body = '' ; if ( in_array ( $ beanType , [ 'array' , 'callable' , 'bool' , 'float' , 'int' , 'string' ] , true ) ) { // return type is a primitive, simply call parent method and return immediately $ body .= 'return parent::' . $ beanId . '(' . $ methodParams . ');' . PHP_EOL ; } elseif ( class_exists ( $ beanType ) || interface_exists ( $ beanType ) ) { if ( $ beanMetadata -> isLazy ( ) ) { $ body = static :: generateLazyBeanCode ( '' , $ beanId , $ beanType , $ beanMetadata , $ methodParams , $ forceLazyInitProperty , $ sessionBeansProperty , $ postProcessorsProperty , $ beanFactoryConfigurationProperty ) ; } else { $ body = static :: generateNonLazyBeanCode ( '' , $ beanId , $ beanType , $ beanMetadata , $ methodParams , $ forceLazyInitProperty , $ sessionBeansProperty , $ postProcessorsProperty , $ wrapBeanAsLazy ) ; } } else { // return type is unknown, throw an exception throw new InvalidProxiedClassException ( sprintf ( 'Return type of method "%s" on "%s" cannot be found! Did you use the full qualified name?' , $ originalMethod -> getName ( ) , $ originalMethod -> getDeclaringClass ( ) -> getName ( ) ) ) ; } $ method -> setBody ( $ body ) ; $ method -> setDocBlock ( '{@inheritDoc}' ) ; return $ method ; }
Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\BeanMethod}.

@param MethodReflection $originalMethod
@param Bean $beanMetadata
@param ReflectionType|null $beanType
@param ForceLazyInitProperty $forceLazyInitProperty
@param SessionBeansProperty $sessionBeansProperty
@param BeanPostProcessorsProperty $postProcessorsProperty
@param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
@param GetParameter $parameterValuesMethod
@param WrapBeanAsLazy $wrapBeanAsLazy
@return MethodGenerator
@throws \Zend\Code\Generator\Exception\InvalidArgumentException
@throws \ProxyManager\Exception\InvalidProxiedClassException
Creates a new { @link \ bitExpert \ Disco \ Proxy \ Configuration \ MethodGenerator \ BeanMethod } .