Skip to content

Find comments of wrapping nodes and on the previous line - #20

Open
swissspidy wants to merge 1 commit into
php-gettext:masterfrom
swissspidy:fix/comment-association
Open

swissspidy wants to merge 1 commit into
php-gettext:masterfrom
swissspidy:fix/comment-association

Conversation

@swissspidy

Copy link
Copy Markdown

A comment in front of a function call belongs to the outermost node that starts there. Only a few statement types were looked at, so the comment was lost when the call was an argument of another call, the value of an array item or part of a concatenation:

printf(
    /* translators: %s: Name */
    __('Hello %s'),
    $name
);

Comments on the line before the call are now found as well, which is common in templates:

<?php /* translators: Label */ ?>
<p><?php _e('Label'); ?></p>

Claude-Session: https://claude.ai/code/session_01UWTd5qmztfFv37ybV4xsjV

@swissspidy
swissspidy marked this pull request as ready for review November 17, 2026 16:12
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

A comment in front of a function call belongs to the outermost node
that starts there. Only a few statement types were looked at, so the
comment was lost when the call was an argument of another call, the
value of an array item or part of a concatenation:

    printf(
        /* translators: %s: Name */
        __('Hello %s'),
        $name
    );

Comments on the line before the call are now found as well, which is
common in templates:

    <?php /* translators: Label */ ?>
    <p><?php _e('Label'); ?></p>
@swissspidy
swissspidy force-pushed the fix/comment-association branch from d904da8 to 5d6b751 Compare November 18, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants