diff --git a/lib/BuiltinInternalArgInfo.php b/lib/BuiltinInternalArgInfo.php index 788fe00539e..5deb7132b82 100644 --- a/lib/BuiltinInternalArgInfo.php +++ b/lib/BuiltinInternalArgInfo.php @@ -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) @@ -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) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 86858364b3f..946288549b5 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -111,6 +111,7 @@ ./test/compliance/StreamIsattyReflectionVMTest.php ./test/compliance/StreamSelectReflectionVMTest.php ./test/compliance/StreamSocketClientReflectionVMTest.php + ./test/compliance/StreamSocketServerReflectionVMTest.php ./test/compliance/TriggerErrorUserErrorReflectionVMTest.php ./test/compliance/TriggerErrorUserErrorHandledVMTest.php ./test/compliance/TriggerErrorUserErrorHandledJITTest.php diff --git a/test/compliance/StreamSocketServerReflectionVMTest.php b/test/compliance/StreamSocketServerReflectionVMTest.php new file mode 100644 index 00000000000..612a8d85789 --- /dev/null +++ b/test/compliance/StreamSocketServerReflectionVMTest.php @@ -0,0 +1,27 @@ + self::parsePHPT( + __DIR__.'/cases/stdlib/'.$file, + $file + ); + } + + public function setUp(): void + { + $this->BIN = realpath(__DIR__.'/../../bin/vm.php'); + } +} diff --git a/test/compliance/cases/stdlib/stream_socket_server_reflection_28857.phpt b/test/compliance/cases/stdlib/stream_socket_server_reflection_28857.phpt new file mode 100644 index 00000000000..294c69aedb5 --- /dev/null +++ b/test/compliance/cases/stdlib/stream_socket_server_reflection_28857.phpt @@ -0,0 +1,23 @@ +--TEST-- +stdlib stream_socket_server Reflection untyped error outs + no return (#28857, streamsfuncs.stub.php) +--FILE-- +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 diff --git a/test/repro/issue_28857_stream_socket_server_reflection.php b/test/repro/issue_28857_stream_socket_server_reflection.php new file mode 100644 index 00000000000..570653c8eb0 --- /dev/null +++ b/test/repro/issue_28857_stream_socket_server_reflection.php @@ -0,0 +1,7 @@ +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; diff --git a/test/unit/BuiltinParamNamesAliasTest.php b/test/unit/BuiltinParamNamesAliasTest.php index b67b50208b2..d7c9d189de2 100644 --- a/test/unit/BuiltinParamNamesAliasTest.php +++ b/test/unit/BuiltinParamNamesAliasTest.php @@ -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 {