Skip to content

Add Filesystem::directoryIsEmpty() to check for directory contents without listing them - #1937

Closed
IonBazan wants to merge 1 commit into
thephpleague:3.xfrom
IonBazan:claude/add-directory-is-empty-31a53a
Closed

IonBazan wants to merge 1 commit into
thephpleague:3.xfrom
IonBazan:claude/add-directory-is-empty-31a53a

Conversation

@IonBazan

Copy link
Copy Markdown

This adds directoryIsEmpty() to Filesystem and MountManager so callers can check whether a directory has contents without listing all of it.

It reads the first item of a shallow listContents() and stops there. Listings are lazy, so the rest of the directory is never read. A directory that does not exist counts as empty, which matches what listContents() returns for a missing path.

The method is on the concrete classes only. Adding it to FilesystemReader, FilesystemOperator or FilesystemAdapter would break third-party implementations in 3.x.

Closes #1870

@IonBazan IonBazan closed this Nov 15, 2026
@IonBazan
IonBazan deleted the claude/add-directory-is-empty-31a53a branch November 15, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filesystem::isEmpty() method to check if a directory is empty without having to actually get the contents.

1 participant