Skip to content

Commit d49587c

Browse files
authored
Merge pull request #506 from PHPCSStandards/feature/dnftypes-minor-cleanup
Tests/DNFTypesTest: fix a few unintentional errors
2 parents b0bb133 + c511f25 commit d49587c

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

tests/Core/Tokenizer/PHP/DNFTypesTest.inc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ $obj->static((CONST_A&CONST_B)|CONST_C | $var);
4949
* DNF parentheses.
5050
*/
5151

52-
class DNFTypes {
52+
abstract class DNFTypes {
5353
/* testDNFTypeOOConstUnqualifiedClasses */
5454
public const (A&B)|D UNQUALIFIED = new Foo;
5555

@@ -63,7 +63,7 @@ class DNFTypes {
6363
(C&D) | // phpcs:ignore Stnd.Cat.Sniff
6464
/* testDNFTypeOOConstMulti3 */
6565
(Y&D)
66-
| null MULTI_DNF = false;
66+
| null MULTI_DNF = null;
6767

6868
/* testDNFTypeOOConstNamespaceRelative */
6969
final protected const (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC NAMESPACE_RELATIVE = new namespace\Sub\NameB;
@@ -75,10 +75,10 @@ class DNFTypes {
7575
const (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameC FULLY_QUALIFIED = new \Fully\Qualified\NameB();
7676

7777
/* testDNFTypePropertyUnqualifiedClasses */
78-
public static (Foo&Bar)|object $obj;
78+
public static (Foo&Bar)|array $obj;
7979

8080
/* testDNFTypePropertyReverseModifierOrder */
81-
static protected string|(A&B)|bool $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
81+
static protected string|(A&B)|int $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
8282

8383
private
8484
/* testDNFTypePropertyMultiNamespaceRelative */
@@ -96,15 +96,15 @@ class DNFTypes {
9696
static readonly (A&B&C)|array $staticReadonly;
9797

9898
/* testDNFTypePropertyWithOnlyStaticKeyword */
99-
static (A&B&C)|true $obj;
99+
static (A&B&C)|true $onlyStaticModified;
100100

101101
public function paramTypes(
102102
/* testDNFTypeParam1WithAttribute */
103103
#[MyAttribute]
104104
(\Foo&Bar)|int|float $paramA /* testParensNoOwnerParamDefaultValue */ = SOMETHING | (CONSTANT_A & CONSTANT_B),
105105

106106
/* testDNFTypeParam2 */
107-
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB = null,
107+
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB,
108108
) {
109109
/* testParensNoOwnerInReturnValue1 */
110110
return (
@@ -148,7 +148,7 @@ function globalFunctionWithSpreadAndReference(
148148
/* testDNFTypeWithReference */
149149
float|(B&A) &$paramA,
150150
/* testDNFTypeWithSpreadOperator */
151-
string|(B|D) ...$paramB
151+
string|(B&D) ...$paramB
152152
) {}
153153

154154

@@ -160,7 +160,7 @@ $closureWithReturnType = function ($string = NONSENSE & FAKE) /* testDNFTypeClos
160160
/* testParensOwnerArrowDNFUsedWithin */
161161
$arrowWithParamType = fn (
162162
/* testDNFTypeArrowParam */
163-
object|(A&B&C)|array $param,
163+
int|(A&B&C)|array $param,
164164
/* testParensNoOwnerAmpersandInDefaultValue */ ?int $int = (CONSTA & CONSTB )| CONST_C
165165
)
166166
/* testParensNoOwnerInArrowReturnExpression */
@@ -175,11 +175,11 @@ $arrowWithParamReturnByRef = fn &(
175175

176176
function InvalidSyntaxes(
177177
/* testDNFTypeParamIllegalUnnecessaryParens */
178-
(A&B) $parensNotNeeded
178+
(A&B) $parensNotNeeded,
179179

180180
/* testDNFTypeParamIllegalIntersectUnionReversed */
181-
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside
181+
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside,
182182

183183
/* testDNFTypeParamIllegalNestedParens */
184-
A|(B&(D|W)|null) $nestedParensNotAllowed
184+
A|(B&(D|W)|null) $nestedParensNotAllowed,
185185
) {}

tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.inc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ $obj->static((CONST_A&CONST_B)|CONST_C | $var);
4949
* DNF parentheses.
5050
*/
5151

52-
class DNFTypes {
52+
abstract class DNFTypes {
5353
/* testDNFTypeOOConstUnqualifiedClasses */
5454
public const (A&B)|D UNQUALIFIED = new Foo;
5555

@@ -63,7 +63,7 @@ class DNFTypes {
6363
(C&D) | // phpcs:ignore Stnd.Cat.Sniff
6464
/* testDNFTypeOOConstMulti3 */
6565
(Y&D)
66-
| null MULTI_DNF = false;
66+
| null MULTI_DNF = null;
6767

6868
/* testDNFTypeOOConstNamespaceRelative */
6969
final protected const (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC NAMESPACE_RELATIVE = new namespace\Sub\NameB;
@@ -75,10 +75,10 @@ class DNFTypes {
7575
const (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameC FULLY_QUALIFIED = new \Fully\Qualified\NameB();
7676

7777
/* testDNFTypePropertyUnqualifiedClasses */
78-
public static (Foo&Bar)|object $obj;
78+
public static (Foo&Bar)|array $obj;
7979

8080
/* testDNFTypePropertyReverseModifierOrder */
81-
static protected string|(A&B)|bool $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
81+
static protected string|(A&B)|int $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
8282

8383
private
8484
/* testDNFTypePropertyMultiNamespaceRelative */
@@ -96,15 +96,15 @@ class DNFTypes {
9696
static readonly (A&B&C)|array $staticReadonly;
9797

9898
/* testDNFTypePropertyWithOnlyStaticKeyword */
99-
static (A&B&C)|true $obj;
99+
static (A&B&C)|true $onlyStaticModified;
100100

101101
public function paramTypes(
102102
/* testDNFTypeParam1WithAttribute */
103103
#[MyAttribute]
104104
(\Foo&Bar)|int|float $paramA /* testParensNoOwnerParamDefaultValue */ = SOMETHING | (CONSTANT_A & CONSTANT_B),
105105

106106
/* testDNFTypeParam2 */
107-
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB = null,
107+
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB,
108108
) {
109109
/* testParensNoOwnerInReturnValue1 */
110110
return (
@@ -148,7 +148,7 @@ function globalFunctionWithSpreadAndReference(
148148
/* testDNFTypeWithReference */
149149
float|(B&A) &$paramA,
150150
/* testDNFTypeWithSpreadOperator */
151-
string|(B|D) ...$paramB
151+
string|(B&D) ...$paramB
152152
) {}
153153

154154

@@ -160,7 +160,7 @@ $closureWithReturnType = function ($string = NONSENSE & FAKE) /* testDNFTypeClos
160160
/* testParensOwnerArrowDNFUsedWithin */
161161
$arrowWithParamType = fn (
162162
/* testDNFTypeArrowParam */
163-
object|(A&B&C)|array $param,
163+
int|(A&B&C)|array $param,
164164
/* testParensNoOwnerAmpersandInDefaultValue */ ?int $int = (CONSTA & CONSTB )| CONST_C
165165
)
166166
/* testParensNoOwnerInArrowReturnExpression */
@@ -175,11 +175,11 @@ $arrowWithParamReturnByRef = fn &(
175175

176176
function InvalidSyntaxes(
177177
/* testDNFTypeParamIllegalUnnecessaryParens */
178-
(A&B) $parensNotNeeded
178+
(A&B) $parensNotNeeded,
179179

180180
/* testDNFTypeParamIllegalIntersectUnionReversed */
181-
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside
181+
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside,
182182

183183
/* testDNFTypeParamIllegalNestedParens */
184-
A|(B&(D|W)|null) $nestedParensNotAllowed
184+
A|(B&(D|W)|null) $nestedParensNotAllowed,
185185
) {}

0 commit comments

Comments
 (0)