Closed flangofas closed 4 years ago
Confirmed here too
The stubs here are really simple, not sure what causes this. I'm gonna investigate.
Unfortunately I'm not able to reproduce this. It runs fine. Running vendor/bin/phpstan analyse -c phpstan-with-extension.neon
in this repo works so I'm not sure what else should I try. If you could pinpoint how the analysed source code where PHPStan crashes looks like, it'd be great.
+1
This doesn't help me reproduce it. I need some minimal code on which it crashes like this. Thanks.
@ondrejmirtes I liked the issue in our repo for you to look. You can easily clone that branch to reproduce.
@ondrejmirtes i haven't tracked this down yet but i'm getting there. the phpstan container is being build incorrectly?
public function createServiceStubPhpDocProvider(): PHPStan\PhpDoc\StubPhpDocProvider
{
return new PHPStan\PhpDoc\StubPhpDocProvider(
$this->getService('043'),
$this->getService('083'),
[
'/Users/ben/Code/phpstan/phpstan-src/stubs/ReflectionClass.stub',
'/Users/ben/Code/phpstan/phpstan-src/stubs/iterable.stub',
'/Users/ben/Code/phpstan/phpstan-src/stubs/ArrayObject.stub',
'/Users/ben/Code/phpstan/phpstan-src/stubs/WeakReference.stub',
'/Users/ben/Code/phpstan/phpstan-src/stubs/ext-ds.stub',
'/Users/ben/Code/phpstan/phpstan-src/stubs/PDOStatement.stub',
'/Users/ben/Code/abacus-webapp/vendor/jangregor/phpstan-prophecy/src/stubs/ObjectProphecy.phpstub',
'/Users/ben/Code/abacus-webapp/vendor/jangregor/phpstan-prophecy/src/stubs/ProphecyInterface.phpstub',
]
);
}
/Users/ben/Code/abacus-webapp/vendor/jangregor/phpstan-prophecy/src/stubs/ObjectProphecy.phpstub
should be
/Users/ben/Code/abacus-webapp/vendor/jangregor/phpstan-prophecy/stubs/ObjectProphecy.phpstub
got it. Relative paths in the stubFiles key are resolved based on the directory of the config file is in.
This repo contains https://github.com/Jan0707/phpstan-prophecy/blob/master/extension.neon and then a symlink https://github.com/Jan0707/phpstan-prophecy/blob/master/src/extension.neon for BC with 0.6.2.
If you load the symlink, i.e.
includes:
- %currentWorkingDirectory%/vendor/jangregor/phpstan-prophecy/src/extension.neon
the relative path resolution to the stubs doesn't work.
Either phpstan could resolve symlinks or...??
If you’re running phpstan-src and not phpstan/phpstan distribution then nothing is guaranteed to work (phpstan-src is just for PHPStan development itself) but I still don’t see how this could break.
It’d be great if someone created a small reproducing repo (with phpstan/phpstan as Composer dependency) so I can debug it.
@bendavies @ondrejmirtes
I will remove the symbolic link in the next release, if that helps!
That, or this line: https://github.com/phpstan/phpstan-src/blob/bde25044d1df8154e5e7a5989b39d270115fa7e3/src/DependencyInjection/NeonAdapter.php#L170
needs changing to
$dir = dirname(realpath($file));
@bendavies @flangofas @ondrejmirtes
I have removed the symbolic link in #182. This will break installations for people who do not use phpstan/extension-installer
, but I think it's best moving forward this way:
phpstan/extension-installer
@ondrejmirtes
Not sure if there are other projects using symbolic links, but I believe we are good in regard to this project now, what do you think?
@localheinz Thank you, symbolic links are generally problematic, IIRC they don't translate well on Windows. (I've wanted the phpstan
file in https://github.com/phpstan/phpstan to be just a symlink to phpstan.phar
but it didn't work.)
People are encouraged to use extension-installer but they can't always do that. For example if they only want to use some of the rules from phpstan-strict-rules, they can't use extension-installer. Since the package is just a convenient way to save a few lines from the configuration file, it's fine.
Anyway, 👍 on the fix, using symlinks in this context is discouraged.
@bendavies Sorry, haven't seen your comment before replying.
Thank you, @ondrejmirtes!
Fixed with #182.
thanks all
thanks for your prompt answers and the quick fix.
You are welcome, @bendavies and @flangofas!
Hey guys,
The following setup breaks PHPStan while the previous release (0.6.2) worked just fine.
PHP: 7.4 PHPStan: 0.12.23 PHPStan-Prophecy: 0.7 Relates to: https://github.com/slimphp/Slim-Skeleton/pull/163
Expected: [OK] No errors
Output: In StubPhpDocProvider.php line 150:
[PHPStan\ShouldNotHappenException] Internal error.
Exception trace: