Skip to content

Stdlib: implement stream_isatty() with VM + JIT/AOT lowering (#6035) - #7549

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-stream-isatty-6035
Jun 7, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-stream-isatty-6035

Conversation

@PurHur

@PurHur PurHur commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements stream_isatty() per php-src ext/standard/streamsfuncs.c — TTY detection for stream resources
  • PHP implementation in ext/standard/stream_isatty.php + VmFs::streamIsatty(); thin C ABI __compiler_stream_isatty in phpc_stream.c using isatty(fileno(fp)) for AOT/JIT
  • Enum case and non-resource operands throw TypeError via shared VmStreamArg::requireStreamHandle guards (php-src-strict)

Closes #6035

php-src reference

  • ext/standard/streamsfuncs.c — PHP_FUNCTION(stream_isatty)
  • main/streams/php_stream.c — php_stream_isatty()

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter stream_isatty'
# OK (5 tests, 5 assertions) — VM + JIT + AOT compliance PHPTs

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/stream_isatty_6035.php'
# 1\n0

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/compile.php -l test/repro/stream_isatty_6035.php'
# OK (AOT lint)

Test plan

  • stream_isatty.phpt — function_exists + false on php://memory and plainfile
  • stream_isatty_enum_typeerror.phpt — enum case → TypeError naming enum class
  • stream_isatty_typeerror.phpt — array operand → TypeError
  • Capability matrix updated (stream_isatty | yes | yes | yes)

Made with Cursor

Add stream_isatty() via VmFs::streamIsatty and thin __compiler_stream_isatty
C ABI (isatty/fileno) so TTY detection works on native AOT paths, not VM-only.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 1a0b5e4 into master Jun 7, 2026
@PurHur
PurHur deleted the agent/stdlib-stream-isatty-6035 branch June 7, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: stream_isatty() — TTY detection for stream resources missing (ext/standard/streamsfuncs.c)

1 participant