Skip to content

Commit b65ab34

Browse files
committed
PassedParameters::getParameterFromStack(): add extra unit test
... documenting the behaviour when a non-existent parameter is requested.
1 parent d018e58 commit b65ab34

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Tests/Utils/PassedParameters/GetParameterFromStackTest.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public function testGetParameterFunctionCallPositionalMissingParamName()
108108
}
109109

110110
/**
111-
* Test retrieving the parameter details from a function call with only named parameters
112-
* without passing a valid name.
111+
* Test receiving an expected exception when trying to retrieve the parameter details
112+
* from a function call with only named parameters without passing a valid name.
113113
*
114114
* @return void
115115
*/
@@ -124,6 +124,24 @@ public function testGetParameterFunctionCallMissingParamName()
124124
PassedParameters::getParameter(self::$phpcsFile, $stackPtr, 2);
125125
}
126126

127+
/**
128+
* Test receiving an expected exception when trying to retrieve the parameter details
129+
* from a function call with only positional parameters without passing a valid name with
130+
* the requested parameter offset not being set.
131+
*
132+
* @return void
133+
*/
134+
public function testGetParameterFunctionCallPositionalMissingParamNameNonExistentParam()
135+
{
136+
$this->expectPhpcsException(
137+
'To allow for support for PHP 8 named parameters, the $paramNames parameter must be passed.'
138+
);
139+
140+
$stackPtr = $this->getTargetToken('/* testAllParamsPositional */', \T_STRING);
141+
142+
PassedParameters::getParameter(self::$phpcsFile, $stackPtr, 10);
143+
}
144+
127145
/**
128146
* Test retrieving the details for a specific parameter from a function call or construct.
129147
*

0 commit comments

Comments
 (0)