PhpStorm - How to escape dollar sign (php variable) in File Template?

Viewed 671

I have a PhpStorm Php file template under Editor > File and Code Templates:

PhpStorm File Template

According to the linked Apache Velocity Docs to escape a dollar sign a back slash should be used:

<?php

declare(strict_types=1);
#parse("PHP File Header.php")
#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

class ${NAME} implements DataTransformerInterface
{
    public function __construct()
    {}

    public function transform(\$value)
    {
        return ;
    }
}

But when I select the template when creating a class, the backslash stays:

Use Template

File output:

<?php

declare(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 ;
    }
}

It works when i directly select the template and not create class, but then the namespace is not taken automatically...

So how do i escape the dollar sign properly? Is that a known bug?

1 Answers
Related