Bug #80387 [NEW]: Wrong behaviour of func_(num|get)_arg(s) functions with named arguments

From: Date: Fri, 20 Nov 2020 13:36:25 +0000
Subject: Bug #80387 [NEW]: Wrong behaviour of func_(num|get)_arg(s) functions with named arguments
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230476@lists.php.net to get a copy of this message
From:             s dot danilchenko at ttbooking dot ru
Operating system: Windows 10
PHP version:      8.0.0RC5
Package:          *General Issues
Bug Type:         Bug
Bug description:Wrong behaviour of func_(num|get)_arg(s) functions with named arguments

Description:
------------
Function cannot fetch its arguments with func_* functions after last one
passed by its name.

Test script:
---------------
function test_func($arg1 = 'a', $arg2 = 'b', $arg3 = 'c', $arg4 =
'd')
{
    return json_encode([
        'func_num_args' => func_num_args(),
        'func_get_args' => func_get_args(),
        'direct_args' => [$arg1, $arg2, $arg3, $arg4],
    ], JSON_PRETTY_PRINT);
}

echo test_func(arg1: 'hello', arg3: 'world');


Expected result:
----------------
{
    "func_num_args": 4,
    "func_get_args": [
        "hello",
        "b",
        "world",
        "d"
    ],
    "direct_args": [
        "hello",
        "b",
        "world",
        "d"
    ]
}

Actual result:
--------------
{
    "func_num_args": 3,
    "func_get_args": [
        "hello",
        "b",
        "world"
    ],
    "direct_args": [
        "hello",
        "b",
        "world",
        "d"
    ]
}

-- 
Edit bug report at https://bugs.php.net/bug.php?id=80387&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80387&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80387&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80387&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80387&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80387&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80387&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80387&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80387&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80387&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80387&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80387&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80387&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80387&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80387&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80387&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80387&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80387&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#230476) next »