PHP Nette - TypeError Argument must be of the type int, float given (how return type int from round)

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:

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));

Související obsah

programovani

ajax

php

type

typehint

nette

Komentáře

Vaše reakce na PHP Nette - TypeError Argument must be of the type int, float given

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.