BrianHenryIE / strauss

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

Fix notice - Undefined offset: 1 #91

Closed sovetski closed 6 months ago

sovetski commented 6 months ago

To reproduce, try the package phpoffice/phpspreadsheet with the version ^1.29

It will return PHP Notice: Undefined offset: 1 in vendor/brianhenryie/strauss/src/ChangeEnumerator.php on line 211

sovetski commented 6 months ago

Strange, it fixes the notice, but it does not work. I have this error

Interface "MyCustomPrefix_Stringable" not found

BrianHenryIE commented 6 months ago

Weird. I'd expect when preg_match() returns 1 the array really should have an element at [1].

preg_match() returns 1 if the pattern matches given subject, 0 if it does not, or false on failure.

BrianHenryIE commented 6 months ago

I think I've fixed the Undefined offset problem: 7c3212061578d78fa1236ca69eeb0ec435f6520d. Basically, it was seeing the word "namespace" in a comment and tripping up. I think your fix was probably fine, but it wasn't until I'd rewritten it this way that I really understood what had been happening.

But I think the Stringable issue is probably still there: https://github.com/BrianHenryIE/strauss/commit/1bd20b75a4e6b5c07a428c04e8b9e514034b6b5c #79

You probably have a polyfill library. Please test and let me know if the problem is still present. You should be able to fix it with:

"extra": {
    "strauss": {
        "exclude_from_prefix": {
            "packages": [
                "symfony/polyfill-php80",
                "php-extended/polyfill-php80-stringable"
            ]
        }
    }
}
BrianHenryIE commented 5 months ago

The interface Stringable issue is fixed in master now https://github.com/BrianHenryIE/strauss/compare/25db6cdcf5fa9761c8ea35cddbbe983600a9de7b...63d781d26d4b85a2284fd08e8862fae3a1d6001b