1

Do you know a VSCode extension for PHP that would highlight variable that I'd access in read but that were never initialized?

It would be useful for example in this scenario: I write a function A, then I find it too long so I take a portion of A and I move this portion inside a new function B that is called within A. The extension would be useful to be sure that B doesn't contain variables access in read that were declared in A.

1 Answer 1

1

php intelephense does this.
I have the Premium variant installed. I've purchased it a few years ago; don't know if reg-status follows along when I sync VSCode settings over many computers.
So I don't know precisely what the free version does.

If you defined temporary variables in the body of a class method, intelephense will do this (see comments):

public function indexAction() { $test1; // intelephense will highlightt in red as error: Undefined Variable '$test' $test2 = null; // intelephense will grey this out for($i = 0; $i < 4; $i++) { // do something } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.