Elgg  Version 2.3
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Project\CodeStyle Class Reference

Public Member Functions

 fixDirectory ($root, $dry_run=false)
 Fix problems in a directory of files and return a report. More...
 
 findFilesToAnalyze ($root)
 Find files which can be analyzed/fixed by this component. More...
 
 analyzeFile ($filepath, $content=null)
 Analyze a file for problems and return a report. More...
 

Public Attributes

const KEY_NEW_CONTENT = 'new_content'
 
const KEY_REMAINING = 'remaining'
 
const KEY_CORRECTIONS = 'corrections'
 

Protected Member Functions

 findFiles ($dir, &$files)
 Find files within a directory (recurse for subdirectories) More...
 
 normalizePath ($path)
 Normalize a path. More...
 

Protected Attributes

 $file_pattern = '~\.(?:php|js|css|xml|json|yml|txt|rst|md|gitignore|htaccess|mailmap|sh)$~'
 
 $substr_start
 

Detailed Description

Definition at line 13 of file CodeStyle.php.

Member Function Documentation

Elgg\Project\CodeStyle::analyzeFile (   $filepath,
  $content = null 
)

Analyze a file for problems and return a report.

Parameters
string$filepathPath of file to analyze
string$contentThe file's content (optional)
Returns
array Report with keys:
remaining_problems : string[]    Problems which could not be fixed
corrections        : string[]    Problems which were fixed
new_content        : string|null Null if no corrections made, otherwise the corrected content

Definition at line 96 of file CodeStyle.php.

Elgg\Project\CodeStyle::findFiles (   $dir,
$files 
)
protected

Find files within a directory (recurse for subdirectories)

Parameters
string$dirDirectory to search
array&$filesReference to found files
Returns
void

Definition at line 147 of file CodeStyle.php.

Elgg\Project\CodeStyle::findFilesToAnalyze (   $root)

Find files which can be analyzed/fixed by this component.

Parameters
string$rootRoot directory
Returns
string[] File paths. All directory separators will be "/"

Definition at line 77 of file CodeStyle.php.

Elgg\Project\CodeStyle::fixDirectory (   $root,
  $dry_run = false 
)

Fix problems in a directory of files and return a report.

Parameters
string$rootRoot directory
bool$dry_runIf set to true, no files will be written
Returns
array Report of notable files

Definition at line 38 of file CodeStyle.php.

Elgg\Project\CodeStyle::normalizePath (   $path)
protected

Normalize a path.

Parameters
string$pathA file/dir path
Returns
string

Definition at line 194 of file CodeStyle.php.

Member Data Documentation

Elgg\Project\CodeStyle::$file_pattern = '~\.(?:php|js|css|xml|json|yml|txt|rst|md|gitignore|htaccess|mailmap|sh)$~'
protected

Definition at line 22 of file CodeStyle.php.

Elgg\Project\CodeStyle::$substr_start
protected

Definition at line 29 of file CodeStyle.php.

const Elgg\Project\CodeStyle::KEY_CORRECTIONS = 'corrections'

Definition at line 17 of file CodeStyle.php.

const Elgg\Project\CodeStyle::KEY_NEW_CONTENT = 'new_content'

Definition at line 15 of file CodeStyle.php.

const Elgg\Project\CodeStyle::KEY_REMAINING = 'remaining'

Definition at line 16 of file CodeStyle.php.


The documentation for this class was generated from the following file: