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 non-numeric value warning #627

Merged
merged 4 commits into from Sep 6, 2023
Merged

Conversation

d-salerno
Copy link
Contributor

Fixes this warning on generating PDF:
Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5473

Fixes this warning on generating PDF:
Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5473
@CLAassistant
Copy link

CLAassistant commented Jun 7, 2023

CLA assistant check
All committers have signed the CLA.

tcpdf.php Outdated
Comment on lines 5470 to 5472
if(!is_numeric($this->textstrokewidth)){
$this->textstrokewidth = 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you try to track in the code where it changes to a non numeric value ?

	/**
	 * Text stroke width in doc units.
	 * @protected
	 * @since 4.9.008 (2010-04-03)
	 */
	protected $textstrokewidth = 0;

Since it's initialized to 0
Maybe you can add an @var int or @var float or @var int|float phpdoc on this property, for documentation purposes

The fix you propose indeed should work, but if we can catch it earlier to avoid the textstrokewidth being a non numeric that would be cool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, turns out I was passing a non-numeric value to the Text function for $fstroke. The new commit ignores non-numeric values that are passed

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it looks way better

Is this mistake related to your code of tcpdf code calling the function ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess so, but anybody calling $pdf->Text($x, $y, $text, "non-numeric"); would get the same warning

Fixes this warning on generating PDF after calling `Text` with a non-numeric value for `$fstroke`:
Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5470
tcpdf.php Outdated Show resolved Hide resolved
Co-authored-by: William Desportes <williamdes@wdes.fr>
Copy link
Contributor

@williamdes williamdes left a comment

Choose a reason for hiding this comment

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

Let's hope Nicolas also likes this patch

@williamdes williamdes mentioned this pull request Aug 2, 2023
@nicolaasuni nicolaasuni merged commit b142eba into tecnickcom:main Sep 6, 2023
0 of 9 checks passed
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.

None yet

4 participants