Git Product home page Git Product logo

Comments (10)

Snake231088 avatar Snake231088 commented on May 20, 2024 6

Two ideas from IntelliJ that you might consider:

  • highlighting unused variables
  • highlighting undeclared variables

from vscode-intelephense.

bmewburn avatar bmewburn commented on May 20, 2024 3

1.3 will add deprecated, undefined classes and methods/functions, stricter type checking for nullable and union types. Further diagnostics will be added in future releases.

from vscode-intelephense.

bmewburn avatar bmewburn commented on May 20, 2024 1

@mindplay-dk, correct. The syntax tree representation will be largely the same but I think it needs a transform applied to make accessing FQN and type info simpler.

from vscode-intelephense.

Thijzer avatar Thijzer commented on May 20, 2024 1

Give me a sign if you need Guinea pig.

I'm a php developer on Arch Linux, most of my projects are Symfony based OO heavy, so a good working IDE is very important to me but I don't like to really to heavily on one tool "PhpStorm". I'm sure I can help if you can orchestrate something.

from vscode-intelephense.

JapSeyz avatar JapSeyz commented on May 20, 2024

Is there anything we can do to help out?

from vscode-intelephense.

bmewburn avatar bmewburn commented on May 20, 2024

@JapSeyz thanks for the offer! You're welcome to create a PR for this or any other issue. I have been meaning to put together a contributing guideline with an overview on how it works. The diagnostics provider is pretty simple right now. It just traverses over the parse tree and creates diagnostics from the parse error nodes in the tree.

There is also 2 derived trees - a symbol (definitions) tree and a references tree. For unused variables and parameters a simple rule might even be that if there is only a single reference to a variable or parameter in a given scope then it is either unused or undefined (a reference is created for the definition/declaration too). I haven't given much thought to how this could all be structured in the diagnostics provider.

from vscode-intelephense.

MichalSchwarz avatar MichalSchwarz commented on May 20, 2024

Hi Guys . Do you think that implement it from scratch is the best solution? I see a insane lot of work ahead... What about find and use some existing static analysis tool? Is possible to connect some tool written eg. in PHP?

from vscode-intelephense.

bmewburn avatar bmewburn commented on May 20, 2024

@MichalSchwarz, you're right it is a lot of work and there are probably other tools out there. The benefit of implementing from scratch is that the syntax tree can be reused. A separate lib would come with it's own parser etc which means more resources needed.

from vscode-intelephense.

mindplay-dk avatar mindplay-dk commented on May 20, 2024

FWIW, most of the actual inspections in existing static analysis tools are not that complex - typically the framework is the complex part.

@bmewburn in #60:

I haven't done much work on this as I'm considering moving to a representation of the syntax tree that is easier to work with (ast instead of parse tree), plus there are improvements to the type inference to be made in cases where phpdoc and type hints are not available for function return type

I know just enough parser theory to break everything, so I think I'll stay away from this one.

I would like to help with the actual inspections, but if you're planning to change the code representation, it's probably premature to start working on those?

from vscode-intelephense.

altwohill avatar altwohill commented on May 20, 2024

Hi, I see that unused variables are listed as such when hovering over them, but there's nothing drawing me to it (no error shows for the line).
image

Is this on the roadmap for this ticket or should I create a new one?

from vscode-intelephense.

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.