Git Product home page Git Product logo

phpstorm-phpdi's Introduction

PHP-DI plugin for PhpStorm

Version Downloads Downloads last month

Plugin url : https://plugins.jetbrains.com/plugin/7694

This is very simple plugin which only implements type provider for services returned from PHP-DI container.

Strictly speaking current implementation is not dependent on PHP-DI in any way. It just supports certain way of receiving services from container which is widely used in PHP-DI:

<?php
$postRepository = $container->get(PostRepository::class);

So the only thing this plugin does is:

  1. It looks for all get (or make, since v1.2.0) method calls.
  2. It filters out all except those where first argument contains ::class substring.
  3. It extracts class FQN from the first argument and provides it as a return type for that specific method call.

Result:

Example screenshot

Contributors:

License: MIT

phpstorm-phpdi's People

Contributors

haehnchen avatar lattwood avatar pulyaevskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

phpstorm-phpdi's Issues

Add support for more building methods

Currently plugin is looking for only get and make method calls. As every project can have some their own specific building methods, I think that it would be cool to make it possible to configure plugin to listen to those methods.

E.g. there is some field PhpStorm plugin configuration like: Listened methods where user can set his own methods. Let say that by the default, that field will contain value like get; make - once someone would like to add support for his own method, he would just need to add semicolon and new value.

Plugin seems to not working ... ?

Hi, I'm using the plugin for a long time without any problem.
But since few days, It seems to not working anymore...
See the capture below:
Sélection_045

PhpStorm 2018.3.5
Build #PS-183.5912.26, built on March 7, 2019
JRE: 1.8.0_152-release-1343-b28 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-46-generic

Also, I've read a comment on the plugin page that phpStorm support natively. So I disabled the plugin then try to see but nothing changed ...
https://plugins.jetbrains.com/plugin/7694-php-di-plugin#comment=23531

Please migrate to PhpTypePriovider3

PhpTypePriovider2 is deprecated since 2016.3 and will be removed in 2017.3

Migration is pretty straightforward, but I can provide assistance if required.

Only provides type information for 1 depth

This plugin does indeed treat the returned value as an instance of the class referenced class within get(), however if on that value I call a method to return an object, then PHPStorm doesn't know what type that value is, and the method call is marked yellow.

E.g.

PHPStorm gives perfect type information in this case:

        /**
         * @var ActorInterface $actor
         */
        $actor = $this->getServiceLocator()->get(ActorInterface::class);
        return $actor->getUser()->getCompany();

However in this case without the docblock:

        $actor = $this->getServiceLocator()->get(ActorInterface::class);
        return $actor->getUser()->getCompany();

Expected: all type information works
Actual: the getCompany() bit is marked yellow

Not working on my PhpStorm

Hi!
It is not working on my PhpStorm... I invalidated the cache but the problem still here.

capture d ecran_2017-12-21_15-43-11

PhpStorm 2017.3.1
Build #PS-173.3942.32, built on December 12, 2017
JRE: 1.8.0_152-release-1024-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-21-generic

Does not implement PhpTypeProvider2

I could not manage to compile the plugin by my self. I spent some hour to fix, but I got stuck into the following interface implementation problem.

java.lang.Throwable: Extension class com.pulyaevskiy.phpstorm.phpdi.PhpDiTypeProvider does not implement interface com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider2

To me it seems, that the implementation is absolutely sufficient. I don't know, why the compiler is unhappy with it. I usually develop in php and I'm used to write IntelliJ plugins. Sorry for any dumb questions.

Maybe it's my development environment? I'm using the SDK from java-7-openjdk and the php-openapi from phpstorm 8.0.3 on Linux Mint 17.1.

Would be great if you can give me a hand.

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.