phpstan / extension-installer

Composer plugin for automatic installation of PHPStan extensions.
MIT License
399 stars 27 forks source link

Use relative directories for packages when building GeneratedConfig #23

Closed cjunge-work closed 3 years ago

cjunge-work commented 4 years ago

Build the GeneratedConfig file using relative paths so PHPStan can be run inside/outside containers/CI, etc.

Fixes #17

cjunge-work commented 4 years ago

@ondrejmirtes any chance this could be merged?

arnaudgoulpeau commented 4 years ago

Hi, we work with Docker and the composer image. We have the same problem and any though on this PR would be greatly appreciated. Even if it is a big no. By the way, thanks for all the great stuff here !

ondrejmirtes commented 4 years ago

Hi, I'm not sure about the implications of this, it would need a lot of testing. We'd first need an extensive test suite that would allow us testing this on Linux/Windows using GitHub Actions making sure we didn't break anything.

ondrejmirtes commented 4 years ago

When looking at the implementation, I already know that this is wrong:

        $vendorPos = strpos(__DIR__, 'vendor');
        if ($vendorPos === false) {
            return;
        }

Composer users can change their vendor-dir using configuration: https://getcomposer.org/doc/06-config.md#vendor-dir

ondrejmirtes commented 4 years ago

I stand by my comment from #17:

I'm fine if this utility isn't usable by everyone. It can afford to only solve the happy path for its users. The only thing it does is to save typing a few lines in your phpstan.neon.

ondrejmirtes commented 3 years ago

I plan to tackle this myself, thank you.

ondrejmirtes commented 3 years ago

This was all that was needed: https://github.com/phpstan/extension-installer/commit/66c7adc9dfa38b6b5838a9fb728b68a7d8348051 + https://github.com/phpstan/phpstan-src/commit/0e306c66ca4c6f31184e222ce5df04a17b4307ca