Documentation

NamedFunctionCallArgumentsTest extends AbstractTokenizerTestCase
in package

FinalYes

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

clearResolvedTokensCache()  : void
Clear the static "resolved tokens" cache property on the Tokenizer\PHP class.
dataNamedFunctionCallArguments()  : array<string, array<string, string|array<string|int, string>>>
Data provider.
dataOtherColonsInTernary()  : array<string, array<string, string>>
Data provider.
dataOtherTstringInFunctionCall()  : array<string, array<string, string>>
Data provider.
dataReservedKeywordsAsName()  : array<string, array<string|int, string|array<string|int, string|int>>>
Data provider.
testMixedPositionalAndNamedArgsWithTernary()  : void
Verify whether the colons are tokenized correctly when a ternary is used in a mixed positional and named arguments function call.
testNamedArgWithTernary()  : void
Verify whether the colons are tokenized correctly when a ternary is used in a named arguments function call.
testNamedFunctionCallArguments()  : void
Verify that parameter labels are tokenized as T_PARAM_NAME and that the colon after it is tokenized as a T_COLON.
testOtherColonsInTernary()  : void
Verify whether the colons are tokenized correctly when a return type is used for an inline closure/arrow function declaration in a ternary.
testOtherTstringInFunctionCall()  : void
Verify that other T_STRING tokens within a function call are still tokenized as T_STRING.
testParseErrorVariableLabel()  : void
Verify that a variable parameter label (parse error) is still tokenized as T_VARIABLE.
testReservedKeywordsAsName()  : void
Verify that reserved keywords used as a parameter label are tokenized as T_PARAM_NAME and that the colon after it is tokenized as a T_COLON.
testSwitchStatement()  : void
Verify whether the colons are tokenized correctly in a switch statement.
testTernaryWithConstantsInThenElse()  : void
Verify whether the colons are tokenized correctly when constants are used in a ternary.
testTernaryWithFunctionCallsInThenElse()  : void
Verify whether the colons are tokenized correctly when named arguments function calls are used in a ternary.
getTargetToken()  : 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.

Properties

$fileExtension

The file extension of the test case file (without leading dot).

protected 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 File $phpcsFile

$tabWidth

The tab width setting to use when tokenizing the file.

protected int $tabWidth = 4

This allows for test case files to use a different tab width than the default.

Methods

clearResolvedTokensCache()

Clear the static "resolved tokens" cache property on the Tokenizer\PHP class.

public static clearResolvedTokensCache() : void

This method should be used selectively by tests to ensure the code under test is actually hit by the test testing the code.

dataNamedFunctionCallArguments()

Data provider.

public static dataNamedFunctionCallArguments() : array<string, array<string, string|array<string|int, string>>>
Tags
see
testNamedFunctionCallArguments()
Return values
array<string, array<string, string|array<string|int, string>>>

dataOtherColonsInTernary()

Data provider.

public static dataOtherColonsInTernary() : array<string, array<string, string>>
Tags
see
testOtherColonsInTernary()
Return values
array<string, array<string, string>>

dataOtherTstringInFunctionCall()

Data provider.

public static dataOtherTstringInFunctionCall() : array<string, array<string, string>>
Tags
see
testOtherTstringInFunctionCall()
Return values
array<string, array<string, string>>

dataReservedKeywordsAsName()

Data provider.

public static dataReservedKeywordsAsName() : array<string, array<string|int, string|array<string|int, string|int>>>
Tags
see
testReservedKeywordsAsName()
Return values
array<string, array<string|int, string|array<string|int, string|int>>>

testMixedPositionalAndNamedArgsWithTernary()

Verify whether the colons are tokenized correctly when a ternary is used in a mixed positional and named arguments function call.

public testMixedPositionalAndNamedArgsWithTernary() : void
Tags
covers

testNamedArgWithTernary()

Verify whether the colons are tokenized correctly when a ternary is used in a named arguments function call.

public testNamedArgWithTernary() : void
Tags
covers

testNamedFunctionCallArguments()

Verify that parameter labels are tokenized as T_PARAM_NAME and that the colon after it is tokenized as a T_COLON.

public testNamedFunctionCallArguments(string $testMarker, array<string|int, string> $parameters) : void
Parameters
$testMarker : string

The comment prefacing the target token.

$parameters : array<string|int, string>

The token content for each parameter label to look for.

Tags
dataProvider

dataNamedFunctionCallArguments

covers

testOtherColonsInTernary()

Verify whether the colons are tokenized correctly when a return type is used for an inline closure/arrow function declaration in a ternary.

public testOtherColonsInTernary(string $testMarker) : void
Parameters
$testMarker : string

The comment prefacing the target token.

Tags
dataProvider

dataOtherColonsInTernary

covers

testOtherTstringInFunctionCall()

Verify that other T_STRING tokens within a function call are still tokenized as T_STRING.

public testOtherTstringInFunctionCall(string $testMarker, string $content) : void
Parameters
$testMarker : string

The comment prefacing the target token.

$content : string

The token content to look for.

Tags
dataProvider

dataOtherTstringInFunctionCall

covers

testParseErrorVariableLabel()

Verify that a variable parameter label (parse error) is still tokenized as T_VARIABLE.

public testParseErrorVariableLabel() : void
Tags
covers

testReservedKeywordsAsName()

Verify that reserved keywords used as a parameter label are tokenized as T_PARAM_NAME and that the colon after it is tokenized as a T_COLON.

public testReservedKeywordsAsName(string $testMarker, array<string|int, string|int> $tokenTypes, string $tokenContent) : void
Parameters
$testMarker : string

The comment prefacing the target token.

$tokenTypes : array<string|int, string|int>

The token codes to look for.

$tokenContent : string

The token content to look for.

Tags
dataProvider

dataReservedKeywordsAsName

covers

testSwitchStatement()

Verify whether the colons are tokenized correctly in a switch statement.

public testSwitchStatement() : void
Tags
covers

testTernaryWithConstantsInThenElse()

Verify whether the colons are tokenized correctly when constants are used in a ternary.

public testTernaryWithConstantsInThenElse() : void
Tags
covers

testTernaryWithFunctionCallsInThenElse()

Verify whether the colons are tokenized correctly when named arguments function calls are used in a ternary.

public testTernaryWithFunctionCallsInThenElse() : void
Tags
covers

getTargetToken()

Get the token pointer for a target token based on a specific comment found on the line before.

protected 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
int

initializeFile()

Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.

protected 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
before

        
On this page

Search results