Skip to content

Commit 31f1055

Browse files
committed
fixed PHP 8.5 compatibility
1 parent 0f92a44 commit 31f1055

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/Iterators/CachingIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CachingIterator extends \CachingIterator implements \Countable
3434
public function __construct(iterable|\stdClass $iterable)
3535
{
3636
$iterable = $iterable instanceof \stdClass
37-
? new \ArrayIterator($iterable)
37+
? new \ArrayIterator((array) $iterable)
3838
: Nette\Utils\Iterables::toIterator($iterable);
3939
parent::__construct($iterable, 0);
4040
}

src/Utils/Image.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ public static function fromBlank(int $width, int $height, ImageColor|array|null
239239
*/
240240
public static function detectTypeFromFile(string $file, &$width = null, &$height = null): ?int
241241
{
242-
[$width, $height, $type] = @getimagesize($file); // @ - files smaller than 12 bytes causes read error
243-
return isset(self::Formats[$type]) ? $type : null;
242+
[$width, $height, $type] = Helpers::falseToNull(@getimagesize($file)); // @ - files smaller than 12 bytes causes read error
243+
return $type && isset(self::Formats[$type]) ? $type : null;
244244
}
245245

246246

@@ -250,8 +250,8 @@ public static function detectTypeFromFile(string $file, &$width = null, &$height
250250
*/
251251
public static function detectTypeFromString(string $s, &$width = null, &$height = null): ?int
252252
{
253-
[$width, $height, $type] = @getimagesizefromstring($s); // @ - strings smaller than 12 bytes causes read error
254-
return isset(self::Formats[$type]) ? $type : null;
253+
[$width, $height, $type] = Helpers::falseToNull(@getimagesizefromstring($s)); // @ - strings smaller than 12 bytes causes read error
254+
return $type && isset(self::Formats[$type]) ? $type : null;
255255
}
256256

257257

tests/Utils/ArrayHash.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test('recursive conversion transforms nested arrays into ArrayHash', function ()
117117
'j' => 'Jack',
118118
'children' => $list['children'],
119119
'c' => 'Jim',
120-
], iterator_to_array(new RecursiveIteratorIterator(new RecursiveArrayIterator($list), RecursiveIteratorIterator::SELF_FIRST)));
120+
], @iterator_to_array(new RecursiveIteratorIterator(new RecursiveArrayIterator($list), RecursiveIteratorIterator::SELF_FIRST))); // ArrayIterator($object) is deprecated since PHP 8.5
121121
});
122122

123123

tests/Utils/FileSystem.copy.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ class RemoteStream /* extends \streamWrapper */
3333
{
3434
return false;
3535
}
36+
37+
38+
public function stream_eof()
39+
{
40+
return false;
41+
}
3642
}
3743

3844
stream_wrapper_register('remote', RemoteStream::class, STREAM_IS_URL);

0 commit comments

Comments
 (0)