Comments (11)
FWIW I'd love to find a way to make this work. But Drupal.org is going to be using this on DrupalCI, so I want to be careful in any decisions.
from phpstan-drupal.
The includes are relative to the current directory they are in, not the tool. It makes sense but is kind of confusing. So you would need something like
../../.. I think
from phpstan-drupal.
Interesting. But this would not work in a continous integration service where there is no drupal installation around.
from phpstan-drupal.
Correct, it needs Drupal around. Otherwise it couldn't load the classes you're working with to analyze your codes usage. Like incorrect parameters or deprecated code
from phpstan-drupal.
Drupal core can very well be loaded as a dev dependency of a module. I'm using autoload-drupal for this.
There is no actual Drupal instance running, but I get a pretty good result with phpstan this way.
from phpstan-drupal.
I can already see some shortages in that package compared to the full autoloading required. Honestly I don't want to force adding something like that which would create bugs while Drupal is still generating namespaces. It's already stuck with it's quirks, that seems like it'd add more grief, possibly.
I do want to explore this and see what we can do. Honestly that package and something which swaps Drupal kernel would work. There's a lot of small things.
from phpstan-drupal.
@CaptainQuirk okay, with #46 and #53 I have added a drupal_root
parameter which lets you specify the Drupal root in the .neon file, and should solve some of these problems. Can you try using this to point to Drupal and fix autoloading? Hopefully, it's a decent fix for now.
from phpstan-drupal.
Hi !
Thanks for that ! I'll have a look as soon as I can
from phpstan-drupal.
@CaptainQuirk you can have a look at the Nagios Monitoring module: it has PHPStan coverage for the Drupal 7 and 8 branches.
from phpstan-drupal.
This should work now with the drupal.drupal_root
parameter. You must have Drupal somewhere for this to work. Because your module will be interacting with its codebase.
parameters:
drupal:
drupal_root: /path/to/drupal
from phpstan-drupal.
You can also run PHPStan on DrupalCI following these instructions: https://www.drupal.org/docs/9/how-to-prepare-your-drupal-7-or-8-site-for-drupal-9/deprecation-checking-and-correction-tools#s-drupalorg-testing-support-for-deprecation-checking
There is a DrupalCI build step tool, however it only does deprecation testing: https://git.drupalcode.org/project/drupalci_testbot/blob/dev/src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseValidate/Phpstan.php
I'm going to close this as the original issue was about having phpstan.neon in the root of the module, not Drupal. And this is now capable by defining the path to Drupal.
Although, I don't know if the module would be discoverable properly if it is not within the Drupal codebase. For isntance, services mapping.
from phpstan-drupal.
Related Issues (20)
- Detect storage handlers injection and storage instantiation in constructors
- «Undefined array key» when using autowiring with decorator
- Make ^10.0 the default constraint for Drupal core, update from ^9.0
- Move data samples out of phpstan_fixtures and into test data files
- Add PHP 8.3 tests
- Form should not have private properties HOT 2
- Simplify defining test namespaces HOT 1
- Have AccessResult forbiddenIf and allowedIf perform truthy checks HOT 5
- LockBackendInterface::acquire() is impure HOT 2
- ModuleHandler->loadInclude() call is not being processed HOT 2
- Update `bleedingEdge.neon` to include new rules
- Support turning off @internal check
- New accessibility requirement requires title attributes for most form elements.
- Validate FormBuilderInterface::getForm() arguments by inspecting form class HOT 1
- New rule for checking "static create()" method in controller
- Register dynamic services from DrupalKernel::attachSynthetic
- Determine return value from `\Drupal\Core\Config\Config::get` HOT 1
- Warn about max-age less then 10
- Fatal error: Uncaught TypeError: is_link(): Argument #1 ($filename) must be of type string, Drush\Config\Environment given in /tmp/site/vendor/webflo/drupal-finder/src/DrupalFinder.php:153 HOT 14
- Stop testing PHP 7.4, 8.0 and Drupal 9 HOT 4
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-drupal.