PHPPresentation icon indicating copy to clipboard operation
PHPPresentation copied to clipboard

Font::setSize() must be of the type int, float given

Open gsonss opened this issue 2 years ago • 4 comments

Fatal error: Uncaught TypeError: Argument 1 passed to PhpOffice\PhpPresentation\Style\Font::setSize() must be of the type int, float given

gsonss avatar Apr 19 '22 02:04 gsonss

PHP 7.4.19 (cli) Zend Engine v3.4.0

gsonss avatar Apr 19 '22 02:04 gsonss

same problem with me, Did you solve it ?

Slairmy avatar Jul 13 '22 03:07 Slairmy

You have tried to set a float as the font size (such as 7.125), but this function requires an integer (such as 7 - see the exact function you're calling below). To fix this, you need to ensure you're only passing an integer value - perhaps using the PHP functions of round(), floor(), ceil() or intval() on the variable?

/**
 * Set Size.
*/
public function setSize(int $pValue = 10): self
{ 
  $this->size = $pValue;

  return $this;
}

Tom-Magill avatar Sep 07 '22 05:09 Tom-Magill