PHP Nette - TypeError Argument must be of the type int, float given (how return type int from round)
Hi,
on a server with PHP 7.4, the image operations I use in Nette have stopped working for me ( Nette\Utils\Image::fromBlank() ). It used to go smoothly. Don't know what the mistake is? Thanks
ERROR:
Hi,
you have to modify the round to return the int data type instead of the float as follows:
on a server with PHP 7.4, the image operations I use in Nette have stopped working for me ( Nette\Utils\Image::fromBlank() ). It used to go smoothly. Don't know what the mistake is? Thanks
ERROR:
TypeError
Argument 2 passed to Nette\Utils\Image::fromBlank() must be of the type int, float given, called in /var/www/is_dev/vendor/nette/utils/src/Utils/Image.php on line 392 search►
.../vendor/nette/utils/src/Utils/Image.php:392
Nette\Utils\Image::fromBlank()
.../vendor/nette/utils/src/Utils/Image.php:292
Nette\Utils\Image->crop()
.../app/AdminModule/model/UploadsAdmin.php:152
Nette\Utils\Image->resize()
142:
143:
144: } else {
145:
146:
147: $width = $thumbMaxSize;
148: $height = round($thumbMaxSize / 1.5);
149:
150:
151: if ($image->width > $image->height) {
152: $image->resize($width, $height, Image::EXACT);
153:
154:
155: } else {
156: $image->resize($width, $height, Image::EXACT);
REPLY
Hi,
you have to modify the round to return the int data type instead of the float as follows:
$width = intval(round($thumbMaxSize / 1.5));