Documentation

Cli
in package

Tags
phpstan-import-type

Errors from \CssLint\Linter

phpstan-import-type

LintConfigurationOptions from \CssLint\LintConfiguration

Table of Contents

Constants

RETURN_CODE_ERROR  = 1
RETURN_CODE_SUCCESS  = 0
SCRIPT_NAME  = 'php-css-lint'

Properties

$formatterFactory  : FormatterFactory|null
$formatterManager  : FormatterManager

Methods

run()  : int
Entrypoint of the cli, will execute the linter according to the given arguments
assertOptionsAreLintConfiguration()  : void
getFormatterFactory()  : FormatterFactory
getLintConfigurationFromOptions()  : LintConfiguration
Retrieve the properties from the given options
isGlobPattern()  : bool
Checks if a given string is a glob pattern.
lintFile()  : int
Performs lint on a given file path
lintGlob()  : int
lintInput()  : int
lintString()  : int
Performs lint on a given string
parseArguments()  : CliArgs
Retrieve the parsed Cli arguments from given arguments array
printLine()  : void
Display the given message in a new line
printLinterErrors()  : int
Display the errors returned by the linter
printUsage()  : void
Display usage of the cli

Constants

RETURN_CODE_ERROR

private mixed RETURN_CODE_ERROR = 1

RETURN_CODE_SUCCESS

private mixed RETURN_CODE_SUCCESS = 0

SCRIPT_NAME

private mixed SCRIPT_NAME = 'php-css-lint'

Properties

Methods

run()

Entrypoint of the cli, will execute the linter according to the given arguments

public run(array<string|int, string> $arguments) : int
Parameters
$arguments : array<string|int, string>

arguments to be parsed (@see $_SERVER['argv'])

Return values
int

the return code related to the execution of the linter

assertOptionsAreLintConfiguration()

private assertOptionsAreLintConfiguration(mixed $options) : void
Parameters
$options : mixed
Tags
phpstan-assert

LintConfigurationOptions $options

getLintConfigurationFromOptions()

Retrieve the properties from the given options

private getLintConfigurationFromOptions(string $options) : LintConfiguration
Parameters
$options : string

the options to be parsed

Return values
LintConfiguration

isGlobPattern()

Checks if a given string is a glob pattern.

private isGlobPattern(string $pattern) : bool

A glob pattern typically includes wildcard characters:

  • '*' matches any sequence of characters.
  • '?' matches any single character.
  • '[]' matches any one character in the specified set.

Optionally, if using the GLOB_BRACE flag, brace patterns like {foo,bar} are also valid.

Parameters
$pattern : string

The string to evaluate.

Return values
bool

True if the string is a glob pattern, false otherwise.

lintFile()

Performs lint on a given file path

private lintFile(Linter $cssLinter, string $filePath) : int
Parameters
$cssLinter : Linter

the instance of the linter

$filePath : string

the path of the file to be linted

Return values
int

the return code related to the execution of the linter

lintGlob()

private lintGlob(string $glob) : int
Parameters
$glob : string
Return values
int

lintInput()

private lintInput(Linter $cssLinter, string $input) : int
Parameters
$cssLinter : Linter
$input : string
Return values
int

lintString()

Performs lint on a given string

private lintString(Linter $cssLinter, string $stringValue) : int
Parameters
$cssLinter : Linter

the instance of the linter

$stringValue : string

the CSS string to be linted

Return values
int

the return code related to the execution of the linter

parseArguments()

Retrieve the parsed Cli arguments from given arguments array

private parseArguments(array<string|int, string> $arguments) : CliArgs
Parameters
$arguments : array<string|int, string>

arguments to be parsed (@see $_SERVER['argv'])

Return values
CliArgs

an instance of Cli arguments object containing parsed arguments

printLine()

Display the given message in a new line

private printLine(string $message) : void
Parameters
$message : string

the message to be displayed

printLinterErrors()

Display the errors returned by the linter

private printLinterErrors(string $source, Generator<string|int, LintError$errors) : int
Parameters
$source : string
$errors : Generator<string|int, LintError>

the generated errors to be displayed

Return values
int

the return code related to the execution of the linter

printUsage()

Display usage of the cli

private printUsage() : void

        
On this page

Search results