Skip to content

Commit

Permalink
Merge pull request #316 from PHPCSStandards/feature/tests-tokenizer-s…
Browse files Browse the repository at this point in the history
…plit-contextsensitive-test-class

Tests/Tokenizer: split `ContextSensitiveKeywordsTest`
  • Loading branch information
jrfnl authored Jan 29, 2024
2 parents 01d1269 + 0d2bba1 commit 2fbf9e3
Show file tree
Hide file tree
Showing 4 changed files with 412 additions and 278 deletions.
39 changes: 1 addition & 38 deletions tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ContextSensitiveKeywords
const /* testMatch */ MATCH = 'MATCH';
const /* testNamespace */ NAMESPACE = 'NAMESPACE';
const /* testNew */ NEW = 'NEW';
const /* testParent */ PARENT = 'PARENT';
const /* testPrint */ PRINT = 'PRINT';
const /* testPrivate */ PRIVATE = 'PRIVATE';
const /* testProtected */ PROTECTED = 'PROTECTED';
Expand All @@ -62,7 +61,6 @@ class ContextSensitiveKeywords
const /* testRequire */ REQUIRE = 'REQUIRE';
const /* testRequireOnce */ REQUIRE_ONCE = 'REQUIRE_ONCE';
const /* testReturn */ RETURN = 'RETURN';
const /* testSelf */ SELF = 'SELF';
const /* testStatic */ STATIC = 'STATIC';
const /* testSwitch */ SWITCH = 'SWITCH';
const /* testThrows */ THROW = 'THROW';
Expand All @@ -78,10 +76,6 @@ class ContextSensitiveKeywords
const /* testAnd */ AND = 'LOGICAL_AND';
const /* testOr */ OR = 'LOGICAL_OR';
const /* testXor */ XOR = 'LOGICAL_XOR';

const /* testFalse */ FALSE = 'FALSE',
const /* testTrue */ TRUE = 'TRUE',
const /* testNull */ NULL = 'NULL',
}

namespace /* testKeywordAfterNamespaceShouldBeString */ class;
Expand Down Expand Up @@ -110,10 +104,6 @@ namespace /* testNamespaceNameIsString1 */ my\ /* testNamespaceNameIsString2 */
/* testFinalIsKeyword */ final /* testFunctionIsKeyword */ function someFunction(
/* testCallableIsKeyword */
callable $callable,
/* testSelfIsKeyword */
self $self,
/* testParentIsKeyword */
parent $parent
) {
/* testReturnIsKeyword */
return $this;
Expand Down Expand Up @@ -220,45 +210,18 @@ $anonymousClass = new /* testAnonymousClassIsKeyword */ class {};
$anonymousClass2 = new class /* testExtendsInAnonymousClassIsKeyword */ extends SomeParent {};
$anonymousClass3 = new class /* testImplementsInAnonymousClassIsKeyword */ implements SomeInterface {};

$instantiated1 = new /* testClassInstantiationParentIsKeyword */ parent();
$instantiated2 = new /* testClassInstantiationSelfIsKeyword */ SELF;
$instantiated3 = new /* testClassInstantiationStaticIsKeyword */ static($param);
$instantiated = new /* testClassInstantiationStaticIsKeyword */ static($param);

class Foo extends /* testNamespaceInNameIsKeyword */ namespace\Exception
{}

function /* testKeywordAfterFunctionShouldBeString */ eval() {}
function /* testKeywordAfterFunctionByRefShouldBeString */ &switch() {}

function /* testKeywordSelfAfterFunctionByRefShouldBeString */ &self() {}
function /* testKeywordStaticAfterFunctionByRefShouldBeString */ &static() {}
function /* testKeywordParentAfterFunctionByRefShouldBeString */ &parent() {}
function /* testKeywordFalseAfterFunctionByRefShouldBeString */ &false() {}
function /* testKeywordTrueAfterFunctionByRefShouldBeString */ & true () {}
function /* testKeywordNullAfterFunctionByRefShouldBeString */ &NULL() {}

/* testKeywordAsFunctionCallNameShouldBeStringSelf */ self();
/* testKeywordAsFunctionCallNameShouldBeStringStatic */ static();
$obj-> /* testKeywordAsMethodCallNameShouldBeStringStatic */ static();
/* testKeywordAsFunctionCallNameShouldBeStringParent */ parent();
/* testKeywordAsFunctionCallNameShouldBeStringFalse */ false();
/* testKeywordAsFunctionCallNameShouldBeStringTrue */ True ();
/* testKeywordAsFunctionCallNameShouldBeStringNull */ null /*comment*/ ();

$instantiated4 = new /* testClassInstantiationFalseIsString */ False();
$instantiated5 = new /* testClassInstantiationTrueIsString */ true ();
$instantiated6 = new /* testClassInstantiationNullIsString */ null();

$function = /* testStaticIsKeywordBeforeClosure */ static function(/* testStaticIsKeywordWhenParamType */ static $param) {};
$arrow = /* testStaticIsKeywordBeforeArrow */ static fn(): /* testStaticIsKeywordWhenReturnType */ static => 10;

function standAloneFalseTrueNullTypesAndMore(
/* testFalseIsKeywordAsParamType */ false $paramA,
/* testTrueIsKeywordAsParamType */ true $paramB,
/* testNullIsKeywordAsParamType */ null $paramC,
) /* testFalseIsKeywordAsReturnType */ false | /* testTrueIsKeywordAsReturnType */ true | /* testNullIsKeywordAsReturnType */ null {
if ($a === /* testFalseIsKeywordInComparison */ false
|| $a === /* testTrueIsKeywordInComparison */ true
|| $a === /* testNullIsKeywordInComparison */ null
) {}
}
Loading

0 comments on commit 2fbf9e3

Please sign in to comment.