Skip to content
This repository has been archived by the owner on Feb 14, 2021. It is now read-only.

Symfony2Extension doesn't like namespaces containing Spec #5

Open
brunoroux opened this issue Jan 15, 2014 · 4 comments
Open

Symfony2Extension doesn't like namespaces containing Spec #5

brunoroux opened this issue Jan 15, 2014 · 4 comments

Comments

@brunoroux
Copy link

I tried using the specification pattern on some doctrine repository.

I ended up doing something like this :

bin/phpspec desc GMP/CommonMonetisationBundle/Entity/Specification/FilterOffreActif

which gave me :

Specification for GMP\CommonMonetisationBundle\Entity\ification\FilterOffreActif created in /data/www/desire/src/GMP/CommonMonetisationBundle/Spec/Entity/ification/FilterOffreActifSpec.php.

Seems like Spec acts like a reserved keyword and strips itself from any namespace.

@jakzal
Copy link
Member

jakzal commented Jan 15, 2014

@brunoroux good catch. There's probably a aproblem with one of the regexps.

@brunoroux
Copy link
Author

I think I found it :

in Locator/PSR0Locator.php :

    /**
     * @param string $classname
     *
     * @return PSR0Resource|null
     */
    public function createResource($classname)
    {
        $classname = str_replace('/', '\\', $classname);
        $classname = str_replace(array($this->specSubNamespace, 'Spec'), '', $classname);
        $classname = str_replace('\\\\', '\\', $classname);

        if ('' === $this->srcNamespace || 0 === strpos($classname, $this->srcNamespace)) {
            return $this->resourceFactory->create(explode('\\', $classname), $this->specSubNamespace, $this->srcPath);
        }

        return null;
    }

It seems the $classname = str_replace(array($this->specSubNamespace, 'Spec'), '', $classname); is the one messing the namespace

brunoroux pushed a commit to brunoroux/Symfony2Extension that referenced this issue Jan 16, 2014
@ghost
Copy link

ghost commented Jul 26, 2014

@brunoroux : are you gonna submit this as a PR?

@ghost
Copy link

ghost commented Jul 26, 2014

@brunoroux : sorry about that. i didn't see a reference to #6 in this, so i didn't think there was one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants