Skip to content

Regression: socket_write(..., null) soft TypeError — Zend Deprecated+Warning+false (ext/sockets/sockets.c) #30320

Description

@PurHur

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

  • Soft socket_write($s, null) matches Zend Deprecated + Warning + false
  • Strict_types still TypeErrors
  • Compliance/repro guard
  • php-src-strict

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions