Comments (12)
Thanks to everyone who tested it, seems it works. After 0.9 is out, I plan to automate this, having phpstan-shim dev-master built after every successful Travis build of the main repo + testing in the build whether it still works.
from phpstan-shim.
Extensions are an open problem right now, we've talked about this with @ondrejmirtes already.
The phar has to include all the extensions (at least the official ones), to make sure they refer to the prefixed classes. But only the extensions - the extra dependencies, they should be part of your project already.
My compiler already handles this case, but Ondra released it without it for now - the 0.7 was a big release already as is.
from phpstan-shim.
I have good news! I just pushed a freshly compiled PHAR that should support installing along the extensions! So feel free to try it out: 5f02c1f
How I verified that it works:
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"phpstan/phpstan-shim":"^0.9",
"phpstan/phpstan-phpunit":"^0.9"
}
}
results in this install log (I excluded PHPUnit dependencies):
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 30 installs, 0 updates, 0 removals
- Installing phpunit/phpunit (6.4.4): Loading from cache
- Installing phpstan/phpstan-shim (dev-master 5f02c1f): Cloning 5f02c1fa2f from cache
- Installing phpstan/phpstan-phpunit (dev-master 87f1be6): Cloning 87f1be64dc from cache
So no phpstan
dependencies are installed directly because of the extension, because they are already met thanks to phpstan-shim
and the replace
key in its composer.json.
With this phpstan.neon:
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
parameters:
autoload_files:
- test.php
And this test.php
:
<?php
class TestCase extends \PHPUnit\Framework\TestCase
{
public function testFoo()
{
$mock = $this->createMock(Foo::class);
$mock->doFoo();
}
}
class Foo
{
}
Running:
vendor/bin/phpstan.phar analyse test.php -c phpstan.neon -l 7
Results in:
------ -----------------------------------------------------------------------------------
Line test.php
------ -----------------------------------------------------------------------------------
9 Call to an undefined method Foo&PHPUnit_Framework_MockObject_MockObject::doFoo().
------ -----------------------------------------------------------------------------------
As you can see, the type Foo&PHPUnit_Framework_MockObject_MockObject
means that the PHPUnit extension is installed and registered correctly!
I urge everyone in this conversation to test out latest phpstan-shim
dev-master whether it works for their use cases as well!
from phpstan-shim.
realated: fprochazka/phpstan-compiler#1
from phpstan-shim.
@jiripudil Actually I think composer require phpstan/phpstan-shim phpstan/phpstan-nette
can't work in any case simply because phpstan-shim
only contains a phpstan.phar
archive and when you use it (vendor/bin/phpstan.phar ...
) you don't load vendor/autoload.php
at all.
Also @fprochazka I tried to compile PHPStan with the extensions, but how do I activate them? I can't reference a vendor/phpstan/phpstan-nette/extension.neon
which is in a PHAR archive, right?
from phpstan-shim.
@JanJakes this is needed: nette/di#153
from phpstan-shim.
from phpstan-shim.
I can't reference a vendor/phpstan/phpstan-nette/extension.neon which is in a PHAR archive, right?
You can! Read the readme for 0.6.x
: https://github.com/phpstan/phpstan-shim/tree/0.6.x#extensions
from phpstan-shim.
I replaced the provide
section with replace
and the result is much better. Although, the current problem with installing PHAR along the extensions is that the Dynamic*ReturnTypeExtension
interface contains references to PhpParser
nodes which are prefixed in the PHAR, rendering implementations incompatible with the interface.
I will probably try to turn off prefixing the PhpParser
library which should help and the extensions should become usable.
from phpstan-shim.
FYI, the original compiler was meant to compile the PHAR with the extensions so you would only enable them, no additional installing.
from phpstan-shim.
from phpstan-shim.
I've tried it with phpstan-nette
and seems working. Only phpstan-shim
gets installed. Thanks!
from phpstan-shim.
Related Issues (20)
- PHPstan conf directory HOT 1
- Global install is not working HOT 9
- On windows: "'bash' is not recognized as an internal or external command," HOT 3
- RootDir phar:// prefix HOT 2
- %rootDir% users phar:// prefix HOT 7
- Conflict with php-di HOT 10
- nikic/php-parser dependency HOT 3
- Problem with nikic/php-parser replaced dependency HOT 4
- Extensions cannot be included, in a portable way, when using global install HOT 3
- sensiolabs-de/deptrac-shim HOT 1
- Bad perf impact for the bootstrap.php file HOT 9
- Plans for bleedingEdge HOT 1
- This package should not replace nikic/php-parser HOT 7
- Cannot uninstall in projects depending on nikic/php-parser HOT 1
- bootstrap.php prevents autoloading of certain files from shared dependencies with project HOT 4
- Bug in relative path for phar file HOT 8
- Level in configuration file is not taken into account HOT 2
- The replacement rule for nikic/php-parser should be an exact version based on what is inside the phar HOT 9
- 0.8.5 release HOT 3
- Sign phar file in separate file HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpstan-shim.