Skip to content

Commit 81b4298

Browse files
authored
Merge pull request #269 from PHPCSStandards/feature/tests-bitwise-or-improvements
Tests/BitwiseOrTest: use named data sets and other tweaks
2 parents 866ca20 + c7d920a commit 81b4298

File tree

2 files changed

+60
-60
lines changed

2 files changed

+60
-60
lines changed

tests/Core/Tokenizer/BitwiseOrTest.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ class TypeUnion
7171
\Fully\Qualified\NameA|\Fully\Qualified\NameB $paramC,
7272
) {}
7373

74-
/* testTypeUnionReturnType */
75-
public function returnType() : int|false {}
76-
7774
/* testTypeUnionConstructorPropertyPromotion */
7875
public function __construct( public bool|null $property) {}
7976

77+
/* testTypeUnionReturnType */
78+
public function returnType() : int|false {}
79+
8080
/* testTypeUnionAbstractMethodReturnType1 */
8181
abstract public function abstractMethod(): object|array /* testTypeUnionAbstractMethodReturnType2 */ |false;
8282

@@ -90,16 +90,16 @@ class TypeUnion
9090
public function identifierNamesReturnFQ() : \Fully\Qualified\NameA|\Fully\Qualified\NameB {}
9191
}
9292

93-
/* testTypeUnionClosureParamIllegalNullable */
94-
$closureWithParamType = function (?string|null $string) {};
95-
9693
function globalFunctionWithSpreadAndReference(
9794
/* testTypeUnionWithReference */
9895
float|null &$paramA,
9996
/* testTypeUnionWithSpreadOperator */
10097
string|int ...$paramB
10198
) {}
10299

100+
/* testTypeUnionClosureParamIllegalNullable */
101+
$closureWithParamType = function (?string|null $string) {};
102+
103103
/* testBitwiseOrClosureParamDefault */
104104
$closureWithReturnType = function ($string = NONSENSE | FAKE)/* testTypeUnionClosureReturn */ : \Package\MyA|PackageB {};
105105

tests/Core/Tokenizer/BitwiseOrTest.php

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ public function testBitwiseOr($testMarker)
4141
*
4242
* @see testBitwiseOr()
4343
*
44-
* @return array
44+
* @return array<string, array<string>>
4545
*/
4646
public static function dataBitwiseOr()
4747
{
4848
return [
49-
['/* testBitwiseOr1 */'],
50-
['/* testBitwiseOr2 */'],
51-
['/* testBitwiseOrPropertyDefaultValue */'],
52-
['/* testBitwiseOrParamDefaultValue */'],
53-
['/* testBitwiseOr3 */'],
54-
['/* testBitwiseOrClosureParamDefault */'],
55-
['/* testBitwiseOrArrowParamDefault */'],
56-
['/* testBitwiseOrArrowExpression */'],
57-
['/* testBitwiseOrInArrayKey */'],
58-
['/* testBitwiseOrInArrayValue */'],
59-
['/* testBitwiseOrInShortArrayKey */'],
60-
['/* testBitwiseOrInShortArrayValue */'],
61-
['/* testBitwiseOrTryCatch */'],
62-
['/* testBitwiseOrNonArrowFnFunctionCall */'],
63-
['/* testLiveCoding */'],
49+
'in simple assignment 1' => ['/* testBitwiseOr1 */'],
50+
'in simple assignment 2' => ['/* testBitwiseOr2 */'],
51+
'in property default value' => ['/* testBitwiseOrPropertyDefaultValue */'],
52+
'in method parameter default value' => ['/* testBitwiseOrParamDefaultValue */'],
53+
'in return statement' => ['/* testBitwiseOr3 */'],
54+
'in closure parameter default value' => ['/* testBitwiseOrClosureParamDefault */'],
55+
'in arrow function parameter default value' => ['/* testBitwiseOrArrowParamDefault */'],
56+
'in arrow function return expression' => ['/* testBitwiseOrArrowExpression */'],
57+
'in long array key' => ['/* testBitwiseOrInArrayKey */'],
58+
'in long array value' => ['/* testBitwiseOrInArrayValue */'],
59+
'in short array key' => ['/* testBitwiseOrInShortArrayKey */'],
60+
'in short array value' => ['/* testBitwiseOrInShortArrayValue */'],
61+
'in catch condition' => ['/* testBitwiseOrTryCatch */'],
62+
'in parameter in function call' => ['/* testBitwiseOrNonArrowFnFunctionCall */'],
63+
'live coding / undetermined' => ['/* testLiveCoding */'],
6464
];
6565

6666
}//end dataBitwiseOr()
@@ -92,48 +92,48 @@ public function testTypeUnion($testMarker)
9292
*
9393
* @see testTypeUnion()
9494
*
95-
* @return array
95+
* @return array<string, array<string>>
9696
*/
9797
public static function dataTypeUnion()
9898
{
9999
return [
100-
['/* testTypeUnionPropertySimple */'],
101-
['/* testTypeUnionPropertyReverseModifierOrder */'],
102-
['/* testTypeUnionPropertyMulti1 */'],
103-
['/* testTypeUnionPropertyMulti2 */'],
104-
['/* testTypeUnionPropertyMulti3 */'],
105-
['/* testTypeUnionPropertyNamespaceRelative */'],
106-
['/* testTypeUnionPropertyPartiallyQualified */'],
107-
['/* testTypeUnionPropertyFullyQualified */'],
108-
['/* testTypeUnionPropertyWithReadOnlyKeyword */'],
109-
['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'],
110-
['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'],
111-
['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'],
112-
['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'],
113-
['/* testTypeUnionPropertyWithOnlyStaticKeyword */'],
114-
['/* testTypeUnionParam1 */'],
115-
['/* testTypeUnionParam2 */'],
116-
['/* testTypeUnionParam3 */'],
117-
['/* testTypeUnionParamNamespaceRelative */'],
118-
['/* testTypeUnionParamPartiallyQualified */'],
119-
['/* testTypeUnionParamFullyQualified */'],
120-
['/* testTypeUnionReturnType */'],
121-
['/* testTypeUnionConstructorPropertyPromotion */'],
122-
['/* testTypeUnionAbstractMethodReturnType1 */'],
123-
['/* testTypeUnionAbstractMethodReturnType2 */'],
124-
['/* testTypeUnionReturnTypeNamespaceRelative */'],
125-
['/* testTypeUnionReturnPartiallyQualified */'],
126-
['/* testTypeUnionReturnFullyQualified */'],
127-
['/* testTypeUnionClosureParamIllegalNullable */'],
128-
['/* testTypeUnionWithReference */'],
129-
['/* testTypeUnionWithSpreadOperator */'],
130-
['/* testTypeUnionClosureReturn */'],
131-
['/* testTypeUnionArrowParam */'],
132-
['/* testTypeUnionArrowReturnType */'],
133-
['/* testTypeUnionNonArrowFunctionDeclaration */'],
134-
['/* testTypeUnionPHP82TrueFirst */'],
135-
['/* testTypeUnionPHP82TrueMiddle */'],
136-
['/* testTypeUnionPHP82TrueLast */'],
100+
'type for static property' => ['/* testTypeUnionPropertySimple */'],
101+
'type for static property, reversed modifier order' => ['/* testTypeUnionPropertyReverseModifierOrder */'],
102+
'type for property, first of multi-union' => ['/* testTypeUnionPropertyMulti1 */'],
103+
'type for property, middle of multi-union, also comments' => ['/* testTypeUnionPropertyMulti2 */'],
104+
'type for property, last of multi-union' => ['/* testTypeUnionPropertyMulti3 */'],
105+
'type for property using namespace relative names' => ['/* testTypeUnionPropertyNamespaceRelative */'],
106+
'type for property using partially qualified names' => ['/* testTypeUnionPropertyPartiallyQualified */'],
107+
'type for property using fully qualified names' => ['/* testTypeUnionPropertyFullyQualified */'],
108+
'type for readonly property' => ['/* testTypeUnionPropertyWithReadOnlyKeyword */'],
109+
'type for static readonly property' => ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'],
110+
'type for readonly property using var keyword' => ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'],
111+
'type for readonly property, reversed modifier order' => ['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'],
112+
'type for readonly property, no visibility' => ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'],
113+
'type for static property, no visibility' => ['/* testTypeUnionPropertyWithOnlyStaticKeyword */'],
114+
'type for method parameter' => ['/* testTypeUnionParam1 */'],
115+
'type for method parameter, first in multi-union' => ['/* testTypeUnionParam2 */'],
116+
'type for method parameter, last in multi-union' => ['/* testTypeUnionParam3 */'],
117+
'type for method parameter with namespace relative names' => ['/* testTypeUnionParamNamespaceRelative */'],
118+
'type for method parameter with partially qualified names' => ['/* testTypeUnionParamPartiallyQualified */'],
119+
'type for method parameter with fully qualified names' => ['/* testTypeUnionParamFullyQualified */'],
120+
'type for property in constructor property promotion' => ['/* testTypeUnionConstructorPropertyPromotion */'],
121+
'return type for method' => ['/* testTypeUnionReturnType */'],
122+
'return type for method, first of multi-union' => ['/* testTypeUnionAbstractMethodReturnType1 */'],
123+
'return type for method, last of multi-union' => ['/* testTypeUnionAbstractMethodReturnType2 */'],
124+
'return type for method with namespace relative names' => ['/* testTypeUnionReturnTypeNamespaceRelative */'],
125+
'return type for method with partially qualified names' => ['/* testTypeUnionReturnPartiallyQualified */'],
126+
'return type for method with fully qualified names' => ['/* testTypeUnionReturnFullyQualified */'],
127+
'type for function parameter with reference' => ['/* testTypeUnionWithReference */'],
128+
'type for function parameter with spread operator' => ['/* testTypeUnionWithSpreadOperator */'],
129+
'type for closure parameter with illegal nullable' => ['/* testTypeUnionClosureParamIllegalNullable */'],
130+
'return type for closure' => ['/* testTypeUnionClosureReturn */'],
131+
'type for arrow function parameter' => ['/* testTypeUnionArrowParam */'],
132+
'return type for arrow function' => ['/* testTypeUnionArrowReturnType */'],
133+
'type for function parameter, return by ref' => ['/* testTypeUnionNonArrowFunctionDeclaration */'],
134+
'type for function param with true type first' => ['/* testTypeUnionPHP82TrueFirst */'],
135+
'type for function param with true type middle' => ['/* testTypeUnionPHP82TrueMiddle */'],
136+
'type for function param with true type last' => ['/* testTypeUnionPHP82TrueLast */'],
137137
];
138138

139139
}//end dataTypeUnion()

0 commit comments

Comments
 (0)