Skip to content

Commit e332340

Browse files
authored
Merge pull request #270 from PHPCSStandards/feature/tests-typeintersection-improvements
Tests/TypeIntersectionTest: use named data sets and other tweaks
2 parents 81b4298 + 477b13f commit e332340

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

tests/Core/Tokenizer/TypeIntersectionTest.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ class TypeIntersection
5959
\Fully\Qualified\NameA&\Fully\Qualified\NameB $paramC,
6060
) {}
6161

62-
/* testTypeIntersectionReturnType */
63-
public function returnType() : Foo&Bar {}
64-
6562
/* testTypeIntersectionConstructorPropertyPromotion */
6663
public function __construct( public Foo&Bar $property) {}
6764

65+
/* testTypeIntersectionReturnType */
66+
public function returnType() : Foo&Bar {}
67+
6868
/* testTypeIntersectionAbstractMethodReturnType1 */
6969
abstract public function abstractMethod(): Foo&Bar /* testTypeIntersectionAbstractMethodReturnType2 */ &Baz;
7070

@@ -78,16 +78,16 @@ class TypeIntersection
7878
public function identifierNamesReturnFQ() : \Fully\Qualified\NameA&\Fully\Qualified\NameB {}
7979
}
8080

81-
/* testTypeIntersectionClosureParamIllegalNullable */
82-
$closureWithParamType = function (?Foo&Bar $string) {};
83-
8481
function globalFunctionWithSpreadAndReference(
8582
/* testTypeIntersectionWithReference */
8683
Foo&Bar /* testBitwiseAnd5 */ &$paramA,
8784
/* testTypeIntersectionWithSpreadOperator */
8885
Foo&Bar ...$paramB
8986
) {}
9087

88+
/* testTypeIntersectionClosureParamIllegalNullable */
89+
$closureWithParamType = function (?Foo&Bar $string) {};
90+
9191
/* testBitwiseAndClosureParamDefault */
9292
$closureWithReturnType = function ($string = NONSENSE & FAKE)/* testTypeIntersectionClosureReturn */ : \Package\MyA&PackageB {};
9393

tests/Core/Tokenizer/TypeIntersectionTest.php

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ public function testBitwiseAnd($testMarker)
4242
*
4343
* @see testBitwiseAnd()
4444
*
45-
* @return array
45+
* @return array<string, array<string>>
4646
*/
4747
public static function dataBitwiseAnd()
4848
{
4949
return [
50-
['/* testBitwiseAnd1 */'],
51-
['/* testBitwiseAnd2 */'],
52-
['/* testBitwiseAndPropertyDefaultValue */'],
53-
['/* testBitwiseAndParamDefaultValue */'],
54-
['/* testBitwiseAnd3 */'],
55-
['/* testBitwiseAnd4 */'],
56-
['/* testBitwiseAnd5 */'],
57-
['/* testBitwiseAndClosureParamDefault */'],
58-
['/* testBitwiseAndArrowParamDefault */'],
59-
['/* testBitwiseAndArrowExpression */'],
60-
['/* testBitwiseAndInArrayKey */'],
61-
['/* testBitwiseAndInArrayValue */'],
62-
['/* testBitwiseAndInShortArrayKey */'],
63-
['/* testBitwiseAndInShortArrayValue */'],
64-
['/* testBitwiseAndNonArrowFnFunctionCall */'],
65-
['/* testBitwiseAnd6 */'],
66-
['/* testLiveCoding */'],
50+
'in simple assignment 1' => ['/* testBitwiseAnd1 */'],
51+
'in simple assignment 2' => ['/* testBitwiseAnd2 */'],
52+
'in property default value' => ['/* testBitwiseAndPropertyDefaultValue */'],
53+
'in method parameter default value' => ['/* testBitwiseAndParamDefaultValue */'],
54+
'reference for method parameter' => ['/* testBitwiseAnd3 */'],
55+
'in return statement' => ['/* testBitwiseAnd4 */'],
56+
'reference for function parameter' => ['/* testBitwiseAnd5 */'],
57+
'in closure parameter default value' => ['/* testBitwiseAndClosureParamDefault */'],
58+
'in arrow function parameter default value' => ['/* testBitwiseAndArrowParamDefault */'],
59+
'in arrow function return expression' => ['/* testBitwiseAndArrowExpression */'],
60+
'in long array key' => ['/* testBitwiseAndInArrayKey */'],
61+
'in long array value' => ['/* testBitwiseAndInArrayValue */'],
62+
'in short array key' => ['/* testBitwiseAndInShortArrayKey */'],
63+
'in short array value' => ['/* testBitwiseAndInShortArrayValue */'],
64+
'in parameter in function call' => ['/* testBitwiseAndNonArrowFnFunctionCall */'],
65+
'function return by reference' => ['/* testBitwiseAnd6 */'],
66+
'live coding / undetermined' => ['/* testLiveCoding */'],
6767
];
6868

6969
}//end dataBitwiseAnd()
@@ -95,42 +95,42 @@ public function testTypeIntersection($testMarker)
9595
*
9696
* @see testTypeIntersection()
9797
*
98-
* @return array
98+
* @return array<string, array<string>>
9999
*/
100100
public static function dataTypeIntersection()
101101
{
102102
return [
103-
['/* testTypeIntersectionPropertySimple */'],
104-
['/* testTypeIntersectionPropertyReverseModifierOrder */'],
105-
['/* testTypeIntersectionPropertyMulti1 */'],
106-
['/* testTypeIntersectionPropertyMulti2 */'],
107-
['/* testTypeIntersectionPropertyMulti3 */'],
108-
['/* testTypeIntersectionPropertyNamespaceRelative */'],
109-
['/* testTypeIntersectionPropertyPartiallyQualified */'],
110-
['/* testTypeIntersectionPropertyFullyQualified */'],
111-
['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'],
112-
['/* testTypeIntersectionPropertyWithStaticKeyword */'],
113-
['/* testTypeIntersectionParam1 */'],
114-
['/* testTypeIntersectionParam2 */'],
115-
['/* testTypeIntersectionParam3 */'],
116-
['/* testTypeIntersectionParamNamespaceRelative */'],
117-
['/* testTypeIntersectionParamPartiallyQualified */'],
118-
['/* testTypeIntersectionParamFullyQualified */'],
119-
['/* testTypeIntersectionReturnType */'],
120-
['/* testTypeIntersectionConstructorPropertyPromotion */'],
121-
['/* testTypeIntersectionAbstractMethodReturnType1 */'],
122-
['/* testTypeIntersectionAbstractMethodReturnType2 */'],
123-
['/* testTypeIntersectionReturnTypeNamespaceRelative */'],
124-
['/* testTypeIntersectionReturnPartiallyQualified */'],
125-
['/* testTypeIntersectionReturnFullyQualified */'],
126-
['/* testTypeIntersectionClosureParamIllegalNullable */'],
127-
['/* testTypeIntersectionWithReference */'],
128-
['/* testTypeIntersectionWithSpreadOperator */'],
129-
['/* testTypeIntersectionClosureReturn */'],
130-
['/* testTypeIntersectionArrowParam */'],
131-
['/* testTypeIntersectionArrowReturnType */'],
132-
['/* testTypeIntersectionNonArrowFunctionDeclaration */'],
133-
['/* testTypeIntersectionWithInvalidTypes */'],
103+
'type for static property' => ['/* testTypeIntersectionPropertySimple */'],
104+
'type for static property, reversed modifier order' => ['/* testTypeIntersectionPropertyReverseModifierOrder */'],
105+
'type for property, first of multi-intersect' => ['/* testTypeIntersectionPropertyMulti1 */'],
106+
'type for property, middle of multi-intersect, also comments' => ['/* testTypeIntersectionPropertyMulti2 */'],
107+
'type for property, last of multi-intersect' => ['/* testTypeIntersectionPropertyMulti3 */'],
108+
'type for property using namespace relative names' => ['/* testTypeIntersectionPropertyNamespaceRelative */'],
109+
'type for property using partially qualified names' => ['/* testTypeIntersectionPropertyPartiallyQualified */'],
110+
'type for property using fully qualified names' => ['/* testTypeIntersectionPropertyFullyQualified */'],
111+
'type for readonly property' => ['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'],
112+
'type for static readonly property' => ['/* testTypeIntersectionPropertyWithStaticKeyword */'],
113+
'type for method parameter' => ['/* testTypeIntersectionParam1 */'],
114+
'type for method parameter, first in multi-intersect' => ['/* testTypeIntersectionParam2 */'],
115+
'type for method parameter, last in multi-intersect' => ['/* testTypeIntersectionParam3 */'],
116+
'type for method parameter with namespace relative names' => ['/* testTypeIntersectionParamNamespaceRelative */'],
117+
'type for method parameter with partially qualified names' => ['/* testTypeIntersectionParamPartiallyQualified */'],
118+
'type for method parameter with fully qualified names' => ['/* testTypeIntersectionParamFullyQualified */'],
119+
'type for property in constructor property promotion' => ['/* testTypeIntersectionConstructorPropertyPromotion */'],
120+
'return type for method' => ['/* testTypeIntersectionReturnType */'],
121+
'return type for method, first of multi-intersect' => ['/* testTypeIntersectionAbstractMethodReturnType1 */'],
122+
'return type for method, last of multi-intersect' => ['/* testTypeIntersectionAbstractMethodReturnType2 */'],
123+
'return type for method with namespace relative names' => ['/* testTypeIntersectionReturnTypeNamespaceRelative */'],
124+
'return type for method with partially qualified names' => ['/* testTypeIntersectionReturnPartiallyQualified */'],
125+
'return type for method with fully qualified names' => ['/* testTypeIntersectionReturnFullyQualified */'],
126+
'type for function parameter with reference' => ['/* testTypeIntersectionWithReference */'],
127+
'type for function parameter with spread operator' => ['/* testTypeIntersectionWithSpreadOperator */'],
128+
'type for closure parameter with illegal nullable' => ['/* testTypeIntersectionClosureParamIllegalNullable */'],
129+
'return type for closure' => ['/* testTypeIntersectionClosureReturn */'],
130+
'type for arrow function parameter' => ['/* testTypeIntersectionArrowParam */'],
131+
'return type for arrow function' => ['/* testTypeIntersectionArrowReturnType */'],
132+
'type for function parameter, return by ref' => ['/* testTypeIntersectionNonArrowFunctionDeclaration */'],
133+
'type for function parameter with invalid types' => ['/* testTypeIntersectionWithInvalidTypes */'],
134134
];
135135

136136
}//end dataTypeIntersection()

0 commit comments

Comments
 (0)