Skip to content

@method Invalid method name with no arguments #174

Closed
@Ne-Lexa

Description

@Ne-Lexa

Problem phpDoc:

/**
 * @method static CategoryEnum GAME() Returns the category id 'Games'.
 */

Result:

phpDocumentor\Reflection\DocBlock\Tags\Method^ {#134
      #name: "method"
      -methodName: "Returns"
      -arguments: []
      -isStatic: true
      -returnType: phpDocumentor\Reflection\Types\Object_^ {#141
          -fqsen: phpDocumentor\Reflection\Fqsen^ {#136
              -fqsen: "\CategoryEnum"
              -name: "CategoryEnum"
          }
      }
      #description: phpDocumentor\Reflection\DocBlock\Description^ {#135
          -bodyTemplate: "the category id 'Games'."
          -tags: []
      }
}

The name of the method is 'Returns', and should be 'GAME'.

But, If you specify the arguments or remove (), it will work correctly.

/**
 * @method static CategoryEnum GAME Returns the category id 'Games'.
 * @method static CategoryEnum FAMILY(int $foo) Returns the category id 'Family'.
 */

Result:

[
    0 => phpDocumentor\Reflection\DocBlock\Tags\Method^ {#134
      -methodName: "GAME"
      -arguments: []
      #description: phpDocumentor\Reflection\DocBlock\Description^ {#135
        -bodyTemplate: "Returns the category id 'Games'."
      }
    }
    1 => phpDocumentor\Reflection\DocBlock\Tags\Method^ {#128
      -methodName: "FAMILY"
      -arguments: array:1 [
        0 => array:2 [
          "name" => "foo"
          "type" => phpDocumentor\Reflection\Types\Integer^ {#130}
        ]
      ]
      #description: phpDocumentor\Reflection\DocBlock\Description^ {#131
        -bodyTemplate: "Returns the category id 'Family'."
      }
    }
]

I consider this behavior to be incorrect, since the "methodName()" is used everywhere in the documentation.

The code uses this regular expression: https://regex101.com/r/VEOvgm/2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions