GithubHelp home page GithubHelp logo

Improve the extension about phpstan-drupal HOT 11 CLOSED

mglaman avatar mglaman commented on August 24, 2024
Improve the extension

from phpstan-drupal.

Comments (11)

mglaman avatar mglaman commented on August 24, 2024 1

:) Yeah. I'm going to get creative with it. The main thing is providing dynamic return types for services. Which requires knowing where Drupal is so extensions can be discovered. Not a hard problem. Just picking the less hacky option out of the choices

from phpstan-drupal.

mglaman avatar mglaman commented on August 24, 2024

CompilerExtension - will PHPStan provide any way to integration with the container? Otherwise the bootstrap or autoload files have no way of interacting with PHPStan -- even if the current setup is a hack.

Global variables -- I'm looking to move from those and should have used %currentWorkingDirectory%, but "it worked" when first starting :)

from phpstan-drupal.

ondrejmirtes avatar ondrejmirtes commented on August 24, 2024

What exactly are you doing in the CompilerExtension? If you just need to run some code, you can create a file and put it to autoload_files in extension.neon.

from phpstan-drupal.

mglaman avatar mglaman commented on August 24, 2024

Drupal doesn't have all of its classes dumped to the autoloader. We need to find the Drupal root and then do namespace processing. For this I need to know the current working directory, and autoload_files nor bootstrap have access to the container to know those params without globals.

Basically the extension, right now, uses that info and pumps data into globals for use later.

from phpstan-drupal.

ondrejmirtes avatar ondrejmirtes commented on August 24, 2024

I see :) I'll try to come up with a solution.

from phpstan-drupal.

mglaman avatar mglaman commented on August 24, 2024

I'll see what I can do, as well. Now that I have PHPUnit tests it's a lot less... magical of an integration.

from phpstan-drupal.

ondrejmirtes avatar ondrejmirtes commented on August 24, 2024

Hi, this should help you to move the logic into autoload_files:

phpstan/phpstan@4824bba

(You should not override bootstrap, that's for the root project that uses PHPStan.)

from phpstan-drupal.

ondrejmirtes avatar ondrejmirtes commented on August 24, 2024

I just released 0.11.6 with this change, so you can change your code and start requiring this version :)

from phpstan-drupal.

mglaman avatar mglaman commented on August 24, 2024

This helped remove some of the magical globals.

However, it cannot be fully used. Parameters need to be added to the container for service detection. Opened an initial branch and experimenting.

from phpstan-drupal.

ondrejmirtes avatar ondrejmirtes commented on August 24, 2024

from phpstan-drupal.

mglaman avatar mglaman commented on August 24, 2024

0.12 forced the fixes :)

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.