我在Editor > File and Code Templates下有一個 PhpStorm Php 文件模板:根據(jù)鏈接的 Apache Velocity Docs轉(zhuǎn)義美元符號,應(yīng)使用反斜杠:<?phpdeclare(strict_types=1);#parse("PHP File Header.php")#if (${NAMESPACE})namespace ${NAMESPACE};#enduse Symfony\Component\Form\DataTransformerInterface;use Symfony\Component\Form\Exception\TransformationFailedException;class ${NAME} implements DataTransformerInterface{ public function __construct() {} public function transform(\$value) { return ; }}但是當(dāng)我在創(chuàng)建類時選擇模板時,反斜杠保持不變:文件輸出:<?phpdeclare(strict_types=1);namespace SomeProject\SomeBundle\Form\DataTransformer;use Symfony\Component\Form\DataTransformerInterface;use Symfony\Component\Form\Exception\TransformationFailedException;class TestTransformer implements DataTransformerInterface{ public function __construct() {} public function transform(\$value) { return ; } public function reverseTransform() { return ; }}當(dāng)我直接選擇模板而不是創(chuàng)建類時它會起作用,但是名稱空間不會自動獲取...那么我該如何正確地轉(zhuǎn)義美元符號呢?那是一個已知的錯誤嗎?
1 回答

藍山帝景
TA貢獻1843條經(jīng)驗 獲得超7個贊
${DS}
根據(jù) PhpStorm 幫助頁面(下面的鏈接),如果您需要$
在文件模板輸出中包含(美元符號),最好的方法是使用預(yù)定義變量。
https://www.jetbrains.com/help/phpstorm/file-template-variables.html
- 1 回答
- 0 關(guān)注
- 162 瀏覽
添加回答
舉報
0/150
提交
取消