Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket address of closed socket should be null (support PHP 8) #246

Merged
merged 1 commit into from
Aug 24, 2020

Conversation

clue
Copy link
Member

@clue clue commented Aug 24, 2020

The previous code works just fine on PHP 7 and older. PHP 8 adds
stricter type checks for closed socket resources, so the underlying
function now throws a TypeError. This can be avoided by first checking
if the socket resource is still valid (not closed). This works across
all PHP versions and also helps with avoiding some uneeded error
suppression operators.

This means this component now supports PHP 8 just fine 馃帀

~/workspace/reactphp-socket$ docker run -it --rm -v `pwd`:/data --workdir /data php:8.0.0beta1-cli php -d memory_limit=-1 vendor/bin/phpunit                                          
PHPUnit 9.3.7 by Sebastian Bergmann and contributors.                                                                                                                                          
                                                                                                                                                                                               
....................................S..........................  63 / 304 ( 20%)                                                                                                               
..........SSS.................................................. 126 / 304 ( 41%)                                                                                                               
............................................................... 189 / 304 ( 62%)                                                                                                               
..........................................................S.... 252 / 304 ( 82%)                                                                                                               
....................................................            304 / 304 (100%)                                                                                                               
                                                                                                                                                                                               
Time: 00:08.058, Memory: 628.00 MB                                                                                                                                                             
                                                                                                                                                                                               
OK, but incomplete, skipped, or risky tests!                                                                                                                                                   
Tests: 304, Assertions: 641, Skipped: 5.

This PR does not currently include PHP 8 in the Travis test matrix. PHP is scheduled to be released in November, I'll file a follow-up PR once it's available for installation on Travis.

Builds on top of #243 and #244

The previous code works just fine on PHP 7 and older. PHP 8 adds
stricter type checks for closed socket resources, so the underlying
function now throws a `TypeError`. This can be avoided by first checking
if the socket resource is still valid (not closed). This works across
all PHP versions and also helps with avoiding some uneeded error
suppression operators.
@clue clue added this to the v1.6.0 milestone Aug 24, 2020
@clue clue requested review from WyriHaximus and jsor August 24, 2020 19:27
@clue clue added the easy pick label Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants