File_SearchReplace
[ class tree: File_SearchReplace ] [ index: File_SearchReplace ] [ all elements ]

Class: File_SearchReplace

Source Location: /File_SearchReplace-1.1.4/File/SearchReplace.php

Class Overview


Search and Replace Utility


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 50]
Search and Replace Utility


[ Top ]


Class Variables

$directories =

[line 58]


Type:   mixed


[ Top ]

$files =

[line 57]


Type:   mixed


[ Top ]

$find =

[line 55]


Type:   mixed


[ Top ]

$ignore_lines =

[line 60]


Type:   mixed


[ Top ]

$ignore_sep =

[line 61]


Type:   mixed


[ Top ]

$include_subdir =

[line 59]


Type:   mixed


[ Top ]

$last_error =

[line 65]


Type:   mixed


[ Top ]

$occurences =

[line 62]


Type:   mixed


[ Top ]

$php5 =

[line 64]


Type:   mixed


[ Top ]

$replace =

[line 56]


Type:   mixed


[ Top ]

$search_function =

[line 63]


Type:   mixed


[ Top ]



Method Detail

File_SearchReplace (Constructor)   [line 85]

File_SearchReplace File_SearchReplace( string $find, string $replace, array $files, [array $directories = ''], [bool $include_subdir = true], [array $ignore_lines = array()])

Sets up the object
  • Access: public

Parameters:

string   $find   —  The string/regex to find.
string   $replace   —  The string/regex to replace $find with.
array   $files   —  The file(s) to perform this operation on.
array   $directories   —  The directories to perform this operation on.
bool   $include_subdir   —  If performing on directories, whether to traverse subdirectories.
array   $ignore_lines   —  Ignore lines beginning with any of the strings in this array. This feature only works with the "normal" search.

[ Top ]

doReplace   [line 578]

void doReplace( )

This starts the search/replace off. Call this to do the replace.

First do whatever files are specified, and/or if directories are specified, do those too.

  • Access: public

[ Top ]

doSearch   [line 562]

void doSearch( )

This starts the search/replace off. The behavior of this function will likely to be changed in future versions to work in read only mode. If you want to do actual replace with writing files - use doReplace method instead.
  • Access: public

[ Top ]

getFind   [line 600]

array getFind( )

Helper method to ensure we always have an array of things to find.
  • Access: public

[ Top ]

getLastError   [line 128]

string getLastError( )

Accessor for retrieving last error.
  • Return: The last error that occurred, if any.
  • Access: public

[ Top ]

getNumOccurences   [line 114]

int getNumOccurences( )

Accessor to return the number of occurences found.
  • Return: Number of occurences found.
  • Access: public

[ Top ]

getReplace   [line 611]

mixed getReplace( )

Helper method to fetch replace
  • Access: public

[ Top ]

setDirectories   [line 193]

void setDirectories( array $directories)

Accessor for setting directories variable.
  • Access: public

Parameters:

array   $directories   —  The directories to perform this operation on.

[ Top ]

setFiles   [line 177]

void setFiles( array $files)

Accessor for setting files variable.
  • Access: public

Parameters:

array   $files   —  The file(s) to perform this operation on.

[ Top ]

setFind   [line 144]

void setFind( mixed $find)

Accessor for setting find variable.
  • Access: public

Parameters:

mixed   $find   —  The string/regex to find, or array of strings

[ Top ]

setIgnoreLines   [line 227]

void setIgnoreLines( array $ignore_lines)

Accessor for setting ignore_lines variable.
  • Access: public

Parameters:

array   $ignore_lines   —  Ignore lines beginning with any of the strings in this array. This feature only works with the "normal" search.

[ Top ]

setIncludeSubdir   [line 209]

void setIncludeSubdir( bool $include_subdir)

Accessor for setting include_subdir variable.
  • Access: public

Parameters:

bool   $include_subdir   —  Whether to traverse subdirectories or not.

[ Top ]

setReplace   [line 161]

void setReplace( mixed $replace)

Accessor for setting replace variable.
  • Access: public

Parameters:

mixed   $replace   —  The string/regex to replace the find string/regex with, or array of strings

[ Top ]

setSearchFunction   [line 250]

void setSearchFunction( string $search_function)

Function to determine which search function is used.

Can be any one of: normal - Default search. Goes line by line. Ignore lines feature only works with this type. quick - Uses str_replace for straight replacement throughout file. Quickest of the lot. preg - Uses preg_replace(), so any valid regex

  • Access: public

Parameters:

string   $search_function   —  The search function that should be used.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:40:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.