Skip to content

Commit

Permalink
try fix for php 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 25, 2024
1 parent bbdfcb4 commit 48a48c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Type/Php/SocketCreateReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use PHPStan\Type\ResourceType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Socket;
use function count;

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

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

if ($scope->getPhpVersion()->socketCreateUsesResource()->yes()) {
Expand Down
6 changes: 4 additions & 2 deletions tests/PHPStan/Analyser/nsrt/socket-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public function sayHello(): void
{
if (PHP_VERSION_ID < 80000) {
assertType('resource|false', socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));
return;
}
assertType('Socket|false', socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));

if (PHP_VERSION_ID >= 80000) {
assertType('Socket|false', socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));
}
}
}

0 comments on commit 48a48c8

Please sign in to comment.