Skip to content

Regression: fsockopen/pfsockopen Reflection errno/errstr + defaults/return resource — Zend error_code/error_message untyped (ext/standard/basic_functions.stub.php) #28919

Closed

Description

@PurHur

Category

bug · php-src-strict · Reflection / named-args · pillar 4

Problem

fsockopen / pfsockopen Reflection diverges from Zend on parameter names, defaults, nullability, and return typing — so Zend-shaped named args (error_code, error_message) will not bind.

Probed 2026-08-08 @ 74acc15279.

Aspect Zend 8.2.32 VM
Signature (string $hostname, int $port = -1, &$error_code = null, &$error_message = null, ?float $timeout = null) untyped return (string $hostname, int $port = 0, int &$errno = 0, string &$errstr = ?, float $timeout = 0): resource
Port default -1 0
By-ref outs untyped $error_code / $error_message default null typed int &$errno / string &$errstr
Timeout ?float = null float = 0
Return untyped (resource|false at runtime) resource (omits |false)

php-src reference

PHP implementation target

  • ext/standard/fsockopen.php, ext/standard/pfsockopen.php — Internal arginfo names/defaults/returns
  • PHP-in-PHP; no new C

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/fsock_ref.php <<'"'"'PHP'"'"'
<?php
foreach (["fsockopen","pfsockopen"] as $n) {
  $r = new ReflectionFunction($n);
  foreach ($r->getParameters() as $p) {
    $def = "";
    if ($p->isOptional()) {
      try { $def = "=" . json_encode($p->getDefaultValue()); }
      catch (Throwable $e) { $def = "=?"; }
    }
    echo $n, " \$", $p->getName(),
      " type=", ($p->hasType() ? $p->getType() : "none"),
      " byref=", ($p->isPassedByReference() ? "y" : "n"),
      $def, "\n";
  }
  echo $n, " ret=", ($r->hasReturnType() ? $r->getReturnType() : "none"), "\n";
}
try {
  $errno = null; $errstr = null;
  fsockopen(hostname: "127.0.0.1", port: 1, error_code: $errno, error_message: $errstr, timeout: 0.1);
  echo "named ok\n";
} catch (Throwable $e) {
  echo get_class($e), ":", $e->getMessage(), "\n";
}
PHP
php bin/vm.php /tmp/fsock_ref.php
php /tmp/fsock_ref.php'

Done when

  • Param names are $error_code / $error_message; defaults match Zend (port=-1, by-ref null, ?float $timeout=null)
  • Return Reflection matches Zend (untyped, or documented resource|false if php-src moves)
  • Named error_code: / error_message: bind; errno/errstr names rejected like Zend
  • Compliance .phpt guard
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Aug 8, 2026
  2. PurHur commented on Aug 10, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #28842, #28919, #28483, #28520, #28557)

  3. PurHur commented on Aug 10, 2026

    @PurHur
    OwnerAuthor

    Merged via #29814

    Verification: PROFILE=8.4 repro → Zend-shaped names/defaults/untyped return; error_code:/error_message: bind; legacy errno rejected. PHPUnit OK (2 tests, 19 assertions).

    Next in batch: #28483 (fstat Reflection return).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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