Previous Next
Command Line use Create Filters

Filter architecture

How Filters works and how to use them

Claudio Bustos cdx@users.sourceforge.com Jens Bierkandt scortch@users.sourceforge.com

Table of Contents

Filters architecture

PHP_Beautifier class tokenize the script, send the tokens to the Filters and, finally, create some type of output. All the beautify process are made by the Filters.

The Filters are managed as a stack in LIFO order (Last In, First Out). If the first Filter doesn't have a method to process the token or send a bypass signal, the second one is called and so on. The last filter (PHP_Beautifier_Filter_Default) is included by default and send the token unchanged if doesn't have a method to handle it.

The Filters have the option to made changes to the output at the end of the processing, using the method PHP_Beautifier_Filter::postProcessing()

Use filters

General

The default Filter and the standard ones resides in {install_dir}/Filter. The name of the file for each filter is '{FILTER_NAME}.filter.php' and the names of class is 'PHP_Beautifier_Filter_{FILTER_NAME}'. Look the source code of PHP_Beautifier_Filter_Default for an example.

You can create your own filters and include they on the default dir. If you use another directory to the Filters, read the next sections to handle this

Use with PHP_Beautifier class

You can create new Filters in others directorys than the default. Use PHP_Beautifier::addFilterDirectory()

To add a Filter, use PHP_Beautifier::addFilter()

Use with command line

In the command line, you can add Filter using the --filters or -l options. The Filters are separated by spaces and if they accept arguments, they are separated by commas. Remember to quote the complete definition inside double quotes.

See Command Line use

beautifier_php --filters "Pear(add_header=>php) ArrayNested"

Use with Web Frontend

TODO

Previous Next
Command Line use Create Filters

Documentation generated on Mon, 31 May 2010 16:16:02 -0400 by phpDocumentor 1.4.3