Skip to content

rmdir() recursive branch reflects into vfsStream private internals (brittle vs ^1.6 bumps) #37

Description

@remyperona

Summary

VirtualFilesystemDirect::rmdir() (recursive branch) reaches into vfsStream's private internals via reflection, coupling the package to a specific vfsStream implementation layout.

Where

VirtualFilesystemDirect.php, recursive rmdir():

$child   = $this->getDir( $dir );
$dirname = $this->getNonPublicPropertyValue( 'name', vfsStreamAbstractContent::class, $child );
$parent  = $this->getParentDir( $dirname, $child );

getParentDir() likewise reads the private parentPath property. Both go through TestCaseTrait::getNonPublicPropertyValue().

Impact

composer.json allows mikey179/vfsstream: ^1.6, so any minor/patch bump can change these private members and silently break recursive directory removal — a core operation the whole filesystem-mock strategy depends on. There is no compile-time signal; it would surface only as failing consumer tests.

Proposed direction

Use vfsStream's public API instead of reflection:

  • vfsStreamContainer::removeChild() / getChild() for the tree mutation.
  • Newer vfsStream exposes getParent(); where unavailable, derive the parent from the known path rather than reading parentPath.

Goal: no reflection into vfsStream internals, so a vfsStream upgrade can't break recursive delete unnoticed.


Found during an audit of WP Rocket's integration test suite, which depends on this package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions