liborm85 / composer-vendor-cleaner

Composer Vendor Cleaner removes unnecessary development files and directories from vendor directory.
MIT License
27 stars 3 forks source link

Empty (Null) Path RuntimeException #8

Closed fbrinker closed 1 year ago

fbrinker commented 1 year ago

Problem

When using this plugin with the package "roave/security-advisories", I get the following error, due to the fact that getInstallPath() returns null:

In Directory.php line 58:
[RuntimeException]
Directory name must not be empty.

With another composer version:

Deprecation Notice: RecursiveDirectoryIterator::__construct(): Passing null to parameter #1 ($directory) of type string is deprecated in /app/vendor/liborm85/composer-vendor-cleaner/src/Directory.php:58

In Directory.php line 58:
[ValueError]
RecursiveDirectoryIterator::__construct(): Argument 1 ($directory) cannot be empty

Reproduction

Composer file to reproduce this:

{
    "name": "test/cleanup",
    "description": "cleanup test",
    "config": {
        "platform": {
            "php": "8.1.0"
        },
        "allow-plugins": {
            "liborm85/composer-vendor-cleaner": true
        }
    },
    "extra": {
        "dev-files": {
            "ramsey/uuid": [
                "*.md"
            ]
        }
    },
    "require": {
        "php": "8.1.*",
        "ramsey/uuid": "4.2.3",
        "liborm85/composer-vendor-cleaner": "1.7.0"
    },
    "require-dev": {
        "roave/security-advisories": "dev-latest"
    }
}

... by running docker run --rm --interactive --tty --volume $PWD:/app composer update

Solution

To avoid the error and the deprecation, I would like to introduce a null check additionally to the empty string check.

liborm85 commented 1 year ago

Fixed in released version 1.7.1.