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

Problem with setValue function in TemplateProcessor #2703

Open
xlh2046 opened this issue Nov 25, 2024 · 0 comments
Open

Problem with setValue function in TemplateProcessor #2703

xlh2046 opened this issue Nov 25, 2024 · 0 comments

Comments

@xlh2046
Copy link

xlh2046 commented Nov 25, 2024

Describe the bug and add attachments

When using the setValue function of the Template Processor class:
$templateProcessor->setValue('score', '0');

Expected behavior

I want to replace the score variable with 0,but the result was that the score variable was replaced with ''.
After checking the code, this function looks like this:
/**
* @param ?string $subject
*
* @return string
*/
protected static function ensureUtf8Encoded($subject)
{
return $subject ? Text::toUTF8($subject) : '';
}

I will change it as follows, local testing is possible. like this:
protected static function ensureUtf8Encoded($subject)
{
$subject = $subject??'';
return $subject ? Text::toUTF8($subject) : $subject;
}

Steps to reproduce

setValue('score', '0'); ... ### PHPWord version(s) where the bug happened 1.3.0 ### PHP version(s) where the bug happened 8.3 ### Priority - [ ] I want to crowdfund the bug fix (with [@algora-io](https://docs.algora.io/bounties/overview)) and fund a community developer. - [ ] I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant