Documentation

Common
in package

Table of Contents

$allowedTypes  : array<string|int, string>
An array of variable types for param/var we will check.
cleanSniffClass()  : string
Removes project-specific information from a sniff class name.
detectLineEndings()  : string
Detects the EOL character being used in a string.
escapeshellcmd()  : string
Escape a path to a system command.
getSniffCode()  : string
Given a sniff class name, returns the code for the sniff.
isCamelCaps()  : bool
Returns true if the specified string is in the camel caps format.
isPharFile()  : mixed
Return TRUE if the path is a PHAR file.
isReadable()  : bool
Checks if a file is readable.
isStdinATTY()  : bool
Check if STDIN is a TTY.
isUnderscoreName()  : bool
Returns true if the specified string is in the underscore caps format.
prepareForOutput()  : string
Prepares token content for output to screen.
realpath()  : mixed
CodeSniffer alternative for realpath.
stripBasepath()  : string
Removes a base path from the front of a file path.
suggestType()  : string
Returns a valid variable type for param/var tags.

Properties

$allowedTypes

An array of variable types for param/var we will check.

public static array<string|int, string> $allowedTypes = ['array', 'boolean', 'float', 'integer', 'mixed', 'object', 'string', 'resource', 'callable']

Methods

cleanSniffClass()

Removes project-specific information from a sniff class name.

public static cleanSniffClass(string $sniffClass) : string
Parameters
$sniffClass : string

The fully qualified sniff class name.

Return values
string

detectLineEndings()

Detects the EOL character being used in a string.

public static detectLineEndings(string $contents) : string
Parameters
$contents : string

The contents to check.

Return values
string

escapeshellcmd()

Escape a path to a system command.

public static escapeshellcmd(string $cmd) : string
Parameters
$cmd : string

The path to the system command.

Return values
string

getSniffCode()

Given a sniff class name, returns the code for the sniff.

public static getSniffCode(string $sniffClass) : string
Parameters
$sniffClass : string

The fully qualified sniff class name.

Return values
string

isCamelCaps()

Returns true if the specified string is in the camel caps format.

public static isCamelCaps(string $string[, bool $classFormat = false ][, bool $public = true ][, bool $strict = true ]) : bool
Parameters
$string : string

The string the verify.

$classFormat : bool = false

If true, check to see if the string is in the class format. Class format strings must start with a capital letter and contain no underscores.

$public : bool = true

If true, the first character in the string must be an a-z character. If false, the character must be an underscore. This argument is only applicable if $classFormat is false.

$strict : bool = true

If true, the string must not have two capital letters next to each other. If false, a relaxed camel caps policy is used to allow for acronyms.

Return values
bool

isPharFile()

Return TRUE if the path is a PHAR file.

public static isPharFile(string $path) : mixed
Parameters
$path : string

The path to use.

Return values
mixed

isReadable()

Checks if a file is readable.

public static isReadable(string $path) : bool

Addresses PHP bug related to reading files from network drives on Windows. e.g. when using WSL2.

Parameters
$path : string

The path to the file.

Return values
bool

isStdinATTY()

Check if STDIN is a TTY.

public static isStdinATTY() : bool
Return values
bool

isUnderscoreName()

Returns true if the specified string is in the underscore caps format.

public static isUnderscoreName(string $string) : bool
Parameters
$string : string

The string to verify.

Return values
bool

prepareForOutput()

Prepares token content for output to screen.

public static prepareForOutput(string $content[, array<string|int, string> $exclude = [] ]) : string

Replaces invisible characters so they are visible. On non-Windows operating systems it will also colour the invisible characters.

Parameters
$content : string

The content to prepare.

$exclude : array<string|int, string> = []

A list of characters to leave invisible. Can contain \r, \n, \t and a space.

Return values
string

realpath()

CodeSniffer alternative for realpath.

public static realpath(string $path) : mixed

Allows for PHAR support.

Parameters
$path : string

The path to use.

Return values
mixed

stripBasepath()

Removes a base path from the front of a file path.

public static stripBasepath(string $path, string $basepath) : string
Parameters
$path : string

The path of the file.

$basepath : string

The base path to remove. This should not end with a directory separator.

Return values
string

suggestType()

Returns a valid variable type for param/var tags.

public static suggestType(string $varType) : string

If type is not one of the standard types, it must be a custom type. Returns the correct type name suggestion if type name is invalid.

Parameters
$varType : string

The variable type to process.

Return values
string

Search results