Skip to content

Supporting the leadingComments array #16

@austinkregel

Description

@austinkregel

Hello!
First off, thank you for your work here. It's saved me many hours of figuring out how to do this myself 😄

I am trying to build a small program to generate PHPUnit tests based off of the class, right now the only thing really preventing me from implementing anything is having the leadingComments supported

"leadingComments": [
    {
        "kind": "commentblock",
        "value": "/**\n * Class " + classObject.name + 'Test' + "\n * @package Tests\\Unit\\Console\\Commands\\ADFRequest\n */"
    }
],

My company uses declare(strict_types=1); and has a comment above it for a file comment and right now the unparser doesn't support any kind of leading comments.

Here is what the parser generates:

{
        "kind": "program",
        "children": [
                {
                    "kind": "declare",
                    "leadingComments": [
                        {
                            "kind": "commentblock",
                            "value": "/**\n * Tests the class\n */"
                        }
                    ],
                    "children": [],
                    "what": {
                        "strict_types": {
                            "kind": "number",
                            "value": "1"
                        }
                    },
                    "mode": "none"
                },
                // Other class item
       ]
}

And in PHP it would look like this:

<?php
/**
 * Tests the class
 */
 declare(strict_types=1);

Adding support for the leading comments would be deeply appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions