Category
Regression · php-src-strict · stdlib socket_write() soft-null $data
Problem
Without declare(strict_types=1), Zend emits E_DEPRECATED for null $data, then a write Warning (broken pipe on unbound socket) and returns false. VM rejects with hard TypeError.
Sibling soft-null pattern of #30316 / socket_sendto; distinct from closed baseline #19286 / Reflection #24373.
| Repro (2026-08-11, Zend 8.2.32 / master VM) |
Zend 8.2 |
VM |
$s=socket_create(AF_INET,SOCK_STREAM,SOL_TCP); socket_write($s, null); |
Deprecated + Warning: unable to write… + false |
TypeError: Argument #2 ($data) must be of type string, null given |
php-src reference
PHP implementation target
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/socket_write_soft_null.php <<'"'"'PHP'"'"'
<?php
error_reporting(E_ALL);
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
try {
var_export(socket_write($s, null));
echo "\n";
} catch (Throwable $e) {
echo get_class($e), ": ", $e->getMessage(), "\n";
}
PHP
php /tmp/socket_write_soft_null.php
php bin/vm.php /tmp/socket_write_soft_null.php'
Done when
Category
Regression· php-src-strict · stdlibsocket_write()soft-null$dataProblem
Without
declare(strict_types=1), Zend emitsE_DEPRECATEDfornull$data, then a writeWarning(broken pipe on unbound socket) and returnsfalse. VM rejects with hardTypeError.Sibling soft-null pattern of #30316 / socket_sendto; distinct from closed baseline #19286 / Reflection #24373.
$s=socket_create(AF_INET,SOCK_STREAM,SOL_TCP); socket_write($s, null);Deprecated+Warning: unable to write…+falseTypeError: Argument #2 ($data) must be of type string, null givenphp-src reference
ext/sockets/sockets.stub.php—socket_write(Socket $socket, string $data, ?int $length = null): int|falseext/sockets/sockets.c—PHP_FUNCTION(socket_write)/Z_PARAM_STRPHP implementation target
ext/sockets/socket_write.php— soft-null via frame-aware string coerce (same as Regression: socket_connect(..., null) soft TypeError — Zend Deprecated+Warning+false (ext/sockets/sockets.c) #30316)ext/sockets/socket_send.phplikely same$dataover-strict (file separately if still red after this)Repro
Done when
socket_write($s, null)matches Zend Deprecated + Warning +false