From e056e2dae900775a4a8694279a2d92dedf3e65cd Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Sun, 23 Aug 2020 10:46:40 -0400 Subject: [PATCH] Check for duplicate names in gen_stub.php With named arguments in php 8.0, it's important that php's modules or PECL extensions using gen_stub.php don't generate functions with duplicate names. Warn if a parameter name is repeated, even if the last occurrence is a variadic parameter Closes GH-6035 --- build/gen_stub.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/gen_stub.php b/build/gen_stub.php index fb79255e84..214d1f563e 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -646,6 +646,7 @@ function parseFunctionLike( } } + $varNameSet = []; $args = []; $numRequiredArgs = 0; $foundVariadic = false; @@ -654,6 +655,11 @@ function parseFunctionLike( $preferRef = !empty($paramMeta[$varName]['preferRef']); unset($paramMeta[$varName]); + if (isset($varNameSet[$varName])) { + throw new Exception("Duplicate parameter name $varName for function $name"); + } + $varNameSet[$varName] = true; + if ($preferRef) { $sendBy = ArgInfo::SEND_PREFER_REF; } else if ($param->byRef) { -- 2.40.0