Skip to content

Tests/DNFTypesTest: fix a few unintentional errors #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
) {}