Skip to content

Namespaces with escaped backslashes in strings are not replaced #129

@deviationist

Description

@deviationist

Hello Coen! First of all, great work and thanks for making this tool. Helped me a lot, super easy to use!

I learned something when implementing it in my project. Not sure if I should call it a bug, but I wanted to share it with you regardless. When namespaces are specified in strings then it seems like Mozart is only able to prefix namespaces where the backslash is not escaped. See the example below.

Before namespace prefixing:

$baseNamespace = "\Example\Sdk\Endpoints";
$baseNamespace = "Example\\Sdk\\Endpoints";
$baseNamespace = "Example\Sdk\Endpoints";

$baseNamespace = '\\Example\\Sdk\\Endpoints';
$baseNamespace = '\Example\Sdk\Endpoints';
$baseNamespace = 'Example\\Sdk\\Endpoints';
$baseNamespace = 'Example\Sdk\Endpoints';

After namespace prefixing:

$baseNamespace = "\My\Dependencies\Example\Sdk\Endpoints";
$baseNamespace = "Example\\Sdk\\Endpoints";
baseNamespace = "My\Dependencies\Example\Sdk\Endpoints";

$baseNamespace = '\\Example\\Sdk\\Endpoints';
$baseNamespace = '\My\Dependencies\Example\Sdk\Endpoints';
$baseNamespace = 'Example\\Sdk\\Endpoints';
$baseNamespace = 'My\Dependencies\Example\Sdk\Endpoints';

Initially I thought this was related to the use of single- or double-quotes, but it only seems to be an issue when using escaped backslashes in the namespace string. Probably not the biggest issue, but it would probably be nice to also support escaped backslashes IMO.

Kind regards,
Robert Sæther

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions