friends-of-reactphp / mysql

Async MySQL database client for ReactPHP.
MIT License
334 stars 66 forks source link

PHP 8.1: PHP Deprecated: parse_str() #149

Closed hasanparasteh closed 2 years ago

hasanparasteh commented 2 years ago

When I run my ReactPHP project using PHP 8.1 I get the below warnings...please consider adding more strong support in the new version of PHP. I know PHP recently upgraded to 8.1 and I appreciate your hard works on this great project!

Using this function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2. Link: PHP documentation on parse_str

Composer.json

"react/mysql": "^0.5.5"

Code

$databaseFactory = new Factory($loop);
$databaseFactory->createLazyConnection($databaseUri['appManager']);

Console

PHP Deprecated:  parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/react/mysql/src/Io/LazyConnection.php on line 37
clue commented 2 years ago

@hasanparasteh Thanks for bringing this up!

I've just filed #150 with some minimal changes to add PHP 8.1 support for this project.

Currently, it only reports a deprecation notice because we pass a possible null value from a parse_url() call to parse_str(). As of PHP 8.1 this requires an explicit type cast, but the code continues to function just fine despite the deprecation notice. This means using the current code base on PHP 8.1 works fine as long as you ignore the deprecation notice (which would be the default).

Expect a release some time in the next couple of weeks :+1:

hasanparasteh commented 2 years ago

Thank you @clue. I'll be glad If there's anything that I can help to fix this issue or other things related to PHP 8.1 in your next release

clue commented 2 years ago

@hasanparasteh Thank you! Reporting issues is much appreciated and is always a good start to help us figure out what needs our attention.

We've intentionally designed our components to be both forward compatible and backward compatible as much as possible and have prepared PHP 8.1 in the past months, so fortunately addressing this one only required a minor change.

Happy to take a look if you find anything else that needs our attention :+1: