Skip to content

Instantly share code, notes, and snippets.

@axiac
Last active July 6, 2021 11:00
Show Gist options
  • Save axiac/e2282b97e7ba34c30b39 to your computer and use it in GitHub Desktop.
Save axiac/e2282b97e7ba34c30b39 to your computer and use it in GitHub Desktop.
A PHP bug reported in 2011: https://bugs.php.net/bug.php?id=55701. Four years and four versions later, the bug is still there, affecting versions 5.3, 5.4, 5.5, 5.6 and 7.0
<?php
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '1');
$glob = new GlobIterator(__DIR__.'/*.some-funky-termination-that-doesnt-match-any-file-in-this-directory');
echo('Number of matching files: '.$glob->count()."\n");
// It should display the above message with 0 files but it throws a confusing exception:
// LogicException: The parent constructor was not called: the object is in an invalid state
// Any method you call on $glob throws the same exception.
// This is the end of file; no closing PHP tag
@axiac
Copy link
Author

axiac commented Jul 6, 2021

It has been fixed in v5.6.24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment