mikehaertl / php-pdftk

A PDF conversion and form utility based on pdftk
MIT License
939 stars 124 forks source link

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated #315

Closed JohnnyLouweret closed 10 months ago

JohnnyLouweret commented 11 months ago

Getting the following on php8.1

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated

   $result = $pdf
            ->fillForm($data) <------ here

    protected function xmlEncode($value)
    {
        return defined('ENT_XML1') ?
            htmlspecialchars($value, ENT_XML1, 'UTF-8') :
            htmlspecialchars($value);
    }

Anything we can do about this?

mikehaertl commented 11 months ago

It seems you have null as values in your $data. Can you confirm that? If that's the case, we can probably just skip those values.

JohnnyLouweret commented 11 months ago

Not entirely sure right now, but it seems more likely that some values in the array have null values as I cannot return null.

->fill($data->toArray())
function toArray(): array
[
    'firstName' => null,
    'lastName' => 'some name'
]
mikehaertl commented 11 months ago

Can you check if the fix in PR #316 works for you?

mikehaertl commented 10 months ago

@JohnnyLouweret Is there any news here? Were you able to test it?

mikehaertl commented 10 months ago

Closing this as there was no further feedback.