What is the point of redundant php docblock tags like @static?
Asked Answered
D

1

6

When using automatic php docblock generation in PhpStorm, I ended up with the @static annotation on a static method:

/**
 * Reset the singleton instance, for the tests only
 * @static
 */
public static function reset() {
    self::$singletonInstance = null;
}

Is there any use for these tags if they can be inferred from the code? I'm trying to decide if I should leave it or remove it (and do so everywhere so it's consistent).

Deboradeborah answered 9/9, 2012 at 20:3 Comment(0)
D
6

These tags were introduced for legacy PHP 4 code that didn't permit the use of such keywords in code. With PHP 5, the code is effectively self-documenting, so these tags are indeed redundant; I don't see any reason to keep them around.

In fact, if you ever generate documentation for your PHP 5 source files, phpDocumentor should still be able to determine that these are static methods. This is mentioned in the phpDocumentor docs:

Just using the static keyword in your code is enough for PhpDocumentor on PHP5 to recognize static variables and methods, and PhpDocumentor will mark them as static.

Devinne answered 9/9, 2012 at 20:7 Comment(1)
Oh yes I didn't think of PHP4, now it makes sense ;)Deboradeborah

© 2022 - 2024 — McMap. All rights reserved.