Skip to content

Commit 48a48c8

Browse files
committed
try fix for php 7.4
1 parent bbdfcb4 commit 48a48c8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Type/Php/SocketCreateReturnTypeExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PHPStan\Type\ResourceType;
1212
use PHPStan\Type\Type;
1313
use PHPStan\Type\UnionType;
14-
use Socket;
1514
use function count;
1615

1716
final class SocketCreateReturnTypeExtension implements DynamicFunctionReturnTypeExtension
@@ -29,7 +28,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
2928
}
3029

3130
if ($scope->getPhpVersion()->socketCreateUsesResource()->no()) {
32-
return new UnionType([new ConstantBooleanType(false), new ObjectType(Socket::class)]);
31+
return new UnionType([new ConstantBooleanType(false), new ObjectType('\\Socket')]);
3332
}
3433

3534
if ($scope->getPhpVersion()->socketCreateUsesResource()->yes()) {

tests/PHPStan/Analyser/nsrt/socket-create.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ public function sayHello(): void
1212
{
1313
if (PHP_VERSION_ID < 80000) {
1414
assertType('resource|false', socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));
15-
return;
1615
}
17-
assertType('Socket|false', socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));
16+
17+
if (PHP_VERSION_ID >= 80000) {
18+
assertType('Socket|false', socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));
19+
}
1820
}
1921
}

0 commit comments

Comments
 (0)