Comments (10)
Two ideas from IntelliJ that you might consider:
- highlighting unused variables
- highlighting undeclared variables
from vscode-intelephense.
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.
@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.
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.
Is there anything we can do to help out?
from vscode-intelephense.
@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.
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.
@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.
FWIW, most of the actual inspections in existing static analysis tools are not that complex - typically the framework is the complex part.
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.
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).
Is this on the roadmap for this ticket or should I create a new one?
from vscode-intelephense.
Related Issues (20)
- Intelephense indicates PHP SSH2 functions and constant undefined HOT 1
- `autoload-dev` seems to be ignored when renaming namespaces
- Recognizing defined constants for being objects has still an another bug
- erroneous expect type 'string' found 'void' HOT 2
- Constant marked "Undefined" in if-clause which checks if constant is defined. HOT 1
- Navigate to classes from yaml files
- Wrong type on dynamic object with string|null
- Enhance type recognition for values in SplDoublyLinkedList
- assert diagnostics
- Syntax error with dynamic enum access in PHP 8.3
- Unexpected P1010 Undefined function error for oci_set_prefetch_lob
- Process Itelephense filters on folders
- Autocomplete functions and attributes of variables in debug console
- Invalid Namespace definition
- I can't go to the method definition HOT 2
- PHP open and close brackets always seem to be misaligned when with HTML HOT 1
- Undefined method 'createToken'. P1013 HOT 1
- Add references HOT 1
- Laravel No definition found for .... HOT 1
- intelephense indexing take too long time HOT 2
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 vscode-intelephense.