Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR-0 dependencies are not correctly prefixed #127

Closed
maks-rafalko opened this issue Nov 9, 2017 · 4 comments
Closed

PSR-0 dependencies are not correctly prefixed #127

maks-rafalko opened this issue Nov 9, 2017 · 4 comments
Assignees
Milestone

Comments

@maks-rafalko
Copy link

maks-rafalko commented Nov 9, 2017

Question Answer
PHP-Scoper version master 1ca326d
PHP version 7.1.4
Composer version 1.5.2 2017-09-11 16:59:25
Github Repo https://github.com/borNfreee/php-scoper-bug

I'm trying to prefix Infection application but faced an issue with PSR-0 dependency which is not correctly resolved.

I've created a github repo with reproducible issue - just a very small application with only 1 dependency - Pimple container which uses PSR-0 in its composer.json.

How to reproduce:

git clone https://github.com/borNfreee/php-scoper-bug
cd php-scoper-bug

composer install

# check it works
php src/main.php // prints "Hello"

# run PHP-Scoper
php-scoper add-prefix --output-dir=build-prefixed --force --prefix=Mutant

composer dump-autoload --working-dir=build-prefixed/ --classmap-authoritative --no-dev

# Then try to run prefixed application:
cd build-prefixed

php src/main.php

This throws an error:

PHP Fatal error:  Uncaught Error: Class 'Mutant\Pimple\Container' not found in php-scoper-bug/build-prefixed/src/Application.php:10
Stack trace: ...

Please note that composer create autoload_static.php with the following content for PSR-0 dependencies:

public static $prefixesPsr0 = array (
        'P' => 
        array (
            'Pimple' =>  // <------- this is not prefixed
            array (
                0 => __DIR__ . '/..' . '/pimple/pimple/src',
            ),
        ),
    );

while PSR-4 dependencies are prefixed:

public static $prefixDirsPsr4 = array (
        'Mutant\\ScoperBug\\' => 
        array (
            0 => __DIR__ . '/../..' . '/src',
        ),
        'Mutant\\Psr\\Container\\' => 
        array (
            0 => __DIR__ . '/..' . '/psr/container/src',
        ),
    );

Did I miss something?

Hope this helps!

@theofidry
Copy link
Member

Indeed, looks like I completely forgot about PSR-0 there

@theofidry theofidry added this to the 1.0.0 milestone Nov 10, 2017
@theofidry theofidry self-assigned this Nov 10, 2017
@rayrutjes
Copy link

Is there a quick hack for this?

@theofidry
Copy link
Member

I don't know what the fix exactly is because I couldn't check it yet. You have a link to the problematic code in my previous comment and the related test here so it should be relatively simple to do.

@BackEndTea BackEndTea mentioned this issue Jan 16, 2018
1 task
@theofidry
Copy link
Member

Closed via #142

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

No branches or pull requests

3 participants