Category
stdlib · php-src-strict
Problem
Under declare(strict_types=1), get_browser($user_agent = null, $return_array = null) must TypeError on bool $return_array. Zend accepts null $user_agent (optional) and TypeErrors on null $return_array. VM soft-deprecates (message even cites parameter #1 ($return_array)), warns that browscap is unset, and returns false.
| Repro |
Zend 8.2.32 (2026-08-15) |
VM (2026-08-15) |
declare(strict_types=1); get_browser(null, null) |
TypeError: get_browser(): Argument #2 ($return_array) must be of type bool, null given |
E_DEPRECATED (param #1 ($return_array)) + browscap warning + false |
php-src reference
PHP implementation target
Repro
./script/docker-exec.sh -- bash -lc 'php -r '\''declare(strict_types=1); try { var_export(get_browser(null, null)); } catch (Throwable $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; }'\'''
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '\''declare(strict_types=1); try { var_export(get_browser(null, null)); } catch (Throwable $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; }'\'''
Done when
Category
stdlib· php-src-strictProblem
Under
declare(strict_types=1),get_browser($user_agent = null, $return_array = null)must TypeError on bool$return_array. Zend accepts null$user_agent(optional) and TypeErrors on null$return_array. VM soft-deprecates (message even cites parameter#1 ($return_array)), warns that browscap is unset, and returnsfalse.declare(strict_types=1); get_browser(null, null)TypeError: get_browser(): Argument #2 ($return_array) must be of type bool, null givenE_DEPRECATED(param#1 ($return_array)) + browscap warning +falsephp-src reference
ext/standard/browscap.c—PHP_FUNCTION(get_browser)/php_get_browserext/standard/basic_functions.stub.php—get_browser(?string $user_agent = null, bool $return_array = false)PHP implementation target
ext/standard/get_browser.php—VmMath::parseBoolBuiltinArgfor arg Php stdlib specs implementation #2 must TypeError under strict_types; fix deprecation index/name if soft path remainslib/JIT/Builtin/GetBrowserRuntime.php/ GetBrowser JIT helper — same behaviorbrowser_namevsuser_agentremains Regression: get_browser Reflection names browser_name — Zend user_agent; named args rejected (ext/standard/basic_functions.stub.php) #23382 (out of scope unless free)Repro
Done when
$return_arrayunder strict_types → ZendTypeError(no browscap warning /false)$user_agentalone still allowed (Zend optional).phptundertest/compliance/cases/stdlib/