-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix socket_select array types after call
- Loading branch information
1 parent
b2177e3
commit 24c5249
Showing
9 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\PhpDoc; | ||
|
||
use PHPStan\Php\PhpVersion; | ||
|
||
class SocketSelectStubFilesExtension implements StubFilesExtension | ||
{ | ||
|
||
public function __construct(private PhpVersion $phpVersion) | ||
{ | ||
} | ||
|
||
public function getFiles(): array | ||
{ | ||
if ($this->phpVersion->getVersionId() >= 80000) { | ||
return [__DIR__ . '/../../stubs/socket_select_php8.stub']; | ||
} | ||
|
||
return [__DIR__ . '/../../stubs/socket_select.stub']; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* @param array<resource>|null &$read | ||
* @param array<resource>|null &$write | ||
* @param array<resource>|null &$except | ||
* @param-out ($read is not null ? array<resource> : null) $read | ||
* @param-out ($write is not null ? array<resource> : null) $write | ||
* @param-out ($except is not null ? array<resource> : null) $except | ||
*/ | ||
function socket_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, int $microseconds = 0): int|false {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* @param array<Socket>|null &$read | ||
* @param array<Socket>|null &$write | ||
* @param array<Socket>|null &$except | ||
* @param-out ($read is not null ? array<Socket> : null) $read | ||
* @param-out ($write is not null ? array<Socket> : null) $write | ||
* @param-out ($except is not null ? array<Socket> : null) $except | ||
*/ | ||
function socket_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, int $microseconds = 0): int|false {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Discussion10285Php8; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(): void | ||
{ | ||
$socket = socket_create(AF_INET, SOCK_STREAM, 0); | ||
if($socket === false) return; | ||
$read = [$socket]; | ||
$write = []; | ||
$except = null; | ||
socket_select($read, $write, $except, 0, 1); | ||
assertType('array<Socket>', $read); | ||
assertType('array<Socket>', $write); | ||
assertType('null', $except); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Discussion10285; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(): void | ||
{ | ||
$socket = socket_create(AF_INET, SOCK_STREAM, 0); | ||
if($socket === false) return; | ||
$read = [$socket]; | ||
$write = []; | ||
$except = null; | ||
socket_select($read, $write, $except, 0, 1); | ||
assertType('array<resource>', $read); | ||
assertType('array<resource>', $write); | ||
assertType('null', $except); | ||
} | ||
} |