Resolver/FormAnnotationResolver.php
private function getBuiltObject(
        Request $request,
        FormFactoryInterface $formFactory,
        CreateForm $annotation,
        string $parameterClass,
        AbstractType $type
    ) {
        /**
         * Checks if parameter typehinting is AbstractType
         * In this case, form type as defined method parameter.
         */
        if (AbstractType::class == $parameterClass) {
            return $type;
        }

        $entity = $request->attributes->get($annotation->getEntity());

        /**
         * Creates form object from type.
         */
        $form = $formFactory->create(get_class($type), $entity);

        /**
         * Handling request if needed.
         */
        if ($annotation->getHandleRequest()) {
            $form->handleRequest($request);

            if ($annotation->getValidate()) {
                $request->attributes->set(
                    $annotation->getValidate(),
                    ($form->isSubmitted() && $form->isValid())
                );
            }
        }

        /**
         * Checks if parameter typehinting is Form
         * In this case, inject form as defined method parameter.
         */
        if (in_array(
            $parameterClass, [
                Form::class,
                FormInterface::class,
            ]
        )) {
            return $form;
        }

        /**
         * Checks if parameter typehinting is FormView
         * In this case, inject form's view as defined method parameter.
         */
        if (FormView::class == $parameterClass) {
            return $form->createView();
        }
    }
private function getBuiltObject(
        Request $request,
        FormFactoryInterface $formFactory,
        CreateForm $annotation,
        string $parameterClass,
        AbstractType $type
    ) {
        /**
         * Checks if parameter typehinting is AbstractType
         * In this case, form type as defined method parameter.
         */
        if (AbstractType::class == $parameterClass) {
            return $type;
        }

        $entity = $request->attributes->get($annotation->getEntity());

        /**
         * Creates form object from type.
         */
        $form = $formFactory->create(get_class($type), $entity);

        /**
         * Handling request if needed.
         */
        if ($annotation->getHandleRequest()) {
            $form->handleRequest($request);

            if ($annotation->getValidate()) {
                $request->attributes->set(
                    $annotation->getValidate(),
                    ($form->isSubmitted() && $form->isValid())
                );
            }
        }

        /**
         * Checks if parameter typehinting is Form
         * In this case, inject form as defined method parameter.
         */
        if (in_array(
            $parameterClass, [
                Form::class,
                FormInterface::class,
            ]
        )) {
            return $form;
        }

        /**
         * Checks if parameter typehinting is FormView
         * In this case, inject form's view as defined method parameter.
         */
        if (FormView::class == $parameterClass) {
            return $form->createView();
        }
    }
private function getBuiltObject ( Request $ request , FormFactoryInterface $ formFactory , CreateForm $ annotation , string $ parameterClass , AbstractType $ type ) { /**
         * Checks if parameter typehinting is AbstractType
         * In this case, form type as defined method parameter.
         */ if ( AbstractType :: class == $ parameterClass ) { return $ type ; } $ entity = $ request -> attributes -> get ( $ annotation -> getEntity ( ) ) ; /**
         * Creates form object from type.
         */ $ form = $ formFactory -> create ( get_class ( $ type ) , $ entity ) ; /**
         * Handling request if needed.
         */ if ( $ annotation -> getHandleRequest ( ) ) { $ form -> handleRequest ( $ request ) ; if ( $ annotation -> getValidate ( ) ) { $ request -> attributes -> set ( $ annotation -> getValidate ( ) , ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) ) ; } } /**
         * Checks if parameter typehinting is Form
         * In this case, inject form as defined method parameter.
         */ if ( in_array ( $ parameterClass , [ Form :: class , FormInterface :: class , ] ) ) { return $ form ; } /**
         * Checks if parameter typehinting is FormView
         * In this case, inject form's view as defined method parameter.
         */ if ( FormView :: class == $ parameterClass ) { return $ form -> createView ( ) ; } }
Built and return desired object.

@param Request              $request
@param FormFactoryInterface $formFactory
@param CreateForm           $annotation
@param string               $parameterClass
@param AbstractType         $type

@return mixed
Built and return desired object .