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
7 changes: 7 additions & 0 deletions lib/BuiltinInternalArgInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public static function stubReturnTypeLabelForFunction(string $callableLc): ?stri
'stream_context_create' => '',
// ext/standard/streamsfuncs.stub.php — no return type; InternalArgInfo says resource (#27848)
'stream_socket_client' => '',
// ext/standard/streamsfuncs.stub.php — no return type; InternalArgInfo says resource (#28857)
'stream_socket_server' => '',
// ext/standard/proc_open.stub.php — no return type; InternalArgInfo says resource (#27847)
'proc_open' => '',
// ext/standard/streamsfuncs.stub.php — InternalArgInfo return int (missing |bool) (#27684)
Expand Down Expand Up @@ -985,6 +987,11 @@ public static function stubParamTypeOverride(string $callableLc, int $index): ?s
3 => '?float',
default => null,
},
// ext/standard/streamsfuncs.stub.php — untyped &$error_* outs (#28857)
'stream_socket_server' => match ($index) {
1, 2 => '',
default => null,
},
// ext/standard/file.stub.php — ?int $length = null (#24826)
'fgetcsv' => 1 === $index ? '?int' : null,
// ext/standard/file.stub.php — string $eol = "\n" (missing from InternalArgInfo) (#25135)
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<file>./test/compliance/StreamIsattyReflectionVMTest.php</file>
<file>./test/compliance/StreamSelectReflectionVMTest.php</file>
<file>./test/compliance/StreamSocketClientReflectionVMTest.php</file>
<file>./test/compliance/StreamSocketServerReflectionVMTest.php</file>
<file>./test/compliance/TriggerErrorUserErrorReflectionVMTest.php</file>
<file>./test/compliance/TriggerErrorUserErrorHandledVMTest.php</file>
<file>./test/compliance/TriggerErrorUserErrorHandledJITTest.php</file>
Expand Down
27 changes: 27 additions & 0 deletions test/compliance/StreamSocketServerReflectionVMTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

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

/** VM compliance for stream_socket_server() Reflection stub types (#28857). */
final class StreamSocketServerReflectionVMTest extends BaseTest
{
protected static string $DIR = __DIR__;

public static function providePHPTests(): \Generator
{
$file = 'stream_socket_server_reflection_28857.phpt';
yield $file => self::parsePHPT(
__DIR__.'/cases/stdlib/'.$file,
$file
);
}

public function setUp(): void
{
$this->BIN = realpath(__DIR__.'/../../bin/vm.php');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
stdlib stream_socket_server Reflection untyped error outs + no return (#28857, streamsfuncs.stub.php)
--FILE--
<?php
$r = new ReflectionFunction('stream_socket_server');
foreach ($r->getParameters() as $p) {
echo $p->getName(), ':', $p->hasType() ? (string) $p->getType() : 'none', $p->isPassedByReference() ? '&' : '', $p->isOptional() ? '?' : '', PHP_EOL;
}
echo 'ret=', $r->hasReturnType() ? (string) $r->getReturnType() : 'none', PHP_EOL;
// client sibling must stay Zend-aligned (#27848)
$c = new ReflectionFunction('stream_socket_client');
echo 'client_ret=', $c->hasReturnType() ? (string) $c->getReturnType() : 'none', PHP_EOL;
echo 'client_ec=', $c->getParameters()[1]->hasType() ? (string) $c->getParameters()[1]->getType() : 'none', PHP_EOL;
?>
--EXPECT--
address:string
error_code:none&?
error_message:none&?
flags:int?
context:none?
ret=none
client_ret=none
client_ec=none
7 changes: 7 additions & 0 deletions test/repro/issue_28857_stream_socket_server_reflection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/** Issue #28857 — stream_socket_server Reflection: untyped error outs, no return (match Zend stubs). */
$r = new ReflectionFunction('stream_socket_server');
foreach ($r->getParameters() as $p) {
echo $p->getName(), ':', $p->hasType() ? (string) $p->getType() : 'none', $p->isPassedByReference() ? '&' : '', $p->isOptional() ? '?' : '', PHP_EOL;
}
echo 'ret=', $r->hasReturnType() ? (string) $r->getReturnType() : 'none', PHP_EOL;
12 changes: 12 additions & 0 deletions test/unit/BuiltinParamNamesAliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5375,6 +5375,18 @@ public function testStreamSocketClientStubReturnAndErrorOutTypes(): void
self::assertNull(BuiltinInternalArgInfo::stubParamTypeOverride('stream_socket_client', 0));
}

/** @covers issue #28857 */
public function testStreamSocketServerStubReturnAndErrorOutTypes(): void
{
self::assertNull(
BuiltinInternalArgInfo::returnTypeLabelForFunction('stream_socket_server')
);
self::assertSame('', BuiltinInternalArgInfo::stubParamTypeOverride('stream_socket_server', 1));
self::assertSame('', BuiltinInternalArgInfo::stubParamTypeOverride('stream_socket_server', 2));
self::assertNull(BuiltinInternalArgInfo::stubParamTypeOverride('stream_socket_server', 0));
self::assertNull(BuiltinInternalArgInfo::stubParamTypeOverride('stream_socket_server', 3));
}

/** @covers issue #25845 */
public function testHashHkdfStubReturnAndStreamContextSetOptionSignature(): void
{
Expand Down
Loading