Extending type-hinting for PHP

后端 未结 2 878
野趣味
野趣味 2021-02-19 19:20

Is it possible to extend the type-hinting with another documentor tag in Netbeans?

I\'m looking for a way to extend the type-hinting with a @scope tag that

相关标签:
2条回答
  • 2021-02-19 20:11

    In the past (older versions of NetBeans) the type-hinting was showing all the methods from a class (of which object was in use), i.e. all public, protected, private and even static methods. Now, in new releases of NetBeans, this bug was fixed and when type-hinting on the object only the accessible methods/properties are type-hinted.

    This is simply just because Your template cannot access/call private property/method of a class as well as if You have an object (instance of a class) You shouldn't be able to access/call it's class's static properties/methods.

    The same applies if You are willing to type-hint inside of the class - now the type-hinting lists all the public, protected and private methods for $this->| (| is the cursor) while the static properties and methods are still not listed. On the other side, if You are type-hint on MyClass::| now only the static properties/methods are listed and again, when inside the MyClass class all the public, protected and public ones are listed while when accessing from outside the private ones are (very correctly) missing in the list.

    So the functionality You are requesting is wrong and denies the correct principles of encapsulation.

    0 讨论(0)
  • 2021-02-19 20:13

    I know we're not supposed to suggest any tools, but sometimes I can't resist the feeling that people are trying to solve problems with the wrong one. NetBeans in my opinion is slowly following the steps of Eclipse, which almost entirely abandoned support for PHP over time. There are however other IDE's strictly designed for PHP language, which solve some problems out of the box.

    Personally I want a tool that gives me most functionality I need right from the start. I'm not interested in writing plugins, which take my time and may be deprecated over time. So I chose a commercial IDE, which gives me more then I need, and by the way - it perfectly adresses your needs included in the question. If your going to write PHP code then I strongly suggest you consider paying for a proffesional tool.

    About the issue itself I'm just going to give an example link to a feature request, which shows how the problem in question was addresed: Allow protected member access on @var $this (i.e. in views). Also there are many more related features, that you might find interesting.

    So to summarize my opinion is: if your going to tighten the screw then use a screwdriver, not a hammer.

    0 讨论(0)
提交回复
热议问题