Patcher
A Unified Diff Format Patcher class
| link |
This has been derived from the PhpPatcher version 0.1.1 written by Giuseppe Mazzotta |
|---|---|
| since |
3.0.0 |
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher instead. |
| package |
Joomla CMS |
Methods
__construct
Constructor
__construct() :
The constructor is protected to force the use of FilesystemPatcher::getInstance()
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::__construct() instead. |
Response
mixed
add
Add a unified diff string to the patcher
add( udiff, root = JPATH_BASE, strip) : \Joomla\CMS\Filesystem\Patcher
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::add() instead. |
Arguments
- udiff
stringUnified diff input string- root
stringThe files root path- strip
intThe number of '/' to strip
Response
Patcher$this for chaining
addFile
Add a unified diff file to the patcher
addFile( filename, root = JPATH_BASE, strip) : \Joomla\CMS\Filesystem\Patcher
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::addFile() instead. |
Arguments
- filename
stringPath to the unified diff file- root
stringThe files root path- strip
intThe number of '/' to strip
Response
Patcher$this for chaining
apply
Apply the patches
apply() :
| since |
3.0.0 |
|---|---|
| throws |
|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::apply() instead. |
Response
intThe number of files patched
applyHunk
Apply the patch
applyHunk(mixed||string|int &lines, src, dst, srcLine, srcSize, dstLine, dstSize) :
| since |
3.0.0 |
|---|---|
| throws |
|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::applyHunk() instead. |
Arguments
- lines
array<string|int, mixed>The udiff array of lines- src
stringThe source file- dst
stringThe destination file- srcLine
stringThe beginning of the patch for the source file- srcSize
stringThe size of the patch for the source file- dstLine
stringThe beginning of the patch for the destination file- dstSize
stringThe size of the patch for the destination file
Response
void
findHeader
Find the diff header
findHeader(mixed||string|int &lines, &src, &dst) :
The internal array pointer of $lines is on the next line after the finding
| since |
3.0.0 |
|---|---|
| throws |
|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::findHeader() instead. |
Arguments
- lines
array<string|int, mixed>The udiff array of lines- src
stringThe source file- dst
stringThe destination file
Response
boolTRUE in case of success, FALSE in case of failure
findHunk
Find the next hunk of difference
findHunk(mixed||string|int &lines, &srcLine, &srcSize, &dstLine, &dstSize) :
The internal array pointer of $lines is on the next line after the finding
| since |
3.0.0 |
|---|---|
| throws |
|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::findHunk() instead. |
Arguments
- lines
array<string|int, mixed>The udiff array of lines- srcLine
stringThe beginning of the patch for the source file- srcSize
stringThe size of the patch for the source file- dstLine
stringThe beginning of the patch for the destination file- dstSize
stringThe size of the patch for the destination file
Response
boolTRUE in case of success, false in case of failure
getDestination
Get the lines of a destination file
getDestination( dst, src) : mixed||string|int
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::getDestination() instead. |
Arguments
- dst
stringThe path of a destination file- src
stringThe path of a source file
Response
array<string|int, mixed>The lines of the destination file
getInstance
Method to get a patcher
getInstance() : \Joomla\CMS\Filesystem\Patcher
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::getInstance() instead. |
Response
Patcheran instance of the patcher
getSource
Get the lines of a source file
getSource( src) : mixed||string|int
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::getSource() instead. |
Arguments
- src
stringThe path of a file
Response
array<string|int, mixed>The lines of the source file
reset
Reset the patcher
reset() : \Joomla\CMS\Filesystem\Patcher
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::reset() instead. |
Response
PatcherThis object for chaining
splitLines
Separate CR or CRLF lines
splitLines( data) : mixed||string|int
| since |
3.0.0 |
|---|---|
| deprecated |
4.4 will be removed in 6.0 Use Joomla\Filesystem\Patcher::splitLines() instead. |
Arguments
- data
stringInput string
Response
array<string|int, mixed>The lines of the inputdestination 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' |
|---|
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' |
|---|
HUNK
Regular expression for searching hunks of differences
| Value | '/@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@($)/A' |
|---|
SPLIT
Regular expression for splitting lines
| Value | '/(\\r\\n)|(\\r)|(\\n)/' |
|---|
Properties
sources
sources files
| since |
3.0.0 |
|---|
Type(s)
array<string|int, mixed>
destinations
destination files
| since |
3.0.0 |
|---|
Type(s)
array<string|int, mixed>
removals
removal files
| since |
3.0.0 |
|---|
Type(s)
array<string|int, mixed>
patches
patches
| since |
3.0.0 |
|---|
Type(s)
array<string|int, mixed>
instance
instance of this class
| since |
3.0.0 |
|---|
Type(s)
array<string|int, mixed>