Skip to content

Stdlib: phpversion() / php_uname() / php_sapi_name() — runtime introspection (ext/standard parity) #3174

Description

@PurHur

Category

stdlib (runtime introspection)

Problem

Core runtime identity functions are missing:

  • phpversion(?string $extension = null): string
  • php_uname(string $mode = "a"): string
  • php_sapi_name(): string

Bootstrap and deployment scripts often gate on SAPI name or report compiler version. None are registered in ext/standard/Module.php.

php-src reference

  • ext/standard/info.c — PHP_FUNCTION(phpversion), PHP_FUNCTION(php_uname), PHP_FUNCTION(php_sapi_name)
  • main/php_version.h — PHP_VERSION

Repro

./script/docker-exec.sh -- bash -lc '
for f in phpversion php_uname php_sapi_name; do
  php bin/vm.php -r "echo \$f, \"=\", function_exists(\"\$f\") ? 1 : 0, \"\\n\";"
done
'
# all 0

php -r 'echo phpversion(), "\n", php_sapi_name(), "\n";'

Scope (this repo)

Area Files
Builtins ext/standard/phpversion.php, php_uname.php, php_sapi_name.php
Constants PHP_VERSION, PHP_SAPI compile-time or runtime strings in lib/Runtime.php / VM bootstrap
Register ext/standard/Module.php
Tests test/compliance/cases/stdlib/phpversion.phpt

Done when

  • phpversion() returns a string identifying this compiler build (may differ from Zend — document format, e.g. phpc-0.x).
  • php_sapi_name() returns cli for bin/vm.php / AOT CLI entry (match Zend for same entrypoint).
  • php_uname('s') returns non-empty OS identifier; full 'a' mode matches Zend shape (fields documented if subset).
  • All three function_exists true on VM.

Notes

Activity

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 machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions