4

I am using the following line in PHP with NetBeans 7.0 :

$ret = $this->stupid_function();

I certainly know that stupid_function doesn't exist in this class or any derivative of this.

"Navigate to source/declaration" takes me nowhere.

But still NetBeans doesn't seem to mark the line as error.

  • I tried restarting Netbeans
  • I tried re-adding the project
  • I tried deleting cache

Nothing seems to work...

Although, I observed that if I removed $this from that statement, NetBeans knows that the function doesn't exist. It seems like NetBeans doesn't understand $this properly.

How to highlight code referencing nonexistent function when using PHP in NetBeans?

alain.janinm
  • 19,951
  • 10
  • 65
  • 112
Shrinath
  • 7,888
  • 13
  • 48
  • 85
  • I have read the reason for no error is because functions can be created on the fly. However I still think you should be able to have a hint. It seems you still can't in Netbeans 8.2. Did you ever find a decent solution to this? – AndyW Feb 14 '17 at 12:00
  • Nope! Tried the answers, none work. Also, since it did not work, I moved out of PHP :) 6 years old question!! – Shrinath Feb 15 '17 at 04:27

2 Answers2

1

I think you should use the magic method functionality of PHP in your class.

public function __call($method, $args) {
  echo "unknown method " . $method;
  return false;
}
1

The support for PHP highlighting is rather limited in Netbeans.

Check in Tools -> Editor -> Hints

Choose PHP.

You have here the full list of supported hints about possible errors/warnings in the code. Nothing works for me among the Experimental options (so Unknow function hints fails) in 7.0, it's slightly better in 7.1, but still doesn't work. Indeed in 7.1 they removed the Unknow function hints from the list.

Seems that Netbeans 7.2 has improved the highlightings quality. If you're in PHP I suggest you download the latest version of Netbeans.

alain.janinm
  • 19,951
  • 10
  • 65
  • 112