BrianHenryIE / strauss

Prefix PHP namespaces and classnames to allow multiple versions of libraries to exist without conflict.
https://brianhenryie.github.io/strauss/
MIT License
143 stars 23 forks source link

Warnings / broken autoloading with Strauss 0.18.0 vs 0.17.0 #101

Closed leewillis77 closed 7 months ago

leewillis77 commented 7 months ago

Version 0.18.0 contains a change which I believe is breaking strauss in my project:

Fix: composer dump-autoload error after delete-vendor-files/delete-vendor-packages

With strauss v0.17.0 the output of composer install [which triggers strauss] ends as follows and everything works as expected:

[info] Loading config...
[info] Building dependency list...
[info] Enumerating files...
[info] Copying files...
[info] Determining changes...
[info] Performing replacements...
[info] Adding licenses...
[info] Generating autoloader...
[info] Cleaning up...
> composer dump-autoload
Generating autoload files
Generated autoload files

The same configuration run against strauss v0.18.0 throws a bunch of warnings to the console and yields a broken project:

[info] Loading package...
[info] Loading composer.json config...
[info] Loading cli config...
[info] Building dependency list...
[info] Enumerating files...
[info] Copying files...
[info] Determining changes...
[info] Performing replacements...
[info] Adding licenses...
[info] Skipping autoloader generation as target directory is in Composer classmap. Run `composer dump-autoload`.
[info] Cleaning up...

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181

Notice: Undefined index: autoload in phar:///usr/local/bin/strauss/src/Cleanup.php on line 155

Warning: Invalid argument supplied for foreach() in phar:///usr/local/bin/strauss/src/Cleanup.php on line 156

Warning: array_filter() expects parameter 1 to be array, null given in phar:///usr/local/bin/strauss/src/Cleanup.php on line 181
> composer dump-autoload
Generating autoload files
Generated autoload files

After the install is run, autoloading appears broken for some items, e.g. Fatal error: Uncaught Error: Class 'Composer\XdebugHandler\XdebugHandler' not found

To reproduce the issue, follow the process below which strauss invoking either v0.17.0 or v0.18.0. Everything works as expected under v0.17.0, but fails under v0.18.0:

$ git clone git@github.com:leewillis77/strauss-issue.git
$ cd strauss-issue
$ composer install
$ php test.php                              // Will work as expected
$ composer run phpmd               // Will work as expected

Everything looks good at this point.

$ composer update

At this point strauss v0.18.0 will throw a bunch of PHP warnings and notices to the console, and autoloading will be broken.

$ php test.php // Still works
$ composer run phpmd            // Does not work under strauss v0.18.0, and throws a Class not found error, despite the class being present under the vendor/ folder

Oddly, in my build pipeline, everything fails after the initial install, but I couldn't reproduce that on my local machine, and a composer install then composer update is required before things break. Probably just a difference in my actual repo vs the example one I put together, but not quite sure what that might be.

JUVOJustin commented 7 months ago

Can confirm. Also happening in my github ci setups

BrianHenryIE commented 7 months ago

Oops. Should be fixed now. https://github.com/BrianHenryIE/strauss/commit/7a0a927835d50e5db8f0a277fe43df44e430eedc

leewillis77 commented 7 months ago

Thanks for the reply here. While v0.19.0 now no longer throws warnings to the console, autoloading is still broken with v0.19.0 versus v0.17.0 - ie this step in the reproduction:

$ php test.php // Still works
$ composer run phpmd            // Does not work under strauss v0.19.0, and throws a Class not found error, despite the class being present under the vendor/ folder
BrianHenryIE commented 7 months ago

I seem to have that fixed now. I was missing / in a path.

https://github.com/BrianHenryIE/strauss/commit/07c4945864bc0381919380bb0a0affb5702d162d

leewillis77 commented 7 months ago

Confirming that v0.19.1 resolves the issues we were having - thanks!