Patcher
A Unified Diff Format Patcher class
link |
This has been derived from the PhpPatcher version 0.1.1 written by Giuseppe Mazzotta |
---|---|
since |
1.0 |
package |
Joomla Framework |
Methods
__construct
Constructor
__construct() : mixed
The constructor is protected to force the use of Patcher::getInstance()
since |
1.0 |
---|
Response
mixed
add
Add a unified diff string to the patcher
add(string udiff, string root, int strip) : \Joomla\Filesystem\Patcher
since |
1.0 |
---|
Arguments
- udiff
string
Unified diff input string- root
string
The files root path- strip
int
The number of '/' to strip
Response
\Joomla\Filesystem\Patcher
$this for chaining
addFile
Add a unified diff file to the patcher
addFile(string filename, string root, int strip) : \Joomla\Filesystem\Patcher
since |
1.0 |
---|
Arguments
- filename
string
Path to the unified diff file- root
string
The files root path- strip
int
The number of '/' to strip
Response
\Joomla\Filesystem\Patcher
$this for chaining
apply
Apply the patches
apply() : int
since |
1.0 |
---|---|
throws |
|
Response
int
The number of files patched
applyHunk
Apply the patch
applyHunk(array &lines, string src, string dst, string srcLine, string srcSize, string dstLine, string dstSize) : void
since |
1.0 |
---|---|
throws |
|
Arguments
- lines
array
The udiff array of lines- src
string
The source file- dst
string
The destination file- srcLine
string
The beginning of the patch for the source file- srcSize
string
The size of the patch for the source file- dstLine
string
The beginning of the patch for the destination file- dstSize
string
The size of the patch for the destination file
findHeader
Find the diff header
findHeader(array &lines, string &src, string &dst) : bool
The internal array pointer of $lines is on the next line after the finding
since |
1.0 |
---|---|
throws |
|
Arguments
- lines
array
The udiff array of lines- src
string
The source file- dst
string
The destination file
Response
bool
TRUE in case of success, FALSE in case of failure
findHunk
Find the next hunk of difference
findHunk(array &lines, string &srcLine, string &srcSize, string &dstLine, string &dstSize) : bool
The internal array pointer of $lines is on the next line after the finding
since |
1.0 |
---|---|
throws |
|
Arguments
- lines
array
The udiff array of lines- srcLine
string
The beginning of the patch for the source file- srcSize
string
The size of the patch for the source file- dstLine
string
The beginning of the patch for the destination file- dstSize
string
The size of the patch for the destination file
Response
bool
TRUE in case of success, false in case of failure
getDestination
Get the lines of a destination file
getDestination(string dst, string src) : array
since |
1.0 |
---|
Arguments
- dst
string
The path of a destination file- src
string
The path of a source file
Response
array
The lines of the destination file
getInstance
Method to get a patcher
getInstance() : \Joomla\Filesystem\Patcher
since |
1.0 |
---|
Response
\Joomla\Filesystem\Patcher
an instance of the patcher
getSource
Get the lines of a source file
getSource(string src) : array
since |
1.0 |
---|
Arguments
- src
string
The path of a file
Response
array
The lines of the source file
reset
Reset the pacher
reset() : \Joomla\Filesystem\Patcher
since |
1.0 |
---|
Response
\Joomla\Filesystem\Patcher
This object for chaining
splitLines
Separate CR or CRLF lines
splitLines(string data) : array
since |
1.0 |
---|
Arguments
- data
string
Input string
Response
array
The lines of the input destination file
Constants
SRC_FILE
Regular expression for searching source files
Value | '/^---\\s+(\\S+)\\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\\+|-)\\d{4}/A' |
---|---|
since |
1.0 |
Type(s)
string
DST_FILE
Regular expression for searching destination files
Value | '/^\\+\\+\\+\\s+(\\S+)\\s+\\d{1,4}-\\d{1,2}-\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}(\\.\\d+)?\\s+(\\+|-)\\d{4}/A' |
---|---|
since |
1.0 |
Type(s)
string
HUNK
Regular expression for searching hunks of differences
Value | '/@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@($)/A' |
---|---|
since |
1.0 |
Type(s)
string
SPLIT
Regular expression for splitting lines
Value | '/(\\r\\n)|(\\r)|(\\n)/' |
---|---|
since |
1.0 |
Type(s)
string
Properties
sources
Source files
since |
1.0 |
---|
Type(s)
array
destinations
Destination files
since |
1.0 |
---|
Type(s)
array
removals
Removal files
since |
1.0 |
---|
Type(s)
array
patches
Patches
since |
1.0 |
---|
Type(s)
array
instance
Singleton instance of this class
since |
1.0 |
---|
Type(s)
\Joomla\Filesystem\Patcher