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

Add support for PHP namespaces (Origin: bugzilla #552605) #3084

Closed
doxygen opened this Issue Jul 2, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@doxygen
Owner

doxygen commented Jul 2, 2018

status RESOLVED severity enhancement in component general for ---
Reported in version 1.5.8 on platform Other
Assigned to: Dimitri van Heesch

On 2008-09-17 09:43:46 +0000, Karsten Dambekalns wrote:

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/

On 2008-12-15 17:54:56 +0000, Karsten Dambekalns wrote:

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! ;)

On 2009-01-16 11:28:31 +0000, Karsten Dambekalns wrote:

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. :)

On 2009-05-26 09:22:39 +0000, Karsten Dambekalns wrote:

Oh, well, then it'll be some other tool... thanks anyway!

On 2009-06-02 19:05:32 +0000, Dimitri van Heesch wrote:

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.

On 2009-06-02 21:34:26 +0000, Karsten Dambekalns wrote:

He, nothing alpha about namespaces - PHP 5.3 is in release candidate status by now and the backslash will definitely stay...

On 2010-04-09 12:37:38 +0000, Mangirdas wrote:

PHP 5.3 is stable for a long time now. Doxygen will support php namespaces or not?

On 2010-08-25 12:48:15 +0000, Fabien Udriot wrote:

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;

On 2010-08-28 16:53:04 +0000, Dimitri van Heesch wrote:

*** Bug 576911 has been marked as a duplicate of this bug. ***

On 2010-08-28 16:58:47 +0000, Dimitri van Heesch wrote:

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.

On 2010-08-28 17:19:03 +0000, Fabien Udriot wrote:

Great to hear that! Thanks for taking care...

On 2010-08-30 14:33:34 +0000, faeroth@web.de wrote:

(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.

On 2010-09-25 10:06:01 +0000, Dimitri van Heesch wrote:

The PHP namespace support changes have been commited to SVN.
Let me know if you see any issues.

On 2010-10-09 08:19:59 +0000, Dimitri van Heesch wrote:

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.

On 2010-11-21 23:01:14 +0000, account@dirk-thomas.net wrote:

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".

On 2010-11-22 19:42:33 +0000, Dimitri van Heesch wrote:

(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?

On 2010-11-23 10:43:27 +0000, account@dirk-thomas.net wrote:

@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.

On 2011-03-20 23:52:29 +0000, account@dirk-thomas.net wrote:

Please set the status of this issue to "open" until the stated issue with namespaced classes in @var is resolved.

@doxygen doxygen closed this Jul 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment