PATH:
opt
/
cpanel
/
ea-wappspector
/
vendor
/
squizlabs
/
php_codesniffer
/
tests
/
Core
/
Tokenizers
/
PHP
<?php function matchWithDefault($i) { return match ($i) { 1 => 1, 2 => 2, /* testSimpleMatchDefault */ default => 'default', }; } function switchWithDefault($i) { switch ($i) { case 1: return 1; case 2: return 2; /* testSimpleSwitchDefault */ default: return 'default'; } } function switchWithDefaultAndCurlies($i) { switch ($i) { case 1: return 1; case 2: return 2; /* testSimpleSwitchDefaultWithCurlies */ default: { return 'default'; } } } function matchWithDefaultInSwitch() { switch ($something) { case 'foo': $var = [1, 2, 3]; $var = match ($i) { 1 => 1, /* testMatchDefaultNestedInSwitchCase1 */ default => 'default', }; continue; case 'bar' : $i = callMe($a, $b); return match ($i) { 1 => 1, /* testMatchDefaultNestedInSwitchCase2 */ default => 'default', }; /* testSwitchDefault */ default; echo 'something', match ($i) { 1, => 1, /* testMatchDefaultNestedInSwitchDefault */ default, => 'default', }; break; } } function switchWithDefaultInMatch() { $x = match ($y) { 5, 8 => function($z) { switch($z) { case 'a'; $var = [1, 2, 3]; return 'a'; /* testSwitchDefaultNestedInMatchCase */ default: $var = [1, 2, 3]; return 'default1'; } }, /* testMatchDefault */ default => function($z) { switch($z) { case 'a': $i = callMe($a, $b); return 'b'; /* testSwitchDefaultNestedInMatchDefault */ default: $i = callMe($a, $b); return 'default2'; } } }; } function shortArrayWithConstantKey() { $arr = [ /* testClassConstantAsShortArrayKey */ SomeClass::DEFAULT => 1, /* testClassPropertyAsShortArrayKey */ SomeClass->DEFAULT => 1, /* testNamespacedConstantAsShortArrayKey */ // Intentional parse error PHP < 8.0. Reserved keyword used as namespaced constant. SomeNamespace\DEFAULT => 1, /* testFQNGlobalConstantAsShortArrayKey */ // Intentional parse error in PHP < 8.0. Reserved keyword used as global constant. \DEFAULT => 1, ]; } function longArrayWithConstantKey() { $arr = array( /* testClassConstantAsLongArrayKey */ SomeClass::DEFAULT => 1, ); } function yieldWithConstantKey() { /* testClassConstantAsYieldKey */ yield SomeClass::DEFAULT => 1; } function longArrayWithConstantKeyNestedInMatch() { return match($x) { /* testMatchDefaultWithNestedLongArrayWithClassConstantKey */ DEFAULT => array( /* testClassConstantAsLongArrayKeyNestedInMatch */ SomeClass::DEFAULT => match($x) { /* testMatchDefaultWithNestedLongArrayWithClassConstantKeyLevelDown */ DEFAULT => array( /* testClassConstantAsLongArrayKeyNestedInMatchLevelDown */ SomeClass::DEFAULT => 1, ), }, ), }; } function shortArrayWithConstantKeyNestedInMatch() { return match($x) { /* testMatchDefaultWithNestedShortArrayWithClassConstantKey */ DEFAULT => [ /* testClassConstantAsShortArrayKeyNestedInMatch */ SomeClass::DEFAULT => match($x) { /* testMatchDefaultWithNestedShortArrayWithClassConstantKeyLevelDown */ DEFAULT => [ /* testClassConstantAsShortArrayKeyNestedInMatchLevelDown */ SomeClass::DEFAULT => 1, ], }, ], }; } function longArrayWithConstantKeyWithNestedMatch() { return array( /* testClassConstantAsLongArrayKeyWithNestedMatch */ SomeClass::DEFAULT => match($x) { /* testMatchDefaultNestedInLongArray */ DEFAULT => 'foo' }, ); } function shortArrayWithConstantKeyWithNestedMatch() { return [ /* testClassConstantAsShortArrayKeyWithNestedMatch */ SomeClass::DEFAULT => match($x) { /* testMatchDefaultNestedInShortArray */ DEFAULT => 'foo' }, ]; } function switchWithConstantNonDefault($i) { switch ($i) { /* testClassConstantInSwitchCase */ case SomeClass::DEFAULT: return 1; /* testClassPropertyInSwitchCase */ case SomeClass->DEFAULT: return 2; /* testNamespacedConstantInSwitchCase */ // Intentional parse error PHP < 8.0. Reserved keyword used as constant. case SomeNamespace\DEFAULT: return 2; /* testNamespaceRelativeConstantInSwitchCase */ // Intentional parse error PHP < 8.0. Reserved keyword used as global constant. case namespace\DEFAULT: return 2; } } class Foo { /* testClassConstant */ const DEFAULT = 'foo'; /* testMethodDeclaration */ public function default() {} }
[-] BackfillExplicitOctalNotationTest.php
[edit]
[-] PHPOpenTagEOF2Test.inc
[edit]
[-] BackfillEnumTest.inc
[edit]
[-] PHPOpenTagEOF1Test.php
[edit]
[-] BackfillAsymmetricVisibilityTest.php
[edit]
[-] EnumCaseTest.php
[edit]
[-] StableCommentWhitespaceTest.inc
[edit]
[-] HeredocNowdocTest.inc
[edit]
[-] TypeIntersectionTest.php
[edit]
[-] DNFTypesParseError2Test.php
[edit]
[-] TypeIntersectionTest.inc
[edit]
[-] NamedFunctionCallArgumentsTest.inc
[edit]
[-] TypedConstantsTest.inc
[edit]
[-] UndoNamespacedNameSingleTokenTest.php
[edit]
[-] BackfillFnTokenParseErrorTest.inc
[edit]
[+]
..
[-] StableCommentWhitespaceWinTest.php
[edit]
[-] DNFTypesTest.inc
[edit]
[-] DNFTypesParseError1Test.inc
[edit]
[-] BitwiseOrTest.php
[edit]
[-] BackfillFnTokenParseErrorTest.php
[edit]
[-] DoubleQuotedStringTest.php
[edit]
[-] BackfillReadonlyTest.inc
[edit]
[-] PHPOpenTagEOF1Test.inc
[edit]
[-] PHPOpenTagEOF2Test.php
[edit]
[-] BackfillNumericSeparatorTest.inc
[edit]
[-] ArrayKeywordTest.inc
[edit]
[-] BackfillMatchTokenTest.php
[edit]
[-] DoubleArrowTest.inc
[edit]
[-] HeredocStringTest.inc
[edit]
[-] GotoLabelTest.inc
[edit]
[-] OtherContextSensitiveKeywordsTest.php
[edit]
[-] StableCommentWhitespaceTest.php
[edit]
[-] NullsafeObjectOperatorTest.php
[edit]
[-] DNFTypesParseError1Test.php
[edit]
[-] AttributesTest.php
[edit]
[-] ExitKeywordTest.inc
[edit]
[-] HeredocParseErrorTest.php
[edit]
[-] AnonClassParenthesisOwnerTest.php
[edit]
[-] NullableVsInlineThenTest.inc
[edit]
[-] ArrayKeywordTest.php
[edit]
[-] NullsafeObjectOperatorTest.inc
[edit]
[-] BackfillExplicitOctalNotationTest.inc
[edit]
[-] ResolveSimpleTokenTest.inc
[edit]
[-] DNFTypesParseError2Test.inc
[edit]
[-] BackfillEnumTest.php
[edit]
[-] YieldTest.inc
[edit]
[-] BackfillReadonlyTest.php
[edit]
[-] HeredocNowdocTest.php
[edit]
[-] ShortArrayTest.inc
[edit]
[-] DefaultKeywordTest.php
[edit]
[-] StableCommentWhitespaceWinTest.inc
[edit]
[-] BitwiseOrTest.inc
[edit]
[-] DNFTypesTest.php
[edit]
[-] DoubleArrowTest.php
[edit]
[-] EnumCaseTest.inc
[edit]
[-] TypedConstantsTest.php
[edit]
[-] BackfillNumericSeparatorTest.php
[edit]
[-] BackfillFnTokenTest.php
[edit]
[-] FinallyTest.inc
[edit]
[-] HeredocStringTest.php
[edit]
[-] ShortArrayTest.php
[edit]
[-] BackfillMatchTokenTest.inc
[edit]
[-] NullableVsInlineThenTest.php
[edit]
[-] DoubleQuotedStringTest.inc
[edit]
[-] GotoLabelTest.php
[edit]
[-] ExitKeywordTest.php
[edit]
[-] HeredocParseErrorTest.inc
[edit]
[-] ResolveSimpleTokenTest.php
[edit]
[-] UndoNamespacedNameSingleTokenTest.inc
[edit]
[-] OtherContextSensitiveKeywordsTest.inc
[edit]
[-] NamedFunctionCallArgumentsTest.php
[edit]
[-] AnonClassParenthesisOwnerTest.inc
[edit]
[-] PHPOpenTagEOF3Test.inc
[edit]
[-] BackfillFnTokenTest.inc
[edit]
[-] BackfillAsymmetricVisibilityTest.inc
[edit]
[-] AttributesTest.inc
[edit]
[-] ContextSensitiveKeywordsTest.inc
[edit]
[-] FinallyTest.php
[edit]
[-] PHPOpenTagEOF3Test.php
[edit]
[-] YieldTest.php
[edit]
[-] DefaultKeywordTest.inc
[edit]
[-] ContextSensitiveKeywordsTest.php
[edit]