簡體   English   中英

位置1附近的值“”的異常標記“表達式結尾”

[英]Unexpected token “end of expression” of value “” around position 1

我以前從未遇到過這種錯誤,而且我也不知道要搜索什么以及從哪里開始。

我使用Symfony 3在CRUD中創建了一個函數,當我到達該路由時,出現以下錯誤(及其跟蹤):

位置1附近的值“”的意外標記“表達式結尾”。500內部服務器錯誤-SyntaxError

    } elseif ($token->test(Token::PUNCTUATION_TYPE, '{')) {
        $node = $this->parseHashExpression();
    } else {
        throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $token->type, $token->value), $token->cursor);
    }
}

因此,我認為這是一個括號問題,但是PHPStorms計數了19個打開和關閉括號(這些“ {”)和112個打開和關閉括號。

我真的不知道該向您展示什么,因此這里是我在收到錯誤之前添加的功能的全部內容:

公共職能

/**
     * @Route("/{id}/encours", name="mission_encours")
     * @Security has_role('ROLE_RECRUTEUR')
     * @Method("POST")
     */
    public function enCoursAction(Request $request, Mission $mission){
        $form = $this->missionInProgress($mission);
        $form->handleRequest($request);

        if($form->isSubmitted() && $form->isValid()){
            $em = $this->getDoctrine()->getManager();
            $mission->setStatut("En cours");
            $em->persist($mission);
            $em->flush();
        }
        return $this->redirectToRoute('mission_index');
    }

私人功能

/**
     * @param Mission $mission
     * @Security has_role('ROLE_RECRUTEUR')
     * @return \Symfony\Component\Form\Form The form
     */
    private function missionInProgress(Mission $mission){
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('mission_encours', array('id' => $mission->getId())))
            ->setMethod('POST')
            ->getForm()
        ;
    }

這些功能的目標是通過單擊CRUD的“顯示”視圖內的提交按鈕來更改任務的狀態。 用戶被重定向,狀態更改,然后用戶返回任務列表。

即使,我也不知道可能出什么問題,我使用PHPStorm並沒有告訴我關於缺少括號的信息。

有沒有人遇到過這個問題,並且知道如何解決?

提前致謝

在安全注釋中缺少景點(“”)。

@Security has_role('ROLE_RECRUTEUR')


@security( “has_role( 'ROLE_RECRUTEUR')”)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM