php-svg-lib icon indicating copy to clipboard operation
php-svg-lib copied to clipboard

Update composer.json

Open tacman opened this issue 4 months ago • 13 comments

allow php-css-parser 9

tacman avatar Aug 21 '25 10:08 tacman

Unit tests are happy. Have you had a chance to review changes between 8 and 9? I haven't yet done so to see if there are any breaking changes that need to be addressed.

bsweeney avatar Aug 21 '25 14:08 bsweeney

phpstan reports the same warnings with both 8 and 9. They should probably be fixed regardless. The signatures are the same, so I imagine they are compatible.

I'm hesitant to fix these, though, because you're still supporting PHP 7.1, and maintaining compatibility with that is awkward. If yo ever release a new version, I'd recommend rector and updating to only supported versions of php.

Very low priority, I just noticed the new version of that library.

phpstan analyze src 29/29 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


Line Svg/Style.php


89 Method Svg\Style::fromAttributes() should return Svg\Style but return statement is missing.
🪪 return.missing
91 Method Svg\Style::fromAttributes() should return Svg\Style but return statement is missing.
🪪 return.missing



Line Svg/Surface/CPdf.php


1109 Undefined variable: $object
🪪 variable.undefined
1111 Undefined variable: $object
🪪 variable.undefined
3624 Call to vsprintf contains 3 placeholders, 4 values given.
🪪 argument.vsprintf
3663 Call to vsprintf contains 3 placeholders, 4 values given.
🪪 argument.vsprintf



Line Svg/Surface/SurfaceCpdf.php


220 Call to an undefined method Svg\Surface\SurfaceCpdf::_convert_gif_bmp_to_png().
🪪 method.notFound


tacman avatar Aug 21 '25 14:08 tacman

Unit tests are happy. Have you had a chance to review changes between 8 and 9? I haven't yet done so to see if there are any breaking changes that need to be addressed.

The only potentially breaking change is https://github.com/MyIntervals/PHP-CSS-Parser/pull/1194. It is unlikely to be breaking, but since it changed the class hierarchy, we considered it worthy of a new major release, just in case.

You can allow v8 or v9 in composer.json. I hope you can resolve this soon - we have had a PR attempting to add PHP 8.5 support to the 8.x branch which is no longer supported. The 9.x version is compatible with PHP from 7.2, which should be sufficient.

JakeQZ avatar Nov 06 '25 01:11 JakeQZ

Thank you for the information. I do plan to start reviewing changes for the next release of SvgLib i the near future.

bsweeney avatar Nov 06 '25 04:11 bsweeney

next release of SvgLib i

What about dropping all unsupported/EOL versions of the dependencies?

tacman avatar Nov 06 '25 09:11 tacman

I'm fine to do that, though preferably separately as a major release. I know it's not strictly necessary since dependency management will take care of it, but I prefer to do it that way to maintain a clear cut off point.

bsweeney avatar Nov 06 '25 13:11 bsweeney

Makes sense. PHP 7.1 reached EOL in 2019. PHP 8.5 will be released in a few weeks, seems like a nice time for a new release.

tacman avatar Nov 06 '25 13:11 tacman

220 Call to an undefined method Svg\Surface\SurfaceCpdf::_convert_gif_bmp_to_png().

FYI I'll address this issue outside of this PR.

bsweeney avatar Nov 15 '25 20:11 bsweeney

It looks like work needs to be done to make SvgLib compatible with version 9. Running through some local (non-unit) tests I'm getting the following error:

Error: Object of class Sabberworm\CSS\Value\Size could not be converted to string in C:\code\php-svg-lib\php-svg-lib\src\Svg\Style.php on line 142

when rendering the following SVG:

<svg width="500" height="110" viewBox="0 0 500 110" xmlns="http://www.w3.org/2000/svg">
    <defs>
        <style type="text/css">
            text {
                font-size: 9pt;
                font-family: sans-serif;
            }
        </style>
    </defs>
    <text x="0" y="0">SvgLib</text>
</svg>

This was the first problem I encountered, and I stopped looking at that point so there could be other issues. I'll continue to review usage to see what changes would need to be made.

bsweeney avatar Nov 15 '25 20:11 bsweeney

__toString() was removed as it was redundant with render(): https://github.com/MyIntervals/PHP-CSS-Parser/issues/998

So in the places where you string-cast CSS objects to strings, you‘ll need to call render() instead.

oliverklee avatar Nov 15 '25 20:11 oliverklee

Thank you for the guidance.

bsweeney avatar Nov 16 '25 04:11 bsweeney

Looking through the changelog, I believe that's the only problematic use case in SvgLib.

bsweeney avatar Nov 16 '25 15:11 bsweeney

This would fix https://github.com/dompdf/php-svg-lib/issues/129

fballiano avatar Nov 22 '25 17:11 fballiano