GithubHelp home page GithubHelp logo

PHP 8.1 Deprecated notices about php-svg HOT 7 CLOSED

Tomefa avatar Tomefa commented on August 30, 2024
PHP 8.1 Deprecated notices

from php-svg.

Comments (7)

meyfa avatar meyfa commented on August 30, 2024

Thanks for reporting! Would you like to send a pull request to fix the issue?

Please note that our support matrix still includes very old PHP versions down to 5.3, which actually require the $num_points parameter to be present. Perhaps this can be solved with a conditional call to imagefilledpolygon(): if the PHP_VERSION_MAJOR constant is greater than/equal to 8, then call imagefilledpolygon() without $num_points, otherwise call imagefilledpolygon() with $num_points just as we are doing now. What do you think?

Documentation for PHP 5 can be found here: https://php-legacy-docs.zend.com/manual/php5/en/function.imagefilledpolygon

from php-svg.

Niellles avatar Niellles commented on August 30, 2024

As for the depreciation notice on passing null to trim() I am wondering what the preferred solution would be:

  1. Look for all the instances of trim() in the repo. Check whether the parameter could potentially be null and if so add a condition that replaces null with an empty string.
  2. Add a string helper/utility (e.g. Str::trim()) that replaces null with an empty string and then returns trim(). And replace all calls to trim() in the repo with Str::trim().

The latter would probably have my preference as it doesn't "pollute" the code base with a lot of checks on null. However I still have to check how many times this occurs. (Option 1 would be perfectly acceptable if it's only a couple of instances.)

from php-svg.

meyfa avatar meyfa commented on August 30, 2024

@Niellles I'd also prefer the second option. Probably a function call slightly degrades performance, especially in parts of the code that are called often, but honestly, the reduced complexity seems worth it. I've counted a about a dozen trim calls, so it should be above the threshold.

from php-svg.

Niellles avatar Niellles commented on August 30, 2024

@meyfa Allright then, nice that we can agree on that. I'll submit a PR at a later point.

I couldn't find any calles to imagefilledpolygon() by the way. So not sure where there 2nd notice comes from.

Remaining direct deprecation notices (2)
1x: trim(): Passing null to parameter #1 ($string) of type string is deprecated
1x: imagefilledpolygon(): Using the $num_points parameter is deprecated


Additionally I'm having some issues with running the test suite locally. PHP 8.1 and 8.0 both fail due to each() being removed and it's required by PHPunit. PHP 7.4 runs the tests partially, but gives a bunch of deprecation notices on each() among others. I can probably work around this (i.e. use an even lower PHP version). However I've noticed that the test suite ran successfully on my recent PR #140 on PHP 8.0. Anything special you did to get the tests to run?

from php-svg.

meyfa avatar meyfa commented on August 30, 2024

I couldn't find any calles to imagefilledpolygon() by the way.

Those were probably removed as part of still unreleased changes. That's why they aren't part of the code on GitHub, but can be seen on servers when using PHP-SVG via Composer.

I'm contemplating creating a v0.12.0 with reduced scope, i.e., with fewer features implemented than are on the v0.12.0 milestone to get some fixes released. I probably won't have any capacity to complete the missing features in the near term any way.

Additionally I'm having some issues with running the test suite locally.

For PHP 8, we need to load a bootstrap file that polyfills the each function. On CI, this is done by configuring php.ini, check out /.github/workflows/php.yml. On the command line, invoking PHPUnit as ./vendor/bin/phpunit --bootstrap tests/bootstrap.php should work.

from php-svg.

Niellles avatar Niellles commented on August 30, 2024

Those were probably removed as part of still unreleased changes. That's why they aren't part of the code on GitHub, but can be seen on servers when using PHP-SVG via Composer.

Since the part above is no longer relevant (i.e. upgrading to a newer release should remove the notice). This remaining part of the issue (i.e. regarding trim(null)) should be fixed with #177.


For PHP 8, we need to load a bootstrap file that polyfills the each function. On CI, this is done by configuring php.ini, check out /.github/workflows/php.yml. On the command line, invoking PHPUnit as ./vendor/bin/phpunit --bootstrap tests/bootstrap.php should work.

Makes sense. How about adding it via the composer-autoloader though? (Probably as a development dependency as only PHPUnit seems to care about it.)

from php-svg.

meyfa avatar meyfa commented on August 30, 2024

This remaining part of the issue (i.e. regarding trim(null)) should be fixed with #177.

I agree. Closing this issue.

Regarding bootstrapping, I've opened #178 to discuss solutions, since it's off-topic here -- but I agree that we need to improve the situation.

from php-svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.