-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation of special behaviour of magic methods #39
Comments
I don't understand what you mean, can you do an example? |
I use this functionality in a similar way. It's just needed somehow in PHP because of the magic methods. /**
|
@peej, @redshadow159 is talking about object overloading. That way of documenting "magic methods" is pretty clunky. I propose that regular function/method docblocks be used, but that an added tag be used to indicate that the block is meant for a magic method. For example:
Doing it this way gives us the benefit of everything we can already do in non-magic method docblocks, as well as it being easily understood by developers what those docblocks are for. |
Hi Kevin, I like this approach to handling the __call magic method. You'd need to optionally specify the method name too, perhaps as part of the @magic tag. |
I'm looking at tackling this issue, mind telling me where I can start? Where should I look at to start making tweaks? |
It's quite a difficult one actually now that I think about it. The parser works by reading doccomments into a buffer and then continuing until it finds an element that we document, applying the previously captured doccomment content to it. In this case, there is no element to find, just the doccomment, so the methodDoc object we need to create will have to be done when the doccomment is processed and a @magic tag is discovered. Look at line 630 of phpDoctor.php, this is where the doccomments are parsed and buffered. A quick check somewhere here to see if the doccomment contains a @magic tag and if so create a methodDoc would probably do the trick. |
Because of the possibility to use __callStatic or __call, there should be a @method annotation which allows the developer to document these things.
In addition to that, @Property(-read/-write) should be included into the fields table with the keyword final if only read access is allowed and for write only something else. Write only for a property is bad practise, but PHP offers you that possibility...
The text was updated successfully, but these errors were encountered: