Skip to content

PhpNamespace::unresolveName() does not preserve intentional leading backslash #21

@mrtnzlml

Description

@mrtnzlml

Due to this commit (6e1b293) it's not possible to generate namespace with leading backslash. I know it was intended, but unfortunately it can be BC break. For example Kdyby\AOP generates class namespaces with leading backslash, but classes are in custom block namespace and if the leading ** is removed, it generates nonsense:

namespace Kdyby\Aop_CG\Container_1ad39c5e84 {

use Kdyby\Aop\Pointcut\Matcher\Criteria;
use Symfony\Component\PropertyAccess\PropertyAccess;

final class Model_PagesClass_85_Model_Pages extends Model\Pages
{
    // ...                                          ^- should be \Model\Pages

It would be great to preserve leading ** (example why). Should I prepare PR or it's completely wrong approach and should it be fixed in Kdyby?

Suggested behavior (PhpNamespace.phpt:13):

$namespace = new PhpNamespace;

Assert::same('\A', $namespace->unresolveName('\A')); //preserve leading backslash
Assert::same('A', $namespace->unresolveName('A'));
Assert::same('foo\A', $namespace->unresolveName('foo\A'));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions