phpstan/phpstan-shim

This package should not replace nikic/php-parser

romainneutron opened this issue · 7 comments

Once I require phpstan/phpstan-shim in my project, I can not require nikic/php-parser since it declares it replaces it.
phpstan-shim should not replace nikic/php-parser.

I'm using phpstan-shim to avoid conflicts with my project dependencies, isn't it supposed to be used in this case?

I've read the README file about this

For technical reasons, if your project depends on nikic/php-parser package, make sure you have the PHAR PHP extension enabled, otherwise the composer autoloader will not work as expected.

here's my configuration:

php --ri phar

Phar

Phar: PHP Archive support => enabled
Phar EXT version => 2.0.2
Phar API version => 1.1.1
SVN revision => $Id: f1155e62742ca367e521a3e412667d8ee34eead9 $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => enabled
Native OpenSSL support => enabled


Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.readonly => On => On
phar.require_hash => On => On
phar.cache_list => no value => no value

Hi, it should just work thanks to this file: https://github.com/phpstan/phpstan-shim/blob/master/bootstrap.php

Can you share a project where it doesn't work?

Given the purpose of the repo

This repository provides easy way to install PHPStan without the risk of conflicting dependencies.

There should be no reason to replace a vendor.
The purpose of this repo is to provide a version of PHPStan that should not conflict with other deps.
I think this is a design issue.

Replacing a vendor at a given version is clearly a dependency conflict.
What happens if I would like to use a custom fork of nikic/php-parser?

Unfortunately it's tightly coupled to nikic/php-parser because the rules and extensions accept various AST nodes from it.

Yes, I understand, but what's preventing from having a standalone phar that packages the php parser at desired version ?

That's exactly what I do here.

Please test the current dev-master. 10caff5