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

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

Closed
JohnnyLouweret opened this issue Oct 16, 2023 · 5 comments

Comments

@JohnnyLouweret
Copy link

JohnnyLouweret commented Oct 16, 2023

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

@mikehaertl
Copy link
Owner

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

@mikehaertl
Copy link
Owner

Closing this as there was no further feedback.

mikehaertl added a commit that referenced this issue Nov 3, 2023
Issue #315 Fix htmlspecialchars() warning for null values
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

No branches or pull requests

2 participants