Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a lot of ERRORs in the PHP Code Sniffer, now is more Pear Code …

…Style
  • Loading branch information...
commit c59083ee52737af9a098cfb780a4bbdcb06d9664 1 parent 582a95c
@jespino jespino authored
View
44 Beautifier/Filter/ArrayNested.filter.php
@@ -10,15 +10,16 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Filter Array Nested: Indent the array structures
@@ -35,18 +36,27 @@
* )
* );
* </CODE>
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
class PHP_Beautifier_Filter_ArrayNested extends PHP_Beautifier_Filter
{
+ /**
+ * t_parenthesis_open
+ *
+ * @param mixed $sTag The tag to be procesed
+ *
+ * @access public
+ * @return void
+ */
public function t_parenthesis_open($sTag)
{
$this->oBeaut->add($sTag);
@@ -56,6 +66,14 @@ public function t_parenthesis_open($sTag)
$this->oBeaut->addIndent();
}
}
+ /**
+ * t_parenthesis_close
+ *
+ * @param mixed $sTag The tag to be procesed
+ *
+ * @access public
+ * @return void
+ */
public function t_parenthesis_close($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -70,6 +88,14 @@ public function t_parenthesis_close($sTag)
$this->oBeaut->add($sTag . ' ');
}
}
+ /**
+ * t_comma
+ *
+ * @param mixed $sTag The tag to be procesed
+ *
+ * @access public
+ * @return void
+ */
public function t_comma($sTag)
{
if ($this->oBeaut->getControlParenthesis() != T_ARRAY) {
@@ -81,4 +107,4 @@ public function t_comma($sTag)
}
}
}
-?>
+?>
View
478 Beautifier/Filter/Default.filter.php
@@ -10,15 +10,16 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Default Filter: Handle all the tokens. Uses K & R style
@@ -34,19 +35,29 @@
* </CODE>
* - All the comments in new lines are indented. In multi-line comments, all the lines are indented, too.
* This class is final, so don't try to extend it!
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
final class PHP_Beautifier_Filter_Default extends PHP_Beautifier_Filter
{
protected $sDescription = 'Default Filter for PHP_Beautifier';
+ /**
+ * __call
+ *
+ * @param mixed $sMethod Method name
+ * @param mixed $aArgs Method arguments
+ *
+ * @access protected
+ * @return void
+ */
function __call($sMethod, $aArgs)
{
if (!is_array($aArgs) or count($aArgs) != 1) {
@@ -56,18 +67,48 @@ function __call($sMethod, $aArgs)
$this->oBeaut->add($aArgs[0]);
}
// Bypass the function!
+ /**
+ * off
+ *
+ * @access public
+ * @return void
+ */
public function off()
{
}
+ /**
+ * t_access
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
public function t_access($sTag)
{
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_end_heredoc
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
public function t_end_heredoc($sTag)
{
$this->oBeaut->add(trim($sTag));
$this->oBeaut->addNewLineIndent();
}
+ /**
+ * t_open_tag
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
public function t_open_tag($sTag)
{
$this->oBeaut->add(trim($sTag));
@@ -81,6 +122,14 @@ public function t_open_tag($sTag)
$this->oBeaut->add(" ");
}
}
+ /**
+ * t_close_tag
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_close_tag($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -91,14 +140,38 @@ function t_close_tag($sTag)
$this->oBeaut->add(" " . $sTag);
}
}
+ /**
+ * t_switch
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_switch($sTag)
{
$this->t_control($sTag);
}
+ /**
+ * t_control
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_control($sTag)
{
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_case
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_case($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -108,21 +181,45 @@ function t_case($sTag)
//$this->oBeaut->incIndent();
}
+ /**
+ * t_parenthesis_open
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_parenthesis_open($sTag)
{
$this->oBeaut->add($sTag);
}
+ /**
+ * t_parenthesis_close
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_parenthesis_close($sTag)
{
if (!$this->oBeaut->isPreviousTokenConstant(T_COMMENT) and !$this->oBeaut->isPreviousTokenConstant(T_END_HEREDOC)) {
$this->oBeaut->removeWhitespace();
}
$this->oBeaut->add($sTag);
- if(!$this->oBeaut->isNextTokenContent(';')) {
+ if (!$this->oBeaut->isNextTokenContent(';')) {
$this->oBeaut->add(' ');
}
}
+ /**
+ * t_open_brace
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_open_brace($sTag)
{
if ($this->oBeaut->openBraceDontProcess()) {
@@ -141,6 +238,14 @@ function t_open_brace($sTag)
}
}
+ /**
+ * t_close_brace
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_close_brace($sTag)
{
if ($this->oBeaut->getMode('string_index') or $this->oBeaut->getMode('double_quote')) {
@@ -156,11 +261,19 @@ function t_close_brace($sTag)
$this->oBeaut->add($sTag);
if ($this->oBeaut->getControlSeq() == T_DO) {
$this->oBeaut->add(' ');
- }else{
+ } else {
$this->oBeaut->addNewLineIndent();
}
}
}
+ /**
+ * t_semi_colon
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_semi_colon($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -169,18 +282,50 @@ function t_semi_colon($sTag)
$this->oBeaut->addNewLineIndent();
}
}
+ /**
+ * t_as
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_as($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_new
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_new($sTag)
{
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_whitespace
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_whitespace($sTag)
{
}
+ /**
+ * t_doc_comment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_doc_comment($sTag)
{
$this->oBeaut->removeWhiteSpace();
@@ -195,7 +340,7 @@ function t_doc_comment($sTag)
} else { // is a multi line doc...
$aLines = preg_split("/\r\n|\r|\n/", $sDoc);
$this->oBeaut->add($aMatch[1]);
- foreach($aLines as $sLine) {
+ foreach ($aLines as $sLine) {
if ($sLine = trim($sLine)) {
$this->oBeaut->addNewLineIndent();
$this->oBeaut->add(" " . $sLine);
@@ -206,6 +351,14 @@ function t_doc_comment($sTag)
$this->oBeaut->addNewLineIndent();
}
}
+ /**
+ * t_comment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_comment($sTag)
{
if ($this->oBeaut->removeWhitespace()) {
@@ -221,11 +374,27 @@ function t_comment($sTag)
$this->comment_short($sTag);
}
}
+ /**
+ * comment_short
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function comment_short($sTag)
{
$this->oBeaut->add(trim($sTag));
$this->oBeaut->addNewLineIndent();
}
+ /**
+ * comment_large
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function comment_large($sTag)
{
if ($sTag == '/*{{{*/' or $sTag == '/*}}}*/') { // folding markers
@@ -235,22 +404,22 @@ function comment_large($sTag)
$aLines = explode("\n", $sTag);
$allWithAsterisk=true;
- for($x=1;$x<(count($aLines)-1);$x++) {
- if (substr(trim($aLines[$x]),0,1)!="*") {
+ for ($x=1;$x<(count($aLines)-1);$x++) {
+ if (substr(trim($aLines[$x]), 0, 1)!="*") {
$allWithAsterisk=false;
}
}
- foreach($aLines as $sLinea) {
- if (substr(trim($sLinea),0,2)=="/*") {
+ foreach ($aLines as $sLinea) {
+ if (substr(trim($sLinea), 0, 2)=="/*") {
$this->oBeaut->add(trim($sLinea));
- } elseif (substr(trim($sLinea),0,2)=="*/") {
+ } elseif (substr(trim($sLinea), 0, 2)=="*/") {
$this->oBeaut->add(trim($sLinea));
} elseif ($allWithAsterisk) {
$this->oBeaut->add(" ".trim($sLinea));
} else {
- if (trim(substr($sLinea,0,$this->oBeaut->getIndent()))=="") {
- $this->oBeaut->add(substr($sLinea,$this->oBeaut->getIndent()));
+ if (trim(substr($sLinea, 0, $this->oBeaut->getIndent()))=="") {
+ $this->oBeaut->add(substr($sLinea, $this->oBeaut->getIndent()));
} else {
$this->oBeaut->add(trim($sLinea));
}
@@ -260,7 +429,13 @@ function comment_large($sTag)
}
}
/**
+ * t_else
+ *
+ * @param mixed $sTag The tag to be processed
+ *
* @uses detect_colon_after_parenthesis
+ * @access public
+ * @return void
*/
function t_else($sTag)
{
@@ -272,17 +447,21 @@ function t_else($sTag)
$this->oBeaut->add(' ');
} else {
$this->oBeaut->removeWhitespace();
- if ($this->oBeaut->isNextTokenContent(':') or ($sTag == 'elseif' and $this->detect_colon_after_parenthesis())) {
+ if ($this->oBeaut->isNextTokenContent(':') or ($sTag == 'elseif' and $this->_detectColonAfterParenthesis())) {
$this->oBeaut->decIndent();
}
$this->oBeaut->addNewLineIndent();
}
$this->oBeaut->add($sTag . ' ');
}
+
/**
- * Detect structure elseif($something):
+ * _detectColonAfterParenthesis Detect structure elseif($something):
+ *
+ * @access private
+ * @return void
*/
- private function detect_colon_after_parenthesis()
+ private function _detectColonAfterParenthesis()
{
$iPar = 1;
$x = 2;
@@ -299,46 +478,126 @@ private function detect_colon_after_parenthesis()
}
return $this->oBeaut->isNextTokenContent(':', $x);
}
+ /**
+ * t_equal
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_equal($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_logical
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_logical($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_foreach
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_foreach($sTag)
{
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_for
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_for($sTag)
{
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_comma
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_comma($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_dot
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_dot($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_include
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_include($sTag)
{
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_language_construct
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_language_construct($sTag)
{
$this->oBeaut->add($sTag . ' ');
}
+ /**
+ * t_constant_encapsed_string
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_constant_encapsed_string($sTag)
{
$this->oBeaut->add($sTag);
}
+ /**
+ * t_variable
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_variable($sTag)
{
if ($this->oBeaut->isPreviousTokenConstant(T_STRING) and !$this->oBeaut->getMode("double_quote")) {
@@ -346,11 +605,27 @@ function t_variable($sTag)
}
$this->oBeaut->add($sTag);
}
+ /**
+ * t_question
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_question($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_colon
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_colon($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -362,10 +637,26 @@ function t_colon($sTag)
$this->oBeaut->addNewLineIndent();
}
}
+ /**
+ * t_double_colon
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_double_colon($sTag)
{
$this->oBeaut->add($sTag);
}
+ /**
+ * t_break
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_break($sTag)
{
if ($this->oBeaut->getControlSeq() == T_SWITCH) {
@@ -381,6 +672,14 @@ function t_break($sTag)
$this->oBeaut->add(" ");
}
}
+ /**
+ * t_continue
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_continue($sTag)
{
$this->oBeaut->add($sTag);
@@ -388,10 +687,26 @@ function t_continue($sTag)
$this->oBeaut->add(" ");
}
}
+ /**
+ * t_default
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_default($sTag)
{
$this->t_case($sTag);
}
+ /**
+ * t_end_suffix
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_end_suffix($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -399,74 +714,155 @@ function t_end_suffix($sTag)
$this->oBeaut->addNewLineIndent();
$this->oBeaut->add($sTag);
}
+ /**
+ * t_extends
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_extends($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_implements
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_implements($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_instanceof
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_instanceof($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_equal_sign
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_equal_sign($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_assigment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_assigment($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' ' . $sTag . ' ');
}
+ /**
+ * t_assigment_pre
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_assigment_pre($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add($sTag . ' ');
}
- function t_clone($sTag) {
+ /**
+ * t_clone
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
+ function t_clone($sTag)
+ {
$this->oBeaut->add($sTag.' ');
}
+ /**
+ * t_array
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_array($sTag)
{
$this->oBeaut->add($sTag);
- // Check this, please!
- if (!$this->oBeaut->isNextTokenContent('(')) {
+ // Check this, please!
+ if (!$this->oBeaut->isNextTokenContent('(')) {
$this->oBeaut->add(" ");
}
}
+ /**
+ * t_object_operator
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_object_operator($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add($sTag);
}
+ /**
+ * t_operator
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_operator($sTag)
{
$this->oBeaut->removeWhitespace();
// binary operators should have a space before and after them. unary ones should just have a space before them.
switch ($this->oBeaut->getTokenFunction($this->oBeaut->getPreviousTokenConstant())) {
- case 't_question':
- case 't_colon':
- case 't_comma':
- case 't_dot':
- case 't_case':
- case 't_echo':
- case 't_language_construct': // print, echo, return, etc.
- case 't_operator':
- $this->oBeaut->add(' ' . $sTag);
- break;
- case 't_parenthesis_open':
- case 't_open_square_brace':
- case 't_open_brace':
- $this->oBeaut->add($sTag);
- break;
- default:
- $this->oBeaut->add(' ' . $sTag . ' ');
+ case 't_question':
+ case 't_colon':
+ case 't_comma':
+ case 't_dot':
+ case 't_case':
+ case 't_echo':
+ case 't_language_construct': // print, echo, return, etc.
+ case 't_operator':
+ $this->oBeaut->add(' ' . $sTag);
+ break;
+ case 't_parenthesis_open':
+ case 't_open_square_brace':
+ case 't_open_brace':
+ $this->oBeaut->add($sTag);
+ break;
+ default:
+ $this->oBeaut->add(' ' . $sTag . ' ');
}
}
}
View
18 Beautifier/Filter/DocBlock.filter.php
@@ -11,15 +11,16 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @author Jesús Espino <jespinog@gmail.com>
* @copyright 2010 Jesús Espino
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Filter Doc Blocks: Use DocBlockGenerator for beautify the phpdoc comments.
@@ -37,18 +38,27 @@
* * @version Release: @package_version@
* *'/
* </pre>
+ *
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @author Jesús Espino <jespinog@gmail.com>
* @copyright 2010 Jesús Espino
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
class PHP_Beautifier_Filter_DocBlock extends PHP_Beautifier_Filter
{
+ /**
+ * t_doc_comment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
public function t_doc_comment($sTag)
{
include_once "PHP/DocBlockGenerator/Align.php";
View
27 Beautifier/Filter/EqualsAlign.filter.php
@@ -11,15 +11,16 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @author Jesús Espino <jespinog@gmail.com>
* @copyright 2010 Jesús Espino
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Filter EqualsAlign: Align the equals symbols in contiguous lines.
@@ -29,23 +30,31 @@
* @subpackage Filter
* @author Jesús Espino <jespinog@gmail.com>
* @copyright 2010 Jesús Espino
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
class PHP_Beautifier_Filter_EqualsAlign extends PHP_Beautifier_Filter
{
var $maxVarSize = 0;
var $equalsToModify = array();
+ /**
+ * t_assigment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
public function t_assigment($sTag)
{
$var_size = 0;
$counter = 1;
$next = $this->oBeaut->getToken($this->oBeaut->iCount+$counter);
$ends = 0;
- while($next!="=" && $ends<2 && $next!=null) {
- if($next == ";") {
+ while ($next!="=" && $ends<2 && $next!=null) {
+ if ($next == ";") {
$ends++;
}
$counter++;
@@ -68,9 +77,9 @@ public function t_assigment($sTag)
$this->maxVarSize = $var_size;
}
$this->equalsToModify[] = array('position'=>count($this->oBeaut->aOut)+1,'size'=>$var_size);
- if($next!="=") {
- foreach($this->equalsToModify as $equal){
- $this->oBeaut->aOut[$equal['position']-2]=$this->oBeaut->aOut[$equal['position']-2].str_repeat(" ",$this->maxVarSize-$equal['size']);
+ if ($next!="=") {
+ foreach ($this->equalsToModify as $equal) {
+ $this->oBeaut->aOut[$equal['position']-2]=$this->oBeaut->aOut[$equal['position']-2].str_repeat(" ", $this->maxVarSize-$equal['size']);
}
$this->maxVarSize = 0;
$this->equalsToModify = array();
View
24 Beautifier/Filter/Fluent.filter.php
@@ -10,15 +10,16 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @author Jesús Espino <jespinog@gmail.com>
* @copyright 2010 Jesús Espino
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Filter Fluent: Create fluent style for multi-level object access.
@@ -30,18 +31,29 @@
* ->addFile("c.txt");
* $this->addFile("d.txt");
* </CODE>
+ *
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @author Jesús Espino <jespinog@gmail.com>
* @copyright 2010 Jesús Espino
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
-class PHP_Beautifier_Filter_Fluent extends PHP_Beautifier_Filter {
- public function t_object_operator($sTag) {
+class PHP_Beautifier_Filter_Fluent extends PHP_Beautifier_Filter
+{
+ /**
+ * t_object_operator
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
+ public function t_object_operator($sTag)
+ {
$counter = 1;
$next = $this->oBeaut->getToken($this->oBeaut->iCount + $counter);
while (($next[0] != T_OBJECT_OPERATOR) && ($next != ";")) {
View
137 Beautifier/Filter/IndentStyles.filter.php
@@ -9,24 +9,31 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Filter Indent Styles: Indent the code in k&r, allman, gnu or whitesmiths
*
* Use 'style' setting to select the style. You can change the style inside
* the file, using the callbacks features.
- * The following is a description taken from {@link http://catb.org/~esr/jargon/html/I/indent-style.html }
+ * The following is a description taken from {@link
+ * http://catb.org/~esr/jargon/html/I/indent-style.html }
*
- * K&R style <b>['k&r']</b> Named after Kernighan & Ritchie, because the examples in K&R are formatted this way. Also called kernel style because the Unix kernel is written in it, and the "One True Brace Style" (abbrev. 1TBS) by its partisans. In C code, the body is typically indented by eight spaces (or one tab) per level, as shown here. Four spaces are occasionally seen in C, but in C++ and Java four tends to be the rule rather than the exception.
+ * K&R style <b>['k&r']</b> Named after Kernighan & Ritchie, because the
+ * examples in K&R are formatted this way. Also called kernel style because the
+ * Unix kernel is written in it, and the "One True Brace Style" (abbrev. 1TBS)
+ * by its partisans. In C code, the body is typically indented by eight spaces
+ * (or one tab) per level, as shown here. Four spaces are occasionally seen in
+ * C, but in C++ and Java four tends to be the rule rather than the exception.
*
*<CODE>
*if (<cond>) {
@@ -34,7 +41,12 @@
* }
*</CODE>
*
- * Allman style <b>['allman' or 'bsd']</b> Named for Eric Allman, a Berkeley hacker who wrote a lot of the BSD utilities in it (it is sometimes called BSD style). Resembles normal indent style in Pascal and Algol. It is the only style other than K&R in widespread use among Java programmers. Basic indent per level shown here is eight spaces, but four (or sometimes three) spaces are generally preferred by C++ and Java programmers.
+ * Allman style <b>['allman' or 'bsd']</b> Named for Eric Allman, a Berkeley
+ * hacker who wrote a lot of the BSD utilities in it (it is sometimes called
+ * BSD style). Resembles normal indent style in Pascal and Algol. It is the
+ * only style other than K&R in widespread use among Java programmers. Basic
+ * indent per level shown here is eight spaces, but four (or sometimes three)
+ * spaces are generally preferred by C++ and Java programmers.
*
*<CODE>
* if (<cond>)
@@ -44,7 +56,9 @@
* </CODE>
*
*
- * Whitesmiths style <b>['whitesmiths']</b>? popularized by the examples that came with Whitesmiths C, an early commercial C compiler. Basic indent per level shown here is eight spaces, but four spaces are occasionally seen.
+ * Whitesmiths style <b>['whitesmiths']</b>? popularized by the examples that
+ * came with Whitesmiths C, an early commercial C compiler. Basic indent per
+ * level shown here is eight spaces, but four spaces are occasionally seen.
*
* <CODE>
* if (<cond>)
@@ -53,7 +67,9 @@
* }
* </CODE>
*
- * GNU style <b>['gnu']</b> Used throughout GNU EMACS and the Free Software Foundation code, and just about nowhere else. Indents are always four spaces per level, with { and } halfway between the outer and inner indent levels.
+ * GNU style <b>['gnu']</b> Used throughout GNU EMACS and the Free Software
+ * Foundation code, and just about nowhere else. Indents are always four spaces
+ * per level, with { and } halfway between the outer and inner indent levels.
*
*<CODE>
* if (<cond>)
@@ -63,14 +79,14 @@
* </CODE>
*
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
class PHP_Beautifier_Filter_IndentStyles extends PHP_Beautifier_Filter
{
@@ -86,11 +102,29 @@ class PHP_Beautifier_Filter_IndentStyles extends PHP_Beautifier_Filter
"ws" => "ws"
);
protected $sDescription = 'Filter the code in 4 different indent styles: K&R, Allman, Whitesmiths and GNU';
+ /**
+ * __construct
+ *
+ * @param PHP_Beautifier $oBeaut PHP_Beautifier Object
+ * @param array $aSettings Settings for the PHP_Beautifier
+ *
+ * @access public
+ * @return void
+ */
public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
{
parent::__construct($oBeaut, $aSettings);
$this->addSettingDefinition('style', 'text', 'Style for indent: K&R, Allman, Whitesmiths, GNU');
}
+ /**
+ * __call
+ *
+ * @param mixed $sMethod Method name
+ * @param mixed $aArgs Method arguments
+ *
+ * @access public
+ * @return void
+ */
public function __call($sMethod, $aArgs)
{
if (strtolower($this->getSetting('style')) == 'k&r') {
@@ -98,17 +132,24 @@ public function __call($sMethod, $aArgs)
}
$sNewMethod = $this->_getFunctionForStyle($sMethod);
if (method_exists($this, $sNewMethod)) {
- call_user_func_array(array(
- $this,
- $sNewMethod
- ) , $aArgs);
+ call_user_func_array(
+ array(
+ $this,
+ $sNewMethod
+ ),
+ $aArgs
+ );
} else {
return PHP_Beautifier_Filter::BYPASS;
}
}
/**
- * Open braces in BSD style
- * @param string '{'
+ * t_open_brace_bsd: Open braces in BSD style
+ *
+ * @param mixed $sTag The tag to be processed (})
+ *
+ * @access public
+ * @return void
*/
function t_open_brace_bsd($sTag)
{
@@ -118,8 +159,12 @@ function t_open_brace_bsd($sTag)
$this->oBeaut->addNewLineIndent();
}
/**
- * Close braces in BSD style
- * @param string '}'
+ * t_close_brace_bsd: Close braces in BSD style
+ *
+ * @param mixed $sTag The tag to be processed ({)
+ *
+ * @access public
+ * @return void
*/
function t_close_brace_bsd($sTag)
{
@@ -134,8 +179,12 @@ function t_close_brace_bsd($sTag)
}
}
/**
- * Open braces in Whitesmiths style
- * @param string '{'
+ * t_open_brace_ws: Open braces in Whitesmiths style
+ *
+ * @param mixed $sTag The tag to be processed ({)
+ *
+ * @access public
+ * @return void
*/
function t_open_brace_ws($sTag)
{
@@ -146,8 +195,12 @@ function t_open_brace_ws($sTag)
$this->oBeaut->addNewLineIndent();
}
/**
- * Close braces in Whitesmiths style
- * @param string '}'
+ * t_close_brace_ws: Close braces in Whitesmiths style
+ *
+ * @param mixed $sTag The tag to be processed (})
+ *
+ * @access public
+ * @return void
*/
function t_close_brace_ws($sTag)
{
@@ -162,8 +215,12 @@ function t_close_brace_ws($sTag)
}
}
/**
- * Close braces in GNU style
- * @param string '}'
+ * t_close_brace_gnu: Close braces in GNU style
+ *
+ * @param mixed $sTag The tag to be processed (})
+ *
+ * @access public
+ * @return void
*/
function t_close_brace_gnu($sTag)
{
@@ -180,8 +237,12 @@ function t_close_brace_gnu($sTag)
}
}
/**
- * Open braces in GNU style
- * @param string '{'
+ * t_open_brace_gnu: Open braces in GNU style
+ *
+ * @param mixed $sTag The tag to be processed ({)
+ *
+ * @access public
+ * @return void
*/
function t_open_brace_gnu($sTag)
{
@@ -193,9 +254,12 @@ function t_open_brace_gnu($sTag)
$this->oBeaut->addNewLineIndent();
}
/**
- * Else for bds, gnu & ws
- * @param string else or elseif
- * @return void|PHP_Beautifier_Filter::BYPASS
+ * t_else: Else for bds, gnu & ws
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void|PHP_Beautifier_Filter::BYPASS
*/
function t_else($sTag)
{
@@ -212,8 +276,11 @@ function t_else($sTag)
}
/**
* Return the method for the defined style
- * @param string method to search
- * @return string method renamed for the defined style
+ *
+ * @param string $sMethod method to search
+ *
+ * @access private
+ * @return string method renamed for the defined style
*/
private function _getFunctionForStyle($sMethod)
{
@@ -224,4 +291,4 @@ private function _getFunctionForStyle($sMethod)
return $sMethod . "_" . $this->aAllowedStyles[$sStyle];
}
}
-?>
+?>
View
121 Beautifier/Filter/ListClassFunction.filter.php
@@ -10,15 +10,16 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Create a list of functions and classes in the script
@@ -27,20 +28,22 @@
* <pre>
* // Class and Function List
* </pre>
- * The script lookup for the string 'Class and Function List' in a comment and replace the entire comment with the list
+ * The script lookup for the string 'Class and Function List' in a comment and
+ * replace the entire comment with the list
* The settings are
* - list_functions: List functions (0 or 1). Default:1
* - list_classes: List classes (0 or 1). Default:1
+ *
* @todo List functions inside classes as methods
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
class PHP_Beautifier_Filter_ListClassFunction extends PHP_Beautifier_Filter
{
@@ -50,65 +53,121 @@ class PHP_Beautifier_Filter_ListClassFunction extends PHP_Beautifier_Filter
T_COMMENT => 't_comment',
T_OPEN_TAG => 't_open_tag'
);
- private $aFunctions = array();
- private $aClasses = array();
- private $iComment;
- private $iOpenTag = null;
+ private $_aFunctions = array();
+ private $_aClasses = array();
+ private $_iComment;
+ private $_iOpenTag = null;
protected $aSettings = array(
'list_functions' => true,
'list_classes' => true
);
protected $sDescription = 'Create a list of functions and classes in the script';
- private $aInclude = array(
+ private $_aInclude = array(
'functions' => true,
'classes' => true
);
+ /**
+ * __construct
+ *
+ * @param PHP_Beautifier $oBeaut PHP_Beautifier Object
+ * @param array $aSettings Settings for the PHP_Beautifier
+ *
+ * @access public
+ * @return void
+ */
public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
{
parent::__construct($oBeaut, $aSettings);
$this->addSettingDefinition('list_functions', 'bool', 'List Functions inside the file');
$this->addSettingDefinition('list_classes', 'bool', 'List Classes inside the file');
}
+ /**
+ * t_function
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_function($sTag)
{
- if ($this->aInclude['functions']) {
+ if ($this->_aInclude['functions']) {
$sNext = $this->oBeaut->getNextTokenContent(1);
if ($sNext == '&') {
$sNext.= $this->oBeaut->getNextTokenContent(2);
}
- array_push($this->aFunctions, $sNext);
+ array_push($this->_aFunctions, $sNext);
}
return PHP_Beautifier_Filter::BYPASS;
}
+ /**
+ * includeInList
+ *
+ * @param mixed $sTag The tag to include in the list (classes|functions)
+ * @param mixed $sValue The flag to enable or thisable the $sTag list (true|false)
+ *
+ * @access public
+ * @return void
+ */
function includeInList($sTag, $sValue)
{
- $this->aInclude[$sTag] = $sValue;
+ $this->_aInclude[$sTag] = $sValue;
}
+ /**
+ * t_class
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_class($sTag)
{
- if ($this->aInclude['classes']) {
+ if ($this->_aInclude['classes']) {
$sClassName = $this->oBeaut->getNextTokenContent(1);
if ($this->oBeaut->isNextTokenConstant(T_EXTENDS, 2)) {
$sClassName.= ' extends ' . $this->oBeaut->getNextTokenContent(3);
}
- array_push($this->aClasses, $sClassName);
+ array_push($this->_aClasses, $sClassName);
}
return PHP_Beautifier_Filter::BYPASS;
}
+ /**
+ * t_doc_comment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_doc_comment($sTag)
{
- if (strpos($sTag, 'Class and Function List') !== FALSE) {
- $this->iComment = $this->oBeaut->iCount;
+ if (strpos($sTag, 'Class and Function List') !== false) {
+ $this->_iComment = $this->oBeaut->iCount;
}
return PHP_Beautifier_Filter::BYPASS;
}
+ /**
+ * t_open_tag
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_open_tag($sTag)
{
- if (is_null($this->iOpenTag)) {
- $this->iOpenTag = $this->oBeaut->iCount;
+ if (is_null($this->_iOpenTag)) {
+ $this->_iOpenTag = $this->oBeaut->iCount;
}
return PHP_Beautifier_Filter::BYPASS;
}
+ /**
+ * postProcess
+ *
+ * @access public
+ * @return void
+ */
function postProcess()
{
$sNL = $this->oBeaut->sNewLine;
@@ -118,33 +177,33 @@ function postProcess()
);
if ($this->getSetting('list_functions')) {
$aOut[] = "* Function list:";
- foreach($this->aFunctions as $sFunction) {
+ foreach ($this->_aFunctions as $sFunction) {
$aOut[] = "* - " . $sFunction . "()";
}
}
if ($this->getSetting('list_classes')) {
$aOut[] = "* Classes list:";
- foreach($this->aClasses as $sClass) {
+ foreach ($this->_aClasses as $sClass) {
$aOut[] = "* - " . $sClass;
}
}
$aOut[] = "*/";
- if ($this->iComment) {
+ if ($this->_iComment) {
// Determine the previous Indent
- $sComment = $this->oBeaut->getTokenAssocText($this->iComment);
+ $sComment = $this->oBeaut->getTokenAssocText($this->_iComment);
if (preg_match("/" . addcslashes($sNL, "\r\n") . "([ \t]+)/ms", $sComment, $aMatch)) {
$sPrevio = $sNL . $aMatch[1];
} else {
$sPrevio = $sNL;
}
$sText = implode($sPrevio, $aOut) . $sNL;
- $this->oBeaut->replaceTokenAssoc($this->iComment, $sText);
+ $this->oBeaut->replaceTokenAssoc($this->_iComment, $sText);
} else {
$sPrevio = $sNL /*.str_repeat($this->oBeaut->sIndentChar, $this->oBeaut->iIndentNumber)*/;
- $sTag = trim($this->oBeaut->getTokenAssocText($this->iOpenTag)) . "\n";
+ $sTag = trim($this->oBeaut->getTokenAssocText($this->_iOpenTag)) . "\n";
$sText = $sPrevio . implode($sPrevio, $aOut);
- $this->oBeaut->replaceTokenAssoc($this->iOpenTag, rtrim($sTag) . $sText . $sPrevio);
+ $this->oBeaut->replaceTokenAssoc($this->_iOpenTag, rtrim($sTag) . $sText . $sPrevio);
}
}
}
-?>
+?>
View
66 Beautifier/Filter/Lowercase.filter.php
@@ -10,16 +10,17 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://php.apsique.com/PHP_Beautifier
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @since File available since Release 0.1.9
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://php.apsique.com/PHP_Beautifier
+ * @since File available since Release 0.1.9
*/
/**
* Lowercase: lowercase all control structures.
@@ -28,21 +29,22 @@
* Command line example:
*
* <code>php_beautifier --filters "Lowercase()"</code>
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
* @since Class available since Release 0.1.9
*/
class PHP_Beautifier_Filter_Lowercase extends PHP_Beautifier_Filter
{
protected $sDescription = 'Lowercase all control structures. Parse the output with another Filters';
- private $aControlSeq = array(
+ private $_aControlSeq = array(
T_IF,
T_ELSE,
T_ELSEIF,
@@ -101,29 +103,59 @@ class PHP_Beautifier_Filter_Lowercase extends PHP_Beautifier_Filter
T_BOOLEAN_OR,
T_BOOLEAN_AND,
);
- private $oLog;
+ private $_oLog;
+
+ /**
+ * __construct
+ *
+ * @param PHP_Beautifier $oBeaut PHP_Beautifier Object
+ * @param array $aSettings Settings for the PHP_Beautifier
+ *
+ * @access public
+ * @return void
+ */
public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
{
parent::__construct($oBeaut, $aSettings);
- $this->oLog = PHP_Beautifier_Common::getLog();
+ $this->_oLog = PHP_Beautifier_Common::getLog();
}
- public function t_string($sTag) {
- if($sTag=='TRUE' or $sTag=='FALSE') {
+
+ /**
+ * t_string
+ *
+ * @param mixed $sTag The tag to be procesed
+ *
+ * @access public
+ * @return void
+ */
+ public function t_string($sTag)
+ {
+ if ($sTag=='TRUE' or $sTag=='FALSE') {
$this->oBeaut->aCurrentToken[1]=strtolower($sTag);
}
return PHP_Beautifier_Filter::BYPASS;
}
+
+ /**
+ * __call
+ *
+ * @param mixed $sMethod Method name
+ * @param mixed $aArgs Method arguments
+ *
+ * @access public
+ * @return void
+ */
public function __call($sMethod, $aArgs)
{
$iToken = $this->aToken[0];
$sContent = $this->aToken[1];
- if (in_array($iToken, $this->aControlSeq)) {
- $this->oLog->log("Lowercase:" . $sContent, PEAR_LOG_DEBUG);
+ if (in_array($iToken, $this->_aControlSeq)) {
+ $this->_oLog->log("Lowercase:" . $sContent, PEAR_LOG_DEBUG);
$this->oBeaut->aCurrentToken[1]=strtolower($sContent);
}
return PHP_Beautifier_Filter::BYPASS;
}
}
-?>
+?>
View
64 Beautifier/Filter/NewLines.filter.php
@@ -10,16 +10,17 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @since File available since Release 0.1.2
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
+ * @since File available since Release 0.1.2
*/
/**
* New Lines: Add new lines after o before specific contents
@@ -29,15 +30,16 @@
* Command line example:
*
* <code>php_beautifier --filters "NewLines(before=if:switch:T_CLASS,after=T_COMMENT:function)"</code>
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
* @since Class available since Release 0.1.2
*/
class PHP_Beautifier_Filter_NewLines extends PHP_Beautifier_Filter
@@ -47,10 +49,19 @@ class PHP_Beautifier_Filter_NewLines extends PHP_Beautifier_Filter
'after' => false
);
protected $sDescription = 'Add new lines after or before specific contents';
- private $aBeforeToken = array();
- private $aBeforeContent = array();
- private $aAfterToken = array();
- private $aAfterContent = array();
+ private $_aBeforeToken = array();
+ private $_aBeforeContent = array();
+ private $_aAfterToken = array();
+ private $_aAfterContent = array();
+ /**
+ * __construct
+ *
+ * @param PHP_Beautifier $oBeaut PHP_Beautifier Object
+ * @param array $aSettings Settings for the PHP_Beautifier
+ *
+ * @access public
+ * @return void
+ */
public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
{
parent::__construct($oBeaut, $aSettings);
@@ -58,37 +69,46 @@ public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
$this->addSettingDefinition('after', 'text', 'List of contents to put new lines after, separated by colons');
if (!empty($this->aSettings['before'])) {
$aBefore = explode(':', str_replace(' ', '', $this->aSettings['before']));
- foreach($aBefore as $sBefore) {
+ foreach ($aBefore as $sBefore) {
if (defined($sBefore)) {
- $this->aBeforeToken[] = constant($sBefore);
+ $this->_aBeforeToken[] = constant($sBefore);
} else {
- $this->aBeforeContent[] = $sBefore;
+ $this->_aBeforeContent[] = $sBefore;
}
}
}
if (!empty($this->aSettings['after'])) {
$aAfter = explode(':', str_replace(' ', '', $this->aSettings['after']));
- foreach($aAfter as $sAfter) {
+ foreach ($aAfter as $sAfter) {
if (defined($sAfter)) {
- $this->aAfterToken[] = constant($sAfter);
+ $this->_aAfterToken[] = constant($sAfter);
} else {
- $this->aAfterContent[] = $sAfter;
+ $this->_aAfterContent[] = $sAfter;
}
}
}
$this->oBeaut->setNoDeletePreviousSpaceHack();
}
+ /**
+ * __call
+ *
+ * @param mixed $sMethod Method name
+ * @param mixed $aArgs Method arguments
+ *
+ * @access public
+ * @return void
+ */
public function __call($sMethod, $aArgs)
{
$iToken = $this->aToken[0];
$sContent = $this->aToken[1];
- if (in_array($sContent, $this->aBeforeContent) or in_array($iToken, $this->aBeforeToken)) {
+ if (in_array($sContent, $this->_aBeforeContent) or in_array($iToken, $this->_aBeforeToken)) {
$this->oBeaut->addNewLineIndent();
}
- if (in_array($sContent, $this->aAfterContent) or in_array($iToken, $this->aAfterToken)) {
+ if (in_array($sContent, $this->_aAfterContent) or in_array($iToken, $this->_aAfterToken)) {
$this->oBeaut->setBeforeNewLine($this->oBeaut->sNewLine . '/**ndps**/');
}
return PHP_Beautifier_Filter::BYPASS;
}
}
-?>
+?>
View
120 Beautifier/Filter/Pear.filter.php
@@ -10,20 +10,21 @@
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
*/
/**
* Require PEAR_Config
*/
-require_once ('PEAR/Config.php');
+require_once 'PEAR/Config.php';
/**
* Filter the code to make it compatible with PEAR Coding Standards
*
@@ -45,32 +46,49 @@
* <code>
* $oBeaut->addFilter('Pear',array('newline_class'=>false, 'newline_function'=>false));
* </code>
+ *
* @category PHP
- * @package PHP_Beautifier
+ * @package PHP_Beautifier
* @subpackage Filter
- * @author Claudio Bustos <cdx@users.sourceforge.com>
+ * @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2010 Claudio Bustos
- * @link http://pear.php.net/package/PHP_Beautifier
- * @link http://beautifyphp.sourceforge.net
- * @link http://pear.php.net/manual/en/standards.php
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id:$
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/PHP_Beautifier
+ * @link http://beautifyphp.sourceforge.net
+ * @link http://pear.php.net/manual/en/standards.php
*/
class PHP_Beautifier_Filter_Pear extends PHP_Beautifier_Filter
{
protected $aSettings = array('add_header' => false, 'newline_class' => true, 'newline_function' => true, 'switch_without_indent'=> true);
protected $sDescription = 'Filter the code to make it compatible with PEAR Coding Specs';
- private $bOpenTag = false;
+ private $_bOpenTag = false;
+ /**
+ * t_open_tag_with_echo
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_open_tag_with_echo($sTag)
{
$this->oBeaut->add("<?php echo ");
}
+ /**
+ * t_close_brace
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_close_brace($sTag)
{
if ($this->oBeaut->getMode('string_index') or $this->oBeaut->getMode('double_quote')) {
$this->oBeaut->add($sTag);
- }elseif($this->oBeaut->getControlSeq() == T_SWITCH and $this->getSetting('switch_without_indent')) {
+ } elseif ($this->oBeaut->getControlSeq() == T_SWITCH and $this->getSetting('switch_without_indent')) {
$this->oBeaut->removeWhitespace();
$this->oBeaut->decIndent();
$this->oBeaut->addNewLineIndent();
@@ -80,6 +98,14 @@ function t_close_brace($sTag)
return PHP_Beautifier_Filter::BYPASS;
}
}
+ /**
+ * t_semi_colon
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_semi_colon($sTag)
{
// A break statement and the next statement are separated by an empty line
@@ -97,6 +123,14 @@ function t_semi_colon($sTag)
return PHP_Beautifier_Filter::BYPASS;
}
}
+ /**
+ * t_case
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_case($sTag)
{
$this->oBeaut->removeWhitespace();
@@ -109,10 +143,26 @@ function t_case($sTag)
//$this->oBeaut->incIndent();
}
+ /**
+ * t_default
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_default($sTag)
{
$this->t_case($sTag);
}
+ /**
+ * t_break
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_break($sTag)
{
$this->oBeaut->add($sTag);
@@ -120,6 +170,14 @@ function t_break($sTag)
$this->oBeaut->add(" ");
}
}
+ /**
+ * t_open_brace
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_open_brace($sTag)
{
if ($this->oBeaut->openBraceDontProcess()) {
@@ -145,6 +203,14 @@ function t_open_brace($sTag)
$this->oBeaut->addNewLineIndent();
}
}
+ /**
+ * t_comment
+ *
+ * @param mixed $sTag The tag to be processed
+ *
+ * @access public
+ * @return void
+ */
function t_comment($sTag)
{
if ($sTag{0} != '#') {
@@ -154,13 +220,21 @@ function t_comment($sTag)
$sTag = '//' . substr($sTag, 1);
return $oFilterDefault->t_comment($sTag);
}
+ /**
+ * t_open_tag
+ *
+ * @param mixed $sTag The tag to be processed