Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Handle __TRAIT__ in i18nTextCollector #10813

Merged

Conversation

emteknetnz
Copy link
Member

Issue #10810

@emteknetnz emteknetnz force-pushed the pulls/5.0/textcollecttraits branch from 4b486a9 to f4e0c76 Compare June 12, 2023 22:11
@@ -722,7 +722,7 @@ function ($input) {
} else {
throw new LogicException("Invalid string escape: " . $text);
}
} elseif ($id === T_CLASS_C) {
} elseif ($id === T_CLASS_C || $id === T_TRAIT_C) {
Copy link
Member

Choose a reason for hiding this comment

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

Above we're setting $id to T_TRAIT if that's available, but it looks like we're only ever doing anything with it if it's set to T_TRAIT_C.... Should we just always set it to T_TRAIT above for consistency, so we make sure we always handle it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so

$id gets get to T_TRAIT via

$tokens = token_get_all("<?php\n" . $content);
...
  foreach ($tokens as $token) {
    ...
    list($id, $text) = $token;

We then change it to T_TRAIT_C via
$id = $id === T_TRAIT ? T_TRAIT_C : T_CLASS_C;

For this PR I've simply adapted the existing code that handles __CLASS__ tokens inside a class block to handle __TRAIT__ inside a trait block.

Copy link
Member

Choose a reason for hiding this comment

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

Ahhh okay I misread that $id assigment line. No worries then.

@GuySartorelli GuySartorelli merged commit 6c266ec into silverstripe:5.0 Jun 13, 2023
@GuySartorelli GuySartorelli deleted the pulls/5.0/textcollecttraits branch June 13, 2023 04:50
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