3 * Filter the code to make it compatible with phpBB Coding Standards
7 * LICENSE: This source file is subject to version 3.0 of the PHP license
8 * that is available through the world-wide-web at the following URI:
9 * http://www.php.net/license/3_0.txt. If you did not receive a copy of
10 * the PHP License and are unable to obtain it through the web, please
11 * send a note to license@php.net so we can mail you a copy immediately.
13 * @package PHP_Beautifier
15 * @author Jim Wigginton <terrafrost@php.net>
16 * @copyright 2008 Jim Wigginton
17 * @link http://pear.php.net/package/PHP_Beautifier
18 * @license http://www.gnu.org/licenses/lgpl.html LGPL
24 require_once ('PEAR/Config.php');
26 * Filter the code to make it compatible with phpBB Coding Standards
28 * Among other differences from the PEAR Coding Standards, the phpBB coding standards use BSD style indenting.
31 * @package PHP_Beautifier
33 * @author Jim Wigginton <terrafrost@php.net>
34 * @copyright 2008 Jim Wigginton
35 * @link http://pear.php.net/package/PHP_Beautifier
36 * @license http://www.gnu.org/licenses/lgpl.html LGPL
37 * @version Release: 0.0.1
39 class PHP_Beautifier_Filter_phpBB
extends PHP_Beautifier_Filter
41 protected $sDescription = 'Filter the code to make it compatible with phpBB Coding Standards';
42 private $iNestedIfs = 0;
43 public function __construct(PHP_Beautifier
$oBeaut, $aSettings = array())
45 parent
::__construct($oBeaut, $aSettings);
46 $oBeaut->setIndentChar("\t");
47 $oBeaut->setIndentNumber(1);
48 $oBeaut->setNewLine(PHP_EOL
);
50 function t_open_brace($sTag)
52 $this->oBeaut
->addNewLineIndent();
53 $this->oBeaut
->add($sTag);
54 $this->oBeaut
->incIndent();
55 $this->oBeaut
->addNewLineIndent();
57 function t_close_brace($sTag)
59 if ($this->oBeaut
->getMode('string_index') or $this->oBeaut
->getMode('double_quote')) {
60 $this->oBeaut
->add($sTag);
62 $this->oBeaut
->removeWhitespace();
63 $this->oBeaut
->decIndent();
64 $this->oBeaut
->addNewLineIndent();
65 $this->oBeaut
->add($sTag);
66 $this->oBeaut
->addNewLineIndent();
69 function t_else($sTag)
71 $this->oBeaut
->add($sTag);
72 if (!$this->oBeaut
->isNextTokenContent('{')) {
73 $this->oBeaut
->addNewLineIndent();
74 $this->oBeaut
->add('{');
75 $this->oBeaut
->incIndent();
76 $this->oBeaut
->addNewLineIndent();
80 function t_semi_colon($sTag)
82 $this->oBeaut
->removeWhitespace();
83 $this->oBeaut
->add($sTag);
84 if ($this->oBeaut
->getControlParenthesis() != T_FOR
) {
85 if ($this->iNestedIfs
> 0) {
86 $this->oBeaut
->decIndent();
87 $this->oBeaut
->addNewLineIndent();
88 $this->oBeaut
->add('}');
91 $this->oBeaut
->addNewLineIndent();
96 $this->iNestedIfs
= 0;