class PhpFixerOptions (View source)

Options for PhpFixer.

Properties

protected Repository $config
private string|null $webRoot

The absolute path to the web root directory.

private string[]|null $filterByExtensions

The list of file extensions to be parsed.

private string[]|null $filterIncludeFiles

The list of additional files (relative to the webroot) to be parsed.

private string[]|null $ignoredDirectoriesByName

The directory names that should not be parsed.

private string[]|null $ignoredDirectoriesByPath

The directory paths (relative to the webroot) that should not be parsed (allowed placeholders: ).

private string[]|null $bootstrapFiles

The file paths (relative to the webroot) that are executed before checking the PHP version.

private string[]|null $phpOnlyNonPsr4Files

The file paths (relative to the webroot) that only contain PHP and that don't follow PSR-4 class names (allowed placeholders: ).

private string[]|null $phpOnlyNonPsr4Directories

The directory paths (relative to the webroot) that contain PHP-only files that don't follow PSR-4 class names (allowed placeholders: ).

private string[]|null $phpOnlyNonPsr4Regexes

The regular expressions describing the paths (relative to the web root) that contain PHP-only files that don't follow PSR-4 class names.

private string[]|null $phpOnlyPsr4Files

The file paths (relative to the webroot) that only contain PHP and that follow PSR-4 class names (allowed placeholders: ).

private string[]|null $phpOnlyPsr4Directories

The directory paths (relative to the webroot) that contain PHP-only files that follow PSR-4 class names (allowed placeholders: ).

private string[]|null $phpOnlyPsr4Regexes

The regular expressions describing the paths (relative to the web root) that contain PHP-only files that follow PSR-4 class names.

private string[]|null $directoriesWithMixedContentsRegex

The list of regular expressions that should be used to check if a directory contains files with mixed flags.

private bool $isCacheDisabled

Is the fixers cache disabled?

private string $minimumPhpVersion

The minimum PHP version.

Methods

__construct(Repository $config)

Initialize the instance.

string
normalizePath(string $path, bool $isDir, bool $isRelative)

Normalize a path.

static string
getDefaultWebRoot()

Get the default absolute path to the web root directory.

string
getWebRoot()

Get the absolute path to the web root directory.

$this
setWebRoot(string|mixed $value)

Set the absolute path to the web root directory.

string[]
getFilterByExtensions()

Get the list of file extensions to be parsed.

$this
setFilterByExtensions(array $value)

Set the list of file extensions to be parsed.

string[]
getFilterIncludeFiles()

Get the list of additional files (relative to the webroot) to be parsed.

$this
setFilterIncludeFiles(string[] $value)

Set the list of additional files (relative to the webroot) to be parsed.

string[]
getIgnoredDirectoriesByName()

Get the directory names that should not be parsed.

$this
setIgnoredDirectoriesByName(array $value)

Set the directory names that should not be parsed.

string[]
getIgnoredDirectoriesByPath()

Get the directory paths (relative to the webroot) that should not be parsed (allowed placeholders: ).

$this
setIgnoredDirectoriesByPath(array $value)

Set the directory paths (relative to the webroot) that should not be parsed (allowed placeholders: ).

string[]
getBootstrapFiles()

Get the file paths (relative to the webroot) that are executed before checking the PHP version.

$this
setBootstrapFiles(array $value)

Set the file paths (relative to the webroot) that are executed before checking the PHP version.

string[]
getPhpOnlyNonPsr4Files()

Get the file paths (relative to the webroot) that only contain PHP and that don't follow PSR-4 class names (allowed placeholders: ).

$this
setPhpOnlyNonPsr4Files(array $value)

Set the file paths (relative to the webroot) that only contain PHP and that don't follow PSR-4 class names (allowed placeholders: ).

string[]
getPhpOnlyNonPsr4Directories()

Get the directory paths (relative to the webroot) that contain PHP-only files that don't follow PSR-4 class names (allowed placeholders: ).

$this
setPhpOnlyNonPsr4Directories(array $value)

Set the directory paths (relative to the webroot) that contain PHP-only files that don't follow PSR-4 class names (allowed placeholders: ).

string[]
getPhpOnlyNonPsr4Regexes()

Get the regular expressions describing the paths (relative to the web root) that contain PHP-only files that don't follow PSR-4 class names.

string[]
getPhpOnlyPsr4Files()

Get the file paths (relative to the webroot) that only contain PHP and that follow PSR-4 class names (allowed placeholders: ).

$this
setPhpOnlyPsr4Files(array $value)

Set the file paths (relative to the webroot) that only contain PHP and that follow PSR-4 class names (allowed placeholders: ).

string[]
getPhpOnlyPsr4Directories()

Get the directory paths (relative to the webroot) that contain PHP-only files that follow PSR-4 class names (allowed placeholders: ).

$this
setPhpOnlyPsr4Directories(array $value)

Set the directory paths (relative to the webroot) that contain PHP-only files that follow PSR-4 class names (allowed placeholders: ).

string[]
getPhpOnlyPsr4Regexes()

Get the regular expressions describing the paths (relative to the web root) that contain PHP-only files that don't follow PSR-4 class names.

bool
isCacheDisabled()

Is the fixers cache disabled.

$this
setIsCacheDisabled(bool $value)

Is the fixers cache disabled.

string
getMinimumPhpVersion()

Get the minimum PHP version.

$this
setMinimumPhpVersion(string $value)

Set the minimum PHP version.

bool
isDirectoryWithMixedContents(string $path)

Check if a directory contains PHP files with mixed flags.

string[]
getDirectoriesWithMixedContentsRegex()

Get the list of regular expressions that should be used to check if a directory contains files with mixed flags.

addDirectoriesWithMixedContentsRegex(string $path, array $directoriesWithMixedContentsRegex)

Add items to the list of regular expressions that should be used to check if a directory contains files with mixed flags.

Details

__construct(Repository $config)

Initialize the instance.

Parameters

Repository $config

string normalizePath(string $path, bool $isDir, bool $isRelative)

Normalize a path.

Parameters

string $path

the path to be normalized

bool $isDir

is $path a directory?

bool $isRelative

is $path relative to the webroot?

Return Value

string

static string getDefaultWebRoot()

Get the default absolute path to the web root directory.

Return Value

string

string getWebRoot()

Get the absolute path to the web root directory.

Return Value

string

$this setWebRoot(string|mixed $value)

Set the absolute path to the web root directory.

Parameters

string|mixed $value

Return Value

$this

Exceptions

RuntimeException

string[] getFilterByExtensions()

Get the list of file extensions to be parsed.

Return Value

string[]

always lower case, without leading dots

$this setFilterByExtensions(array $value)

Set the list of file extensions to be parsed.

Parameters

array $value

Return Value

$this

string[] getFilterIncludeFiles()

Get the list of additional files (relative to the webroot) to be parsed.

Return Value

string[]

$this setFilterIncludeFiles(string[] $value)

Set the list of additional files (relative to the webroot) to be parsed.

Parameters

string[] $value

Return Value

$this

string[] getIgnoredDirectoriesByName()

Get the directory names that should not be parsed.

Return Value

string[]

$this setIgnoredDirectoriesByName(array $value)

Set the directory names that should not be parsed.

Parameters

array $value

Return Value

$this

string[] getIgnoredDirectoriesByPath()

Get the directory paths (relative to the webroot) that should not be parsed (allowed placeholders: ).

Return Value

string[]

$this setIgnoredDirectoriesByPath(array $value)

Set the directory paths (relative to the webroot) that should not be parsed (allowed placeholders: ).

Parameters

array $value

Return Value

$this

string[] getBootstrapFiles()

Get the file paths (relative to the webroot) that are executed before checking the PHP version.

Return Value

string[]

$this setBootstrapFiles(array $value)

Set the file paths (relative to the webroot) that are executed before checking the PHP version.

Parameters

array $value

Return Value

$this

string[] getPhpOnlyNonPsr4Files()

Get the file paths (relative to the webroot) that only contain PHP and that don't follow PSR-4 class names (allowed placeholders: ).

Return Value

string[]

$this setPhpOnlyNonPsr4Files(array $value)

Set the file paths (relative to the webroot) that only contain PHP and that don't follow PSR-4 class names (allowed placeholders: ).

Parameters

array $value

Return Value

$this

string[] getPhpOnlyNonPsr4Directories()

Get the directory paths (relative to the webroot) that contain PHP-only files that don't follow PSR-4 class names (allowed placeholders: ).

Return Value

string[]

$this setPhpOnlyNonPsr4Directories(array $value)

Set the directory paths (relative to the webroot) that contain PHP-only files that don't follow PSR-4 class names (allowed placeholders: ).

Parameters

array $value

Return Value

$this

string[] getPhpOnlyNonPsr4Regexes()

Get the regular expressions describing the paths (relative to the web root) that contain PHP-only files that don't follow PSR-4 class names.

Return Value

string[]

string[] getPhpOnlyPsr4Files()

Get the file paths (relative to the webroot) that only contain PHP and that follow PSR-4 class names (allowed placeholders: ).

Return Value

string[]

$this setPhpOnlyPsr4Files(array $value)

Set the file paths (relative to the webroot) that only contain PHP and that follow PSR-4 class names (allowed placeholders: ).

Parameters

array $value

Return Value

$this

string[] getPhpOnlyPsr4Directories()

Get the directory paths (relative to the webroot) that contain PHP-only files that follow PSR-4 class names (allowed placeholders: ).

Return Value

string[]

$this setPhpOnlyPsr4Directories(array $value)

Set the directory paths (relative to the webroot) that contain PHP-only files that follow PSR-4 class names (allowed placeholders: ).

Parameters

array $value

Return Value

$this

string[] getPhpOnlyPsr4Regexes()

Get the regular expressions describing the paths (relative to the web root) that contain PHP-only files that don't follow PSR-4 class names.

Return Value

string[]

bool isCacheDisabled()

Is the fixers cache disabled.

Return Value

bool

$this setIsCacheDisabled(bool $value)

Is the fixers cache disabled.

Parameters

bool $value

Return Value

$this

string getMinimumPhpVersion()

Get the minimum PHP version.

Return Value

string

empty string if the default one

$this setMinimumPhpVersion(string $value)

Set the minimum PHP version.

Parameters

string $value

empty string if the default one

Return Value

$this

bool isDirectoryWithMixedContents(string $path)

Check if a directory contains PHP files with mixed flags.

Parameters

string $path

the normalized relative path of the directory

Return Value

bool

protected string[] getDirectoriesWithMixedContentsRegex()

Get the list of regular expressions that should be used to check if a directory contains files with mixed flags.

Return Value

string[]

protected addDirectoriesWithMixedContentsRegex(string $path, array $directoriesWithMixedContentsRegex)

Add items to the list of regular expressions that should be used to check if a directory contains files with mixed flags.

Parameters

string $path

the normalized relative path

array $directoriesWithMixedContentsRegex