Skip to content

Inserted boilerplate gets broken if there is a CRLF line break after the opening tag #176

@micaherne

Description

@micaherne

I'm seeing an issue with the fix for the Files.BoilerplateComment sniff where there is a Windows line ending after the opening <?php tag.

Running phpcbf with the moodle standard on this code:

<?php

gives this:

<?php
// This file is part of Moodle - https://moodle.org/
// Moodle is free software: you can redistribute it and/or modify
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.

This doesn't happen if running the boilerplate sniff only (vendor/bin/phpcbf --standard=moodle --sniffs=moodle.Files.BoilerplateComment) and from looking at the processing output it looks as if it may be an interaction with moodle.Commenting.InlineComment which seems to remove the blank lines from the boilerplate, which BoilerplateComment then adds back in wrongly.

I think there may be a couple of buggy things going on here so I'll try to work out in more detail what is happening.

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