PHP Class Mutagenesis\Mutable

Datei anzeigen Open project: padraic/mutagenesis Class Usage Examples

Protected Properties

Property Type Description
$_filename string Name and relative path of the file to be mutated
$_mutables array Array of mutable elements located in file
$_mutations array An array of generated mutations to be sequentially tested

Public Methods

Method Description
__construct ( string $filename = null ) Constructor; sets name and relative path of the file being mutated
_parseTString ( array $token ) : string Parse a T_STRING value to identify a possible mutation type
cleanup ( ) Cleanup routines for memory management
generate ( ) : void Based on the current file, generate mutations
getFilename ( ) : string Return the file path of the file which is currently being assessed for mutations.
getMutables ( ) : array Get an array of method metainfo in tokenised form representing methods which are capable of being mutated. Note: This does not guarantee they will be mutated since this depends on the scope of supported mutations.
getMutations ( ) : array Get an array of Class & Method indexed mutations containing the mutated token and that token's index in the method's block code.
hasMutation ( string $type ) : boolean Check whether the current file will contain a mutation of the given type
setFilename ( string $filename ) Set the file path of the file which is currently being assessed for mutations.

Protected Methods

Method Description
_parseMutables ( ) : array Parse the given file into an array of method metainformation including class name, method name, file name, method arguments, and method body tokens.
_parseStringToken ( array $token, integer $index ) : mixed Parse a given token (in string form) to identify its type and ascertain whether it can be replaced with a mutated form. The mutated form, if any, is returned for future integration into a mutated version of the source code being tested.
_parseToken ( array $token, integer $index ) : mixed Parse a given token (in array form) to identify its type and ascertain whether it can be replaced with a mutated form. The mutated form, if any, is returned for future integration into a mutated version of the source code being tested.
_parseTokensToMutations ( array $mutables ) : void Based on the internal array of mutable methods, generate another internal array of supported mutations accessible using getMutations().
_reconstructFromTokens ( array $tokens ) : string Reconstruct a string of source code from its constituent tokens

Method Details

__construct() public method

Constructor; sets name and relative path of the file being mutated
public __construct ( string $filename = null )
$filename string

_parseMutables() protected method

Parse the given file into an array of method metainformation including class name, method name, file name, method arguments, and method body tokens.
protected _parseMutables ( ) : array
return array

_parseStringToken() protected method

Parse a given token (in string form) to identify its type and ascertain whether it can be replaced with a mutated form. The mutated form, if any, is returned for future integration into a mutated version of the source code being tested.
protected _parseStringToken ( array $token, integer $index ) : mixed
$token array The token to check for viable mutations
$index integer The index of the token in the method's body
return mixed Return null if no mutation, or a mutation object

_parseTString() public method

Parse a T_STRING value to identify a possible mutation type
public _parseTString ( array $token ) : string
$token array
return string

_parseToken() protected method

Parse a given token (in array form) to identify its type and ascertain whether it can be replaced with a mutated form. The mutated form, if any, is returned for future integration into a mutated version of the source code being tested.
protected _parseToken ( array $token, integer $index ) : mixed
$token array The token to check for viable mutations
$index integer The index of the token in the method's body
return mixed Return null if no mutation, or a mutation object

_parseTokensToMutations() protected method

Based on the internal array of mutable methods, generate another internal array of supported mutations accessible using getMutations().
protected _parseTokensToMutations ( array $mutables ) : void
$mutables array
return void

_reconstructFromTokens() protected method

Reconstruct a string of source code from its constituent tokens
protected _reconstructFromTokens ( array $tokens ) : string
$tokens array
return string

cleanup() public method

Cleanup routines for memory management
public cleanup ( )

generate() public method

Based on the current file, generate mutations
public generate ( ) : void
return void

getFilename() public method

Return the file path of the file which is currently being assessed for mutations.
public getFilename ( ) : string
return string

getMutables() public method

Get an array of method metainfo in tokenised form representing methods which are capable of being mutated. Note: This does not guarantee they will be mutated since this depends on the scope of supported mutations.
public getMutables ( ) : array
return array

getMutations() public method

Get an array of Class & Method indexed mutations containing the mutated token and that token's index in the method's block code.
public getMutations ( ) : array
return array

hasMutation() public method

Check whether the current file will contain a mutation of the given type
public hasMutation ( string $type ) : boolean
$type string The mutation type as documented
return boolean

setFilename() public method

Set the file path of the file which is currently being assessed for mutations.
public setFilename ( string $filename )
$filename string

Property Details

$_filename protected_oe property

Name and relative path of the file to be mutated
protected string $_filename
return string

$_mutables protected_oe property

Array of mutable elements located in file
protected array $_mutables
return array

$_mutations protected_oe property

An array of generated mutations to be sequentially tested
protected array $_mutations
return array