Skip to content

Commit

Permalink
Update Socket.php (#156)
Browse files Browse the repository at this point in the history
On PHP >= 8.1 this throws a TypeError
```
Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in .\vendor\xpaw\php-source-query-class\SourceQuery\Socket.php:32
```

Because a failed connection server sets this to boolean false. Better to check if the parameter passed to `fclose()` is an actual resource/stream.
  • Loading branch information
Hackmastr authored Dec 26, 2022
1 parent f38c42b commit ce9c8f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion SourceQuery/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Socket extends BaseSocket
{
public function Close( ) : void
{
if( $this->Socket !== null )
if( is_resource($this->Socket) )
{
fclose( $this->Socket );

Expand Down

0 comments on commit ce9c8f4

Please sign in to comment.