private vars magic getter/setter and code complete |
|
No, and AFAIK there is no way for PhpEd to know that at all. Code completion can only complete on variables it can see. In your case, the only variable that PhpEd would be able to complete would be the $legs, but only in the scope of its own class because it is private. Since it is not public, it wont see anything on derived objects from that class.
As for the __get and __set, there is no way for PhpEd to know your intentions to use that for mapping to private vars. You can actually supply a property value to a class that utilizes a __set function that has no mention of the property anywhere in the code and yet still has value because the __set function could have logic inside of itself to handle the setting of that property on other areas of the class. So because of that, AFAIK there is no programmable way to have PhpEd to uncover your intentions in using __set and __get to be able complete your code automatically. Have a great day! |
||||||||||||
|
|
We could implement a function in the class GetClassVars... PhpEd could call that? Would that be a worthwhile ECR? Too many variables to consider?
public function GetClassVars(){ return get_class_vars(get_class($this)); } /MB |
||||||||||||
|
|
Well, heres the way I see that. Its opening up a can of worms. What you are asking them to do is create a special method that is only used by PhpEd and not recognized anywhere else. If they implement that, then I can see a whole slew of requests coming in that will ask for special method this, special property that, and so on. Then no only would have all those requests to implement, but for each one you do implement you would have to maintain and verify non-conflict across future PHP and PhpEd updates. I dont think that would be something we would want as more attention would be taken for that, instead of continuing development of PhpEd to stay on top of PHP releases.
Also, if I am not mistaken, PHP is planning on implementing standard getter setter functions for properties (i.e. public function set thisProperty()) which then would provide the structure for code completion to work. Dont quote me on that, but I believe they are going to. I think I read that somewhere, in some blog, referencing some magazine, in an article read by some one at a rest stop. Quite viable, trust me. |
||||||||||||
|
|
I figured it would be a can of worms as you suggest and yes - everyone would have their own favorite feature they want to have added. One could say that's how software is improved - p)
Of course I'm joking. If PHP is adding real live getter setter syntax then I can deal with this until then. Thanks for the info /MB |
||||||||||||
|
|
I was just exploring some more PHPDoc options and code hinting... I see something I had not spotted before
/** * @package ThePack * @author foo * * @property $legs */ Class Animal { private $legs; ... balance of class like it was before } I notice when I include the @property tag for an item in the class then code hints will come up for that even though the item is declared as private within the class. Should this work OK or will the declaration of the @property interfere with the operation of the __get __set functions I have set up? I can try this out and let you know if you don't know already. /MB |
||||||||||||
|
|
I'll go ahead and answer my own question here... yes it does work and it does not appear to interfere with the usage of the __get and __set functions. The @property is discovered above the class definition and it shows up in the code hints but during operation it still goes through the __get and __set functions so you can do whatever property filtering or data validation is required.
Hope this helps the next one searching for this /MB |
||||||||||||
|
private vars magic getter/setter and code complete |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by