Skip to content

Commit

Permalink
Merge pull request #597 from PHPCSStandards/feature/various-minor-fixes
Browse files Browse the repository at this point in the history
Various documentation fixes
  • Loading branch information
jrfnl authored May 13, 2024
2 parents 60a360c + 9198d63 commit 8c577be
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 106 deletions.
2 changes: 1 addition & 1 deletion PHPCSUtils/TestUtils/UtilityMethodTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
* *
* * @return array
* * /
* public function dataMyMethod()
* public static function dataMyMethod()
* {
* return array(
* array('/* testTestCaseDescription * /', false),
Expand Down
2 changes: 1 addition & 1 deletion PHPCSUtils/Utils/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static function inForCondition(File $phpcsFile, $stackPtr)
if ($tokens[$i]['level'] !== $level
|| \count($tokens[$i]['nested_parenthesis']) !== $parens
) {
// Disregard semi-colons at lower nesting/condition levels.
// Disregard semicolons at lower nesting/condition levels.
continue;
}

Expand Down
7 changes: 3 additions & 4 deletions PHPCSUtils/Utils/PassedParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ final class PassedParameters
*
* - If passed a `T_STRING`, `T_NAME_FULLY_QUALIFIED`, `T_NAME_RELATIVE`, `T_NAME_QUALIFIED`,
* or `T_VARIABLE` stack pointer, it will treat it as a function call.
* If a `T_STRING` or `T_VARIABLE` which is *not* a function call is passed, the behaviour is
* undetermined.
* If a token which is *not* a function call is passed, the behaviour is undetermined.
* - If passed a `T_ANON_CLASS` stack pointer, it will accept it as a class instantiation.
* - If passed a `T_SELF`, `T_STATIC` or `T_PARENT` stack pointer, it will accept it as a
* class instantiation function call when used like `new self()` (with or without parenthesis).
* When these hierarchiecal keywords are not preceded by the `new` keyword, parenthesis
* class instantiation function call when used like `new self()` (with or without parentheses).
* When these hierarchiecal keywords are not preceded by the `new` keyword, parentheses
* will be required for the token to be accepted.
* - If passed a `T_ARRAY` or `T_OPEN_SHORT_ARRAY` stack pointer, it will detect
* whether the array has values or is empty.
Expand Down
15 changes: 8 additions & 7 deletions Tests/Utils/Lists/GetAssignmentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function testNonExistentToken()
*
* @dataProvider dataNotListToken
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string|array $targetToken The token type(s) to look for.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string $targetToken The token type(s) to look for.
*
* @return void
*/
Expand All @@ -60,7 +60,7 @@ public function testNotListToken($testMarker, $targetToken)
*
* @see testNotListToken() For the array format.
*
* @return array
* @return array<string, array<string, int|string>>
*/
public static function dataNotListToken()
{
Expand All @@ -81,9 +81,10 @@ public static function dataNotListToken()
*
* @dataProvider dataGetAssignments
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string|array $targetToken The token type(s) to look for.
* @param array|false $expected The expected function return value.
* @param string $testMarker The comment which prefaces the target token
* in the test file.
* @param int|string $targetToken The token type(s) to look for.
* @param array<int, array<string, int|string|bool>> $expected The expected function return value.
*
* @return void
*/
Expand Down Expand Up @@ -124,7 +125,7 @@ public function testGetAssignments($testMarker, $targetToken, $expected)
*
* @see testGetAssignments() For the array format.
*
* @return array
* @return array<string, array<string, int|string|array<int, array<string, int|string|bool>>>>
*/
public static function dataGetAssignments()
{
Expand Down
22 changes: 11 additions & 11 deletions Tests/Utils/MessageHelper/AddMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ final class AddMessageTest extends UtilityMethodTestCase
* @dataProvider dataAddMessage
* @covers ::addMessage
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param bool $isError Whether to test adding an error or a warning.
* @param array $expected Expected error details.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param bool $isError Whether to test adding an error or a warning.
* @param array<string, bool|string> $expected Expected error details.
*
* @return void
*/
Expand Down Expand Up @@ -82,7 +82,7 @@ public function testAddMessage($testMarker, $isError, $expected)
*
* @see testAddMessage() For the array format.
*
* @return array
* @return array<string, array<string, bool|string|array<string, bool|string>>>
*/
public static function dataAddMessage()
{
Expand Down Expand Up @@ -114,9 +114,9 @@ public static function dataAddMessage()
* @dataProvider dataAddFixableMessage
* @covers ::addFixableMessage
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param bool $isError Whether to test adding an error or a warning.
* @param array $expected Expected error details.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param bool $isError Whether to test adding an error or a warning.
* @param array<string, bool|string> $expected Expected error details.
*
* @return void
*/
Expand Down Expand Up @@ -148,7 +148,7 @@ public function testAddFixableMessage($testMarker, $isError, $expected)
*
* @see testAddFixableMessage() For the array format.
*
* @return array
* @return array<string, array<string, bool|string|array<string, bool|string>>>
*/
public static function dataAddFixableMessage()
{
Expand Down Expand Up @@ -177,9 +177,9 @@ public static function dataAddFixableMessage()
/**
* Helper method to verify the expected message details.
*
* @param int $stackPtr The stack pointer on which the error/warning is expected.
* @param bool $isError Whether to test adding an error or a warning.
* @param array $expected Expected error details.
* @param int $stackPtr The stack pointer on which the error/warning is expected.
* @param bool $isError Whether to test adding an error or a warning.
* @param array<string, bool|int|string> $expected Expected error details.
*
* @return void
*/
Expand Down
50 changes: 25 additions & 25 deletions Tests/Utils/Parentheses/ParenthesesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ public function testFunctionNamedFnKeywordNotParenthesesOwner()
*
* @dataProvider dataWalkParentheses
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Expected function output for the various functions.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, int|false> $expectedResults Expected function output for the various functions.
*
* @return void
*/
Expand Down Expand Up @@ -456,8 +456,8 @@ public function testGetFirstOpener($testName, $expectedResults)
*
* @dataProvider dataWalkParentheses
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Expected function output for the various functions.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, int|false> $expectedResults Expected function output for the various functions.
*
* @return void
*/
Expand Down Expand Up @@ -487,8 +487,8 @@ public function testGetFirstCloser($testName, $expectedResults)
*
* @dataProvider dataWalkParentheses
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Expected function output for the various functions.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, int|false> $expectedResults Expected function output for the various functions.
*
* @return void
*/
Expand Down Expand Up @@ -518,8 +518,8 @@ public function testGetFirstOwner($testName, $expectedResults)
*
* @dataProvider dataWalkParentheses
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Expected function output for the various functions.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, int|false> $expectedResults Expected function output for the various functions.
*
* @return void
*/
Expand Down Expand Up @@ -549,8 +549,8 @@ public function testGetLastOpener($testName, $expectedResults)
*
* @dataProvider dataWalkParentheses
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Expected function output for the various functions.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, int|false> $expectedResults Expected function output for the various functions.
*
* @return void
*/
Expand Down Expand Up @@ -580,8 +580,8 @@ public function testGetLastCloser($testName, $expectedResults)
*
* @dataProvider dataWalkParentheses
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Expected function output for the various functions.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, int|false> $expectedResults Expected function output for the various functions.
*
* @return void
*/
Expand Down Expand Up @@ -616,7 +616,7 @@ public function testGetLastOwner($testName, $expectedResults)
* @see testGetLastCloser() For the array format.
* @see testGetLastOwner() For the array format.
*
* @return array
* @return array<string, array<string, string|array<string, int|false>>>
*/
public static function dataWalkParentheses()
{
Expand Down Expand Up @@ -937,9 +937,9 @@ public static function dataWalkParentheses()
*
* @dataProvider dataHasOwner
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $expectedResults Array with the owner token type to search for as key
* and the expected result as a value.
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<string, true> $expectedResults Array with the owner token type to search for as key
* and the expected result as a value.
*
* @return void
*/
Expand Down Expand Up @@ -969,7 +969,7 @@ public function testHasOwner($testName, $expectedResults)
*
* @see testHasOwner() For the array format.
*
* @return array
* @return array<string, array<string, string|array<string, true>>>
*/
public static function dataHasOwner()
{
Expand Down Expand Up @@ -1191,9 +1191,9 @@ public function testHasOwnerMultipleTypes()
*
* @dataProvider dataFirstOwnerIn
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $validOwners Valid owners to test against.
* @param int|false $expected Expected function output
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<int|string> $validOwners Valid owners to test against.
* @param int|false $expected Expected function output
*
* @return void
*/
Expand All @@ -1213,7 +1213,7 @@ public function testFirstOwnerIn($testName, $validOwners, $expected)
*
* @see testFirstOwnerIn() For the array format.
*
* @return array
* @return array<string, array<string, int|string|array<int|string>|false>>
*/
public static function dataFirstOwnerIn()
{
Expand Down Expand Up @@ -1282,9 +1282,9 @@ public static function dataFirstOwnerIn()
*
* @dataProvider dataLastOwnerIn
*
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array $validOwners Valid owners to test against.
* @param int|false $expected Expected function output
* @param string $testName The name of this test as set in the cached $testTokens array.
* @param array<int|string> $validOwners Valid owners to test against.
* @param int|false $expected Expected function output
*
* @return void
*/
Expand All @@ -1304,7 +1304,7 @@ public function testLastOwnerIn($testName, $validOwners, $expected)
*
* @see testLastOwnerIn() For the array format.
*
* @return array
* @return array<string, array<int|string|array<int|string>|false>>
*/
public static function dataLastOwnerIn()
{
Expand Down
19 changes: 10 additions & 9 deletions Tests/Utils/PassedParameters/GetParameterFromStackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ public static function dataGetParameterFunctionCallWithParamName()
*
* @dataProvider dataGetParameterFromStack
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param array $expectedName The expected result array for the $name parameter.
* @param array|false $expectedExpires The expected result array for the $expires_or_options parameter.
* @param array|false $expectedHttpOnly The expected result array for the $httponly parameter.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param array<string, int|string>|false $expectedName The expected result array for the $name parameter.
* @param array<string, int|string>|false $expectedExpires The expected result array for the $expires_or_options
* parameter.
* @param array<string, int|string>|false $expectedHttpOnly The expected result array for the $httponly parameter.
*
* @return void
*/
Expand Down Expand Up @@ -280,7 +281,7 @@ public function testGetParameterFromStack($testMarker, $expectedName, $expectedE
*
* @see testGetParameterFromStack() For the array format.
*
* @return array
* @return array<string, array<string, string|array<string, int|string>|false>>
*/
public static function dataGetParameterFromStack()
{
Expand Down Expand Up @@ -413,9 +414,9 @@ public static function dataGetParameterFromStack()
*
* @dataProvider dataGetParameterFromStackNamedAfterVariadic
*
* @param int $offset The positional offfset to pass.
* @param array $names The parameter names to pass.
* @param array|false $expected The expected result array for the parameter.
* @param int $offset The positional offfset to pass.
* @param array<string> $names The parameter names to pass.
* @param array<string, int|string>|false $expected The expected result array for the parameter.
*
* @return void
*/
Expand Down Expand Up @@ -446,7 +447,7 @@ public function testGetParameterFromStackNamedAfterVariadic($offset, $names, $ex
*
* @see testGetParameterFromStackNamedAfterVariadic() For the array format.
*
* @return array
* @return array<string, array<string, int|array<string>|array<string, int|string>|false>>
*/
public static function dataGetParameterFromStackNamedAfterVariadic()
{
Expand Down
11 changes: 6 additions & 5 deletions Tests/Utils/PassedParameters/GetParametersNamedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ final class GetParametersNamedTest extends UtilityMethodTestCase
*
* @dataProvider dataGetParameters
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string $targetType The type of token to look for.
* @param array $expected The expected parameter array.
* @param mixed $targetContent Optional. The token content to look for.
* @param string $testMarker The comment which prefaces the target token
* in the test file.
* @param int|string $targetType The type of token to look for.
* @param array<int|string, array<string, int|string>> $expected The expected parameter array.
* @param string|null $targetContent Optional. The token content to look for.
*
* @return void
*/
Expand Down Expand Up @@ -73,7 +74,7 @@ public function testGetParameters($testMarker, $targetType, $expected, $targetCo
*
* @see testGetParameters() For the array format.
*
* @return array
* @return array<string, array<string, int|string|array<int|string, array<string, int|string>>|null>>
*/
public static function dataGetParameters()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testHasParametersDontSkipShortArrayCheck($testMarker, $targetTyp
*
* @see testHasParametersDontSkipShortArrayCheck() For the array format.
*
* @return array
* @return array<string, array<string, int|string|bool|array<int, array<string, int|string>>>>
*/
public static function dataHasParametersDontSkipShortArrayCheck()
{
Expand All @@ -79,9 +79,9 @@ public static function dataHasParametersDontSkipShortArrayCheck()
*
* @dataProvider dataGetParametersSkipShortArrayCheck
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string $targetType The type of token to look for.
* @param array $expected The expected return value.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string $targetType The type of token to look for.
* @param array<int, array<string, int|string>> $expected The expected return value.
*
* @return void
*/
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testGetParametersSkipShortArrayCheck($testMarker, $targetType, $
*
* @see testGetParametersSkipShortArrayCheck() For the array format.
*
* @return array
* @return array<string, array<string, int|string|bool|array<int, array<string, int|string>>>>
*/
public static function dataGetParametersSkipShortArrayCheck()
{
Expand All @@ -143,7 +143,7 @@ public static function dataGetParametersSkipShortArrayCheck()
* @see testGetParametersSkipShortArrayCheck() For the array format.
* @see testHasParametersDontSkipShortArrayCheck() For the array format.
*
* @return array
* @return array<string, array<string, int|string|bool|array<int, array<string, int|string>>>>
*/
public static function dataTestCases()
{
Expand Down
Loading

0 comments on commit 8c577be

Please sign in to comment.