GNOME Bugzilla – Bug 552605
Add support for PHP namespaces
Last modified: 2011-03-20 23:52:29 UTC
PHP 5.3 introduces namespaces, for which support on Doxygen is missing. It is not yet fully clear whether PHP will use "namespace X::Y::Z;" or rather "namespace X::Y::Z { ... }" but this is about everything that remains to be seen. One developer hinted at the possibility of another slight change to namespace syntax, I'll keep this feature request updated. It should basically be enough if doxygen treats "namespace X::Y::Z;", as if "namespace X { namespace Y { namespace Z {" had been written in C#/C++ (where the closing }'s are all at the end of the file. But mind that there might be multiple namespace declarations in one PHP file, so in that case it needs to act as if the closing } is before that next namespace declaration. Here is the PHP documentation on namespaces: http://www.php.net/manual/language.namespaces.php And here is (part of) our code making use of namespaces, if you want to to have a look or need to code to test Doxygen on: https://svn.typo3.org/FLOW3/Packages/FLOW3/trunk/Classes/
Recently the PHP developers published PHP5.3.0alpha3 which includes the new syntax for namespaces. There was a switch from :: as namespace seperator to \ and now both ways of declaring a namespace (one being "namespace some\ns;" which is in effect from that point on until a new namespace is declared, the other being "namespace some\ns { ... }" doing what one would expect) are possible. The URLs mentioned above are still good, the PHP documentation has been updated accordingly and we have switched our codebase to the new syntax. Please, help us poor developers by at least giving us back one piece of our currently broken tool chain! ;)
If there is anything I can do to help with this, let me know. We currently have no way of producing code documentation, so we really long for a solution. :)
Oh, well, then it'll be some other tool... thanks anyway!
A patch with the solution would be nice ;-) Anyway, once namespaces become "non-alpha" they will probably be added to doxygen. Hopeful the developers will come to their senses and use :: i.s.o. \ as the scope operator before that happens.
He, nothing alpha about namespaces - PHP 5.3 is in release candidate status by now and the backslash will definitely stay...
PHP 5.3 is stable for a long time now. Doxygen will support php namespaces or not?
Is there any progress on this one? I tested again with the latest Doxygen 1.7.1 but didn't see any improvement regarding namespaces. I admit namespaces looks a bit weird in PHP compared to other language but it is really a missing feature for me. namespace MyApp\Web\Routing;
*** Bug 576911 has been marked as a duplicate of this bug. ***
The implementation of namespace support for PHP consists of 3 parts: 1) getting doxygen to parse PHP namespaces (including the "get" and "get as" constructs) 2) allowing references to qualified items from the documentation. 3) getting the source browser and cross referencing features to recognise qualified names and do proper name resolution. I'm current working on 1, which should be available in the next subversion update.
Great to hear that! Thanks for taking care...
(In reply to comment #9) > The implementation of namespace support for PHP consists of 3 parts: > 1) getting doxygen to parse PHP namespaces (including the "get" and "get as" > constructs) > 2) allowing references to qualified items from the documentation. > 3) getting the source browser and cross referencing features to recognise > qualified names and do proper name resolution. > > I'm current working on 1, which should be available in the next subversion > update. Awesome job! I am not sure whether you know, but there is yet another thing about namespaces in PHP that you might want to implement. PHP offers the possibility of 'switching' into a namespace by just putting a semicolon after the name instead of curly brackets containing the namespace's code. Thus, namespace A; class B { } namespace C; class C { } is the same as namespace A { class B { } } namespace C { class C { } } For verification, check out http://www.php.net/manual/en/language.namespaces.definitionmultiple.php . It would be very great if you implemented this feature as well. Thanks.
The PHP namespace support changes have been commited to SVN. Let me know if you see any issues.
This bug was previously marked ASSIGNED, which means it should be fixed in doxygen version 1.7.2. Please verify if this is indeed the case. Reopen the bug if you think it is not fixed and please include any additional information that you think can be relevant.
Version 1.7.2 seems not to be able to handle namespaced classnames for parameters and return values of methods. E.g. MyClass.php: namespace MyNamespace; class MyClass { ... } ExampleClass.php: class ExampleClass { /** * @var \MyNamespace\MyClass */ public exampleMember = null; } Instead doxygen outputs warnings like "documented function `MyNamespace MyClass' was not declared or defined".
(In reply to comment #14) > ExampleClass.php: > class ExampleClass { > /** > * @var \MyNamespace\MyClass > */ > public exampleMember = null; > } > > Instead doxygen outputs warnings like "documented function `MyNamespace > MyClass' was not declared or defined". I don't understand the use of @var in your example. What are you trying to accomplish? Or did you mean to use @ref instead?
@var indicates the type of the member variable, which could be used in the documentation to link to the according class (while "array" would also be a valid type as far as i know). IDEs like Eclipse PDT use this indication in order to provide specific auto-completion.
Please set the status of this issue to "open" until the stated issue with namespaced classes in @var is resolved.