Skip to content

3.0 - Confusing commentsBlocks references #278

@miljan-aleksic

Description

@miljan-aleksic

Hi, first of all thank you for your work :)

I found it confusing and difficult to associate comments with their methods in the current 3.0-prerelease 8 version. Taking as example:

<?php

namespace Foospace\Foo;

/**
 * Class description
 */
class FooClass
{
    /**
     * Description
     */
    public static function bar()
    {
        return $array;
    }

    /**
     * Description
     */
    public static function baz()
    {
        return $array;
    }
  
    /**
     * Description
     */
    public static function woo()
    {
        return $array;
    }
}

the AST explorer will render something like this:

// class body
[
    {
        "kind": "method",
        "leadingComments": [...],
        "body": {
            "trailingComments": [...],
        },
        ...
    },
    {
        "kind": "method",
        "body": {
            "trailingComments": [...],
        },
        ...
    },
    {
        "kind": "method",
        "body": {
            "trailingComments": [...],
        },
        ...
    }
]

The confusing part is that the trailing comments are part of the method body, which is not accurate.

And I would expect each method to have it leadingComments as the first one in order to access them easier.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions