Skip to content

First comment in Method is ignored when using PhpFile::fromCode() #119

Description

@MaximilianSpeer

Version: 3.6.7

Bug Description

The PhpParser ignores a comment if it's in the first line of a method. This occurses when using PhpFile::fromCode()

Steps To Reproduce

`$code = "<?php

    class TestClass
    {
        function aFunction()
        {
            // a Comment
            \$foo = 'bar';
            // another Comment
        }
    }";

$file = PhpFile::fromCode($code);
$newCode = (string) $file;
echo $newCode;
return;`

Expected Behavior

The first comment should get extracted from the code and stored in the PhpFile object.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions