Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ext/sockets/socket_addrinfo_lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public function execute(Frame $frame): void
throw new \LogicException('socket_addrinfo_lookup() requires VM context');
}

$host = VmString::coerceTypedStringBuiltinArg($frame->calledArgs[0], 'socket_addrinfo_lookup', 0, 'host');
// Z_PARAM_STR — soft-null outside strict_types; strict → TypeError (#30337).
// userArgIndex is 0-based for Argument/parameter #N messages (same as socket_connect).
$host = VmString::stringBuiltinArgForFrame($frame, 0, 'socket_addrinfo_lookup', 0, 'host', false);
$service = null;
if ($argc >= 2) {
$service = VmString::coerceNullableStringBuiltinArg(
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
<file>./test/compliance/SocketErrorNullOptionalVMTest.php</file>
<file>./test/compliance/SocketBindSoftNullVMTest.php</file>
<file>./test/compliance/SocketConnectSoftNullVMTest.php</file>
<file>./test/compliance/SocketAddrinfoLookupSoftNullVMTest.php</file>
<file>./test/compliance/SocketSendtoSoftNullVMTest.php</file>
<file>./test/compliance/SocketWriteSoftNullVMTest.php</file>
<file>./test/compliance/SocketSendSoftNullVMTest.php</file>
Expand Down
30 changes: 30 additions & 0 deletions test/compliance/SocketAddrinfoLookupSoftNullVMTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

require_once __DIR__.'/../BaseTest.php';

/** VM: socket_addrinfo_lookup(null) soft-null + strict $host (#30337). */
final class SocketAddrinfoLookupSoftNullVMTest extends BaseTest
{
protected static string $DIR = __DIR__;

public static function providePHPTests(): \Generator
{
yield 'socket_addrinfo_lookup_soft_null.phpt' => self::parsePHPT(
__DIR__.'/cases/sockets/socket_addrinfo_lookup_soft_null.phpt',
'socket_addrinfo_lookup_soft_null.phpt'
);
yield 'socket_addrinfo_lookup_null_strict.phpt' => self::parsePHPT(
__DIR__.'/cases/sockets/socket_addrinfo_lookup_null_strict.phpt',
'socket_addrinfo_lookup_null_strict.phpt'
);
}

public function setUp(): void
{
$this->BIN = realpath(__DIR__.'/../../bin/vm.php');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
stdlib socket_addrinfo_lookup(null) TypeError under strict_types (#30337, ext/sockets/sockets.c)
--FILE--
<?php
declare(strict_types=1);
error_reporting(E_ALL);
try {
var_export(socket_addrinfo_lookup(null));
echo "\n";
} catch (Throwable $e) {
echo get_class($e), ':', $e->getMessage(), "\n";
}
--EXPECT--
TypeError:socket_addrinfo_lookup(): Argument #1 ($host) must be of type string, null given
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
stdlib socket_addrinfo_lookup(null) soft-null Deprecated+false (#30337, ext/sockets/sockets.c)
--FILE--
<?php
error_reporting(E_ALL);
try {
var_export(socket_addrinfo_lookup(null));
echo "\n";
} catch (Throwable $e) {
echo get_class($e), ':', $e->getMessage(), "\n";
}
--EXPECTF--
PHP Deprecated: socket_addrinfo_lookup(): Passing null to parameter #1 ($host) of type string is deprecated in %s on line %d
false
13 changes: 13 additions & 0 deletions test/repro/issue_30337_socket_addrinfo_lookup_soft_null.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/**
* Repro #30337 — socket_addrinfo_lookup(null) soft-null: Deprecated + false.
* php-src: ext/sockets/sockets.c PHP_FUNCTION(socket_addrinfo_lookup)
*/
error_reporting(E_ALL);
try {
var_export(socket_addrinfo_lookup(null));
echo "\n";
} catch (Throwable $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
Loading