Giter Club home page Giter Club logo

Comments (11)

mglaman avatar mglaman commented on May 25, 2024 1

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.

mglaman avatar mglaman commented on May 25, 2024

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.

CaptainQuirk avatar CaptainQuirk commented on May 25, 2024

Interesting. But this would not work in a continous integration service where there is no drupal installation around.

from phpstan-drupal.

mglaman avatar mglaman commented on May 25, 2024

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.

CaptainQuirk avatar CaptainQuirk commented on May 25, 2024

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.

mglaman avatar mglaman commented on May 25, 2024

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.

mglaman avatar mglaman commented on May 25, 2024

@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.

CaptainQuirk avatar CaptainQuirk commented on May 25, 2024

Hi !

Thanks for that ! I'll have a look as soon as I can

from phpstan-drupal.

gogowitsch avatar gogowitsch commented on May 25, 2024

@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.

mglaman avatar mglaman commented on May 25, 2024

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.

mglaman avatar mglaman commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.