Skip to content

TemplateAnnotationRector removes annotation without modifying return statement when delegating to another method #2216

@stedekay

Description

@stedekay

Question

Like mentioned in #2215 the TemplateAnnotationRector removes the Template annotation when the the controller uses as private method in its return statement, but the private method still returns an array at the end:

    /**
     * @Route("/create", name="survey_create")
     * @Template("PAPPSurveyBundle:Survey:create.html.twig")
     *
     * @return array
     */
    public function createAction(Request $request, Party $currentParty)
    {
        $survey = $this->surveyHelper->createSurvey($currentParty);

        return $this->processForm($request, $currentParty, $survey, $this->generateUrl('survey_save'));
    }

    private function processForm(Request $request, Party $party, Survey $survey, $url)
    {
        ...

        return [
            'form' => $form->createView(),
        ];
    }

When I would fix this manually I would put the render Method into the private method. Is this something rector can handle or should this be fixed manually?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions