PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.16k stars 2.68k forks source link

Alterd the function ensureUtf8Encoded to return only an empty string on null and false #2566

Open SnipsMine opened 5 months ago

SnipsMine commented 5 months ago

Description

I ran into a problem that nothing was printed when 0 was given as the value for function TemplateProcessor->setValue(). I tracked this issue down to the function ensureUtf8Encoded that checked if $subject was true, instead of is not null.

I changed the line to check if $subject is null and only then return a empty string else the value is send to Text::toUTF8().

The test I wrote might be a bit overkill, but I hope it sufficient to test te fix

Checklist:

coveralls commented 5 months ago

Coverage Status

coverage: 97.217%. remained the same when pulling cb1ba73c909932d1de5314c0bfdd7fd00db6d31a on SnipsMine:master into 8b891bb6842dd383f679b47898fad0b7c181f325 on PHPOffice:master.