Skip to content

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

Merged
oscarotero merged 1 commit into
php-gettext:masterfrom
swissspidy:fix/comment-association
Nov 23, 2026
Merged

oscarotero merged 1 commit into
php-gettext:masterfrom
swissspidy:fix/comment-association

Conversation

@swissspidy

Copy link
Copy Markdown
Contributor

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.

@oscarotero

Copy link
Copy Markdown
Member

Oops, should I merge this one first? Now there's a conflict with the HEAD. Can you fix it?

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 5d6b751 to 4759f7e Compare November 20, 2026 21:31
@swissspidy

Copy link
Copy Markdown
Contributor Author

@oscarotero no worries, I rebased it now.

@oscarotero
oscarotero merged commit 247d4cd into php-gettext:master Nov 23, 2026
8 checks passed
@oscarotero

Copy link
Copy Markdown
Member

thank you!

oscarotero pushed a commit that referenced this pull request Nov 23, 2026
A comment on the line before an array item, or before the value of a
nested array item, was not extracted until the comment association fix
in #20. This adds the example from the issue as a test.

Closes #19
@swissspidy
swissspidy deleted the fix/comment-association branch November 23, 2026 16:43
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.

3 participants