Skip to content

Commit

Permalink
Merge pull request #506 from PHPCSStandards/feature/dnftypes-minor-cl…
Browse files Browse the repository at this point in the history
…eanup

Tests/DNFTypesTest: fix a few unintentional errors
  • Loading branch information
jrfnl committed May 21, 2024
2 parents b0bb133 + c511f25 commit d49587c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions tests/Core/Tokenizer/PHP/DNFTypesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $obj->static((CONST_A&CONST_B)|CONST_C | $var);
* DNF parentheses.
*/

class DNFTypes {
abstract class DNFTypes {
/* testDNFTypeOOConstUnqualifiedClasses */
public const (A&B)|D UNQUALIFIED = new Foo;

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

/* testDNFTypeOOConstNamespaceRelative */
final protected const (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC NAMESPACE_RELATIVE = new namespace\Sub\NameB;
Expand All @@ -75,10 +75,10 @@ class DNFTypes {
const (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameC FULLY_QUALIFIED = new \Fully\Qualified\NameB();
/* testDNFTypePropertyUnqualifiedClasses */
public static (Foo&Bar)|object $obj;
public static (Foo&Bar)|array $obj;
/* testDNFTypePropertyReverseModifierOrder */
static protected string|(A&B)|bool $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
static protected string|(A&B)|int $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
private
/* testDNFTypePropertyMultiNamespaceRelative */
Expand All @@ -96,15 +96,15 @@ class DNFTypes {
static readonly (A&B&C)|array $staticReadonly;
/* testDNFTypePropertyWithOnlyStaticKeyword */
static (A&B&C)|true $obj;
static (A&B&C)|true $onlyStaticModified;
public function paramTypes(
/* testDNFTypeParam1WithAttribute */
#[MyAttribute]
(\Foo&Bar)|int|float $paramA /* testParensNoOwnerParamDefaultValue */ = SOMETHING | (CONSTANT_A & CONSTANT_B),
/* testDNFTypeParam2 */
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB = null,
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB,
) {
/* testParensNoOwnerInReturnValue1 */
return (
Expand Down Expand Up @@ -148,7 +148,7 @@ function globalFunctionWithSpreadAndReference(
/* testDNFTypeWithReference */
float|(B&A) &$paramA,
/* testDNFTypeWithSpreadOperator */
string|(B|D) ...$paramB
string|(B&D) ...$paramB
) {}


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

function InvalidSyntaxes(
/* testDNFTypeParamIllegalUnnecessaryParens */
(A&B) $parensNotNeeded
(A&B) $parensNotNeeded,

/* testDNFTypeParamIllegalIntersectUnionReversed */
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside,

/* testDNFTypeParamIllegalNestedParens */
A|(B&(D|W)|null) $nestedParensNotAllowed
A|(B&(D|W)|null) $nestedParensNotAllowed,
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $obj->static((CONST_A&CONST_B)|CONST_C | $var);
* DNF parentheses.
*/

class DNFTypes {
abstract class DNFTypes {
/* testDNFTypeOOConstUnqualifiedClasses */
public const (A&B)|D UNQUALIFIED = new Foo;

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

/* testDNFTypeOOConstNamespaceRelative */
final protected const (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC NAMESPACE_RELATIVE = new namespace\Sub\NameB;
Expand All @@ -75,10 +75,10 @@ class DNFTypes {
const (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameC FULLY_QUALIFIED = new \Fully\Qualified\NameB();
/* testDNFTypePropertyUnqualifiedClasses */
public static (Foo&Bar)|object $obj;
public static (Foo&Bar)|array $obj;
/* testDNFTypePropertyReverseModifierOrder */
static protected string|(A&B)|bool $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
static protected string|(A&B)|int $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED);
private
/* testDNFTypePropertyMultiNamespaceRelative */
Expand All @@ -96,15 +96,15 @@ class DNFTypes {
static readonly (A&B&C)|array $staticReadonly;
/* testDNFTypePropertyWithOnlyStaticKeyword */
static (A&B&C)|true $obj;
static (A&B&C)|true $onlyStaticModified;
public function paramTypes(
/* testDNFTypeParam1WithAttribute */
#[MyAttribute]
(\Foo&Bar)|int|float $paramA /* testParensNoOwnerParamDefaultValue */ = SOMETHING | (CONSTANT_A & CONSTANT_B),
/* testDNFTypeParam2 */
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB = null,
(Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB,
) {
/* testParensNoOwnerInReturnValue1 */
return (
Expand Down Expand Up @@ -148,7 +148,7 @@ function globalFunctionWithSpreadAndReference(
/* testDNFTypeWithReference */
float|(B&A) &$paramA,
/* testDNFTypeWithSpreadOperator */
string|(B|D) ...$paramB
string|(B&D) ...$paramB
) {}


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

function InvalidSyntaxes(
/* testDNFTypeParamIllegalUnnecessaryParens */
(A&B) $parensNotNeeded
(A&B) $parensNotNeeded,

/* testDNFTypeParamIllegalIntersectUnionReversed */
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside
A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside,

/* testDNFTypeParamIllegalNestedParens */
A|(B&(D|W)|null) $nestedParensNotAllowed
A|(B&(D|W)|null) $nestedParensNotAllowed,
) {}

0 comments on commit d49587c

Please sign in to comment.