goat1000/SVGGraph

PHP 8.1 compatibility, to avoid deprecation notices

mklemme1 opened this issue · 4 comments

Hallo
I am using SVGGraph Library version 3.13.
When using PHP 8.1.2 I get a lot of deprecation notices.

Code:

$graph =  new Goat1000\SVGGraph\SVGGraph(700,700, $settings);

Output:

Deprecated: Return type of Goat1000\SVGGraph\Colours::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /xxxxxx/SVGGraph/Colours.php on line 93 start`

In fact, the entire sceen is filled with notices.

I suspect the library needs to be updated in order to be usable with PHP 8.1

List of messages: messages.txt

I have upgraded my version of PHP to 8.1.2, so I can see this myself now. I'll see what I can do about it.

For now turning those messages off would be a simple fix - they are just warnings that things will not work with PHP9:

error_reporting(E_ALL ^ E_DEPRECATED);

Thanks!
I'll use that for the time being.

I get one more message

Notice: iconv(): Detected an illegal character in input string in xxxSVGGraph/Text.php on line 48 

That can be avoided by error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE );

I've fixed all the PHP 8.1 warnings and notices that I could find - there may be more, but none of my tests are showing any.