FindStartOfStatementTest
extends AbstractMethodUnitTest
in package
Tests for the \PHP_CodeSniffer\Files\File:findStartOfStatement method.
Tags
Table of Contents
Properties
- $fileExtension : string
- The file extension of the test case file (without leading dot).
- $phpcsFile : File
- The \PHP_CodeSniffer\Files\File object containing the parsed contents of the test case file.
- $tabWidth : int
- The tab width setting to use when tokenizing the file.
Methods
- dataFindStartInsideClosedScopeNestedWithinMatch() : array<string, array<string, int|string>>
- Data provider.
- dataFindStartInsideParenthesesNestedWithinMatch() : array<string, array<string, int|string>>
- Data provider.
- dataFindStartInsideParenthesesNestedWithinNestedMatch() : array<string, array<string, int|string>>
- Data provider.
- dataFindStartInsideShortArrayNestedWithinMatch() : array<string, array<string, int|string>>
- Data provider.
- dataFindStartInsideSwitchCaseDefaultStatements() : array<string, array<string, int|string>>
- Data provider.
- expectRunTimeException() : void
- Helper method to tell PHPUnit to expect a PHPCS RuntimeException in a PHPUnit cross-version compatible manner.
- getTargetToken() : int
- Get the token pointer for a target token based on a specific comment found on the line before.
- getTargetTokenFromFile() : int
- Get the token pointer for a target token based on a specific comment found on the line before.
- initializeFile() : void
- Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
- testArrowFunctionArrayValue() : void
- Test arrow function as array value.
- testArrowFunctionAsArgument() : void
- Test arrow function used as a function argument.
- testArrowFunctionReturnValue() : void
- Test arrow function with return value.
- testArrowFunctionWithArrayAsArgument() : void
- Test arrow function with arrays used as a function argument.
- testClosureAssignment() : void
- Test the assignment of a closure.
- testControlStructure() : void
- Test a direct call to a control structure.
- testFindStartInsideClosedScopeNestedWithinMatch() : void
- Test finding the start of a statement inside a closed scope nested within a match expressions.
- testFindStartInsideParenthesesNestedWithinMatch() : void
- Test finding the start of a statement for a token within a set of parentheses within a match expressions.
- testFindStartInsideParenthesesNestedWithinNestedMatch() : void
- Test finding the start of a statement for a token within a set of parentheses within a match expressions, which itself is nested within parentheses.
- testFindStartInsideShortArrayNestedWithinMatch() : void
- Test finding the start of a statement for a token within a short array within a match expressions.
- testFindStartInsideSwitchCaseDefaultStatements() : void
- Test finding the start of a statement inside a switch control structure case/default statement.
- testFunctionCall() : void
- Test a function call.
- testFunctionCallArgument() : void
- Test a function call.
- testHeredocFunctionArg() : void
- Test using a heredoc in a function argument.
- testMatchArray() : void
- Test match expression with array declaration.
- testMatchCase() : void
- Test simple match expression case.
- testMatchClosure() : void
- Test match expression with closure.
- testMatchDefault() : void
- Test simple match expression default case.
- testMatchDefaultComma() : void
- Test match expression default case with trailing comma.
- testMatchFunctionCall() : void
- Test match expression with function call.
- testMatchFunctionCallArm() : void
- Test match expression with function call in the arm.
- testMatchMultipleCase() : void
- Test multiple comma-separated match expression case values.
- testNestedMatch() : void
- Test nested match expressions.
- testObjectCallPrecededByArrowFunctionAsFunctionCallParameterInArray() : void
- Test object call on result of static function call with arrow function as parameter and wrapped within an array.
- testOpenTag() : void
- Test PHP open tag.
- testOpenTagWithEcho() : void
- Test PHP short open echo tag.
- testSimpleAssignment() : void
- Test a simple assignment.
- testStartIsNeverMoreThanCurrentToken() : void
- Test that start of statement is NEVER beyond the "current" token.
- testStatementAsArrayValue() : void
- Test statements that are array values.
- testStaticArrowFunction() : void
- Test static arrow function.
- testSwitch() : void
- Test parts of a switch statement.
- testUseGroup() : void
- Test a use group.
Properties
$fileExtension
The file extension of the test case file (without leading dot).
protected
static string
$fileExtension
= 'inc'
This allows child classes to overrule the default inc with, for instance,
js or css when applicable.
$phpcsFile
The \PHP_CodeSniffer\Files\File object containing the parsed contents of the test case file.
protected
static File
$phpcsFile
$tabWidth
The tab width setting to use when tokenizing the file.
protected
static int
$tabWidth
= 4
This allows for test case files to use a different tab width than the default.
Methods
dataFindStartInsideClosedScopeNestedWithinMatch()
Data provider.
public
static dataFindStartInsideClosedScopeNestedWithinMatch() : array<string, array<string, int|string>>
Return values
array<string, array<string, int|string>>dataFindStartInsideParenthesesNestedWithinMatch()
Data provider.
public
static dataFindStartInsideParenthesesNestedWithinMatch() : array<string, array<string, int|string>>
Return values
array<string, array<string, int|string>>dataFindStartInsideParenthesesNestedWithinNestedMatch()
Data provider.
public
static dataFindStartInsideParenthesesNestedWithinNestedMatch() : array<string, array<string, int|string>>
Return values
array<string, array<string, int|string>>dataFindStartInsideShortArrayNestedWithinMatch()
Data provider.
public
static dataFindStartInsideShortArrayNestedWithinMatch() : array<string, array<string, int|string>>
Return values
array<string, array<string, int|string>>dataFindStartInsideSwitchCaseDefaultStatements()
Data provider.
public
static dataFindStartInsideSwitchCaseDefaultStatements() : array<string, array<string, int|string>>
Return values
array<string, array<string, int|string>>expectRunTimeException()
Helper method to tell PHPUnit to expect a PHPCS RuntimeException in a PHPUnit cross-version compatible manner.
public
expectRunTimeException(string $message) : void
Parameters
- $message : string
-
The expected exception message.
getTargetToken()
Get the token pointer for a target token based on a specific comment found on the line before.
public
getTargetToken(string $commentString, int|string|array<string|int, mixed> $tokenType[, string $tokenContent = null ]) : int
Note: the test delimiter comment MUST start with "/* test" to allow this function to distinguish between comments used in a test and test delimiters.
Parameters
- $commentString : string
-
The delimiter comment to look for.
- $tokenType : int|string|array<string|int, mixed>
-
The type of token(s) to look for.
- $tokenContent : string = null
-
Optional. The token content for the target token.
Return values
intgetTargetTokenFromFile()
Get the token pointer for a target token based on a specific comment found on the line before.
public
static getTargetTokenFromFile(File $phpcsFile, string $commentString, int|string|array<string|int, mixed> $tokenType[, string $tokenContent = null ]) : int
Note: the test delimiter comment MUST start with "/* test" to allow this function to distinguish between comments used in a test and test delimiters.
Parameters
- $phpcsFile : File
-
The file to find the token in.
- $commentString : string
-
The delimiter comment to look for.
- $tokenType : int|string|array<string|int, mixed>
-
The type of token(s) to look for.
- $tokenContent : string = null
-
Optional. The token content for the target token.
Tags
Return values
intinitializeFile()
Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
public
static initializeFile() : void
The test case file for a unit test class has to be in the same directory directory and use the same file name as the test class, using the .inc extension.
Tags
testArrowFunctionArrayValue()
Test arrow function as array value.
public
testArrowFunctionArrayValue() : void
testArrowFunctionAsArgument()
Test arrow function used as a function argument.
public
testArrowFunctionAsArgument() : void
testArrowFunctionReturnValue()
Test arrow function with return value.
public
testArrowFunctionReturnValue() : void
testArrowFunctionWithArrayAsArgument()
Test arrow function with arrays used as a function argument.
public
testArrowFunctionWithArrayAsArgument() : void
testClosureAssignment()
Test the assignment of a closure.
public
testClosureAssignment() : void
testControlStructure()
Test a direct call to a control structure.
public
testControlStructure() : void
testFindStartInsideClosedScopeNestedWithinMatch()
Test finding the start of a statement inside a closed scope nested within a match expressions.
public
testFindStartInsideClosedScopeNestedWithinMatch(string $testMarker, int|string $target, int|string $expectedTarget) : void
Parameters
- $testMarker : string
-
The comment which prefaces the target token in the test file.
- $target : int|string
-
The token to search for after the test marker.
- $expectedTarget : int|string
-
Token code of the expected start of statement stack pointer.
Tags
testFindStartInsideParenthesesNestedWithinMatch()
Test finding the start of a statement for a token within a set of parentheses within a match expressions.
public
testFindStartInsideParenthesesNestedWithinMatch(string $testMarker, int|string $target, int|string $expectedTarget) : void
Parameters
- $testMarker : string
-
The comment which prefaces the target token in the test file.
- $target : int|string
-
The token to search for after the test marker.
- $expectedTarget : int|string
-
Token code of the expected start of statement stack pointer.
Tags
testFindStartInsideParenthesesNestedWithinNestedMatch()
Test finding the start of a statement for a token within a set of parentheses within a match expressions, which itself is nested within parentheses.
public
testFindStartInsideParenthesesNestedWithinNestedMatch(string $testMarker, int|string $target, int|string $expectedTarget) : void
Parameters
- $testMarker : string
-
The comment which prefaces the target token in the test file.
- $target : int|string
-
The token to search for after the test marker.
- $expectedTarget : int|string
-
Token code of the expected start of statement stack pointer.
Tags
testFindStartInsideShortArrayNestedWithinMatch()
Test finding the start of a statement for a token within a short array within a match expressions.
public
testFindStartInsideShortArrayNestedWithinMatch(string $testMarker, int|string $target, int|string $expectedTarget) : void
Parameters
- $testMarker : string
-
The comment which prefaces the target token in the test file.
- $target : int|string
-
The token to search for after the test marker.
- $expectedTarget : int|string
-
Token code of the expected start of statement stack pointer.
Tags
testFindStartInsideSwitchCaseDefaultStatements()
Test finding the start of a statement inside a switch control structure case/default statement.
public
testFindStartInsideSwitchCaseDefaultStatements(string $testMarker, int|string $targets, string|int $expectedTarget) : void
Parameters
- $testMarker : string
-
The comment which prefaces the target token in the test file.
- $targets : int|string
-
The token to search for after the test marker.
- $expectedTarget : string|int
-
Token code of the expected start of statement stack pointer.
Tags
testFunctionCall()
Test a function call.
public
testFunctionCall() : void
testFunctionCallArgument()
Test a function call.
public
testFunctionCallArgument() : void
testHeredocFunctionArg()
Test using a heredoc in a function argument.
public
testHeredocFunctionArg() : void
testMatchArray()
Test match expression with array declaration.
public
testMatchArray() : void
testMatchCase()
Test simple match expression case.
public
testMatchCase() : void
testMatchClosure()
Test match expression with closure.
public
testMatchClosure() : void
testMatchDefault()
Test simple match expression default case.
public
testMatchDefault() : void
testMatchDefaultComma()
Test match expression default case with trailing comma.
public
testMatchDefaultComma() : void
testMatchFunctionCall()
Test match expression with function call.
public
testMatchFunctionCall() : void
testMatchFunctionCallArm()
Test match expression with function call in the arm.
public
testMatchFunctionCallArm() : void
testMatchMultipleCase()
Test multiple comma-separated match expression case values.
public
testMatchMultipleCase() : void
testNestedMatch()
Test nested match expressions.
public
testNestedMatch() : void
testObjectCallPrecededByArrowFunctionAsFunctionCallParameterInArray()
Test object call on result of static function call with arrow function as parameter and wrapped within an array.
public
testObjectCallPrecededByArrowFunctionAsFunctionCallParameterInArray() : void
Tags
testOpenTag()
Test PHP open tag.
public
testOpenTag() : void
testOpenTagWithEcho()
Test PHP short open echo tag.
public
testOpenTagWithEcho() : void
testSimpleAssignment()
Test a simple assignment.
public
testSimpleAssignment() : void
testStartIsNeverMoreThanCurrentToken()
Test that start of statement is NEVER beyond the "current" token.
public
testStartIsNeverMoreThanCurrentToken() : void
testStatementAsArrayValue()
Test statements that are array values.
public
testStatementAsArrayValue() : void
testStaticArrowFunction()
Test static arrow function.
public
testStaticArrowFunction() : void
testSwitch()
Test parts of a switch statement.
public
testSwitch() : void
testUseGroup()
Test a use group.
public
testUseGroup() : void