enumeration icon indicating copy to clipboard operation
enumeration copied to clipboard

Improve documentation

Open berturion opened this issue 9 years ago • 4 comments

Hi, In Java Styles enumeration implementations, members are called with static methods that are not explicitly declared. So, in IDE like Eclipse PHP or other, those methods are not listed for auto-completion.

I found that adding appropriate PHPDocumentor doc blocks resolves this issue.

For example, if you have those members in a Exemple class extending AbstractMultiton:

Exemple::FOO()
Exemple::BAR()

You can add this doc block:

/**
 * @method static Exemple FOO()
 * @method static Exemple BAR()
 */
class Exemple extends AbstractMultiton
{
    (...)
}

Trust me, it is very useful !

berturion avatar Mar 18 '16 12:03 berturion

Seems like useful information to have. I'll try to include this in the README when I get a chance.

ezzatron avatar Mar 29 '16 04:03 ezzatron

This is entirely unnecessary. If you do not like those semantics use Enumeration::memberByKey() instead. Static analysis will work in your editor with this calling convention.

Bilge avatar Jun 29 '16 12:06 Bilge

I agree, this is not necessary, but it is more convenient, at least for me.

Exemple::FOO() is shorter than Exemple::memberByKey(Exemple::FOO) or Exemple::memberByKey('FOO') and auto-completion in IDE is called once instead of two.

Without those @method annotations, auto-completion only propose the static member of the enumeration (FOO) so we always need to add parentheses at the end to call the Enumeration object (FOO()). But the IDE doesn't recognize the static method Exemple::FOO() because it is not explicitly declared.

Anyway, it is up to you to add this tip. I just wanted to share it. You can close the issue if you mind.

berturion avatar Jun 30 '16 06:06 berturion

Perhaps you should submit a PR rather than an issue if you want to share this information.

Bilge avatar Jul 28 '17 11:07 Bilge