-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Description
Description
The following code:
<?php
touch("/tmp/empty");
var_dump(iterator_count(new SplFileObject("/tmp/empty", "r")));
Resulted in this output:
(None. Script runs forever)
But I expected this output instead:
int(0)
It fails on files of any size, but this is the simplest I can reproduce the problem with.
Can reproduce this all the way to PHP 5.6 which is the earliest version I tried
PHP Version
PHP 8.4.12 (cli) (built: Sep 8 2025 21:17:50) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.12, Copyright (c) Zend Technologies
with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies
Operating System
Tested under Linux and macOS