Skip to content

Commit

Permalink
Version 0.1.12. Added space after every concat operator
Browse files Browse the repository at this point in the history
  • Loading branch information
clbustos committed Feb 10, 2007
1 parent c552f56 commit 4aee239
Show file tree
Hide file tree
Showing 11 changed files with 634 additions and 737 deletions.
265 changes: 133 additions & 132 deletions Beautifier/Filter.php
@@ -1,93 +1,94 @@
<?php
/**
* Definition of class PHP_Beautifier_Filter
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* 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 Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2006 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:$
*/
* Definition of class PHP_Beautifier_Filter
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* 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 Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2006 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:$
*/
/**
* PHP_Beautifier_Filter
*
* Definition for creation of Filters
* For concrete details, please see {@link PHP_Beautifier_Filter_Default}
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @tutorial PHP_Beautifier/Filter/Filter.create.pkg
* @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2006 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@
*/
abstract class PHP_Beautifier_Filter {
* PHP_Beautifier_Filter
*
* Definition for creation of Filters
* For concrete details, please see {@link PHP_Beautifier_Filter_Default}
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
* @tutorial PHP_Beautifier/Filter/Filter.create.pkg
* @author Claudio Bustos <cdx@users.sourceforge.com>
* @copyright 2004-2006 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@
*/
abstract class PHP_Beautifier_Filter
{
/**
* Stores a reference to main PHP_Beautifier
* @var PHP_Beautifier
*/
* Stores a reference to main PHP_Beautifier
* @var PHP_Beautifier
*/
protected $oBeaut;
/**
* Associative array of functions to use when some token are found
* @var array
*/
* Associative array of functions to use when some token are found
* @var array
*/
protected $aFilterTokenFunctions = array();
/**
* Settings for the Filter
* @var array
*/
* Settings for the Filter
* @var array
*/
protected $aSettings = array();
/**
* Definition of the settings
* Should be an associative array. The keys are the names of settings
* and the values are an array with the keys 'type' and '
* @var array
*/
* Definition of the settings
* Should be an associative array. The keys are the names of settings
* and the values are an array with the keys 'type' and '
* @var array
*/
protected $aSettingsDefinition = array();
/**
* Description of the Filter
* @var string
*/
* Description of the Filter
* @var string
*/
protected $sDescription = 'Filter for PHP_Beautifier';
/**
* If a method for parse Tokens of a Filter returns this, the control of the process
* is handle by the next Filter
*/
* If a method for parse Tokens of a Filter returns this, the control of the process
* is handle by the next Filter
*/
const BYPASS = 'BYPASS';
/**
* Switch to 'turn' on and off the filter
* @var bool
*/
* Switch to 'turn' on and off the filter
* @var bool
*/
protected $bOn = true;
/**
* Current token
*/
* Current token
*/
protected $aToken = false;
/**
* Constructor
* If you need to overload this (for example, to create a
* definition for setting with {@link addSettingDefinition()}
* remember call the parent constructor.
* <code>
* parent::__construct($oBeaut, $aSettings)
* </code>
* @param PHP_Beautifier
* @param array settings for the Filter
*/
* Constructor
* If you need to overload this (for example, to create a
* definition for setting with {@link addSettingDefinition()}
* remember call the parent constructor.
* <code>
* parent::__construct($oBeaut, $aSettings)
* </code>
* @param PHP_Beautifier
* @param array settings for the Filter
*/
public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
{
$this->oBeaut = $oBeaut;
Expand All @@ -96,83 +97,83 @@ public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
}
}
/**
* Add a setting definition
* @param string
*/
* Add a setting definition
* @param string
*/
protected function addSettingDefinition($sSetting, $sType, $sDescription)
{
$this->aSettingsDefinition[$sSetting] = array(
'type'=>$sType,
'description'=>$sDescription
'type' => $sType,
'description' => $sDescription
);
}
/**
* return @string
*/
* return @string
*/
public function getName()
{
return str_ireplace('PHP_Beautifier_Filter_', '', get_class($this));
}
/**
* Turn on the Filter
* Use inside the code to beautify
* Ex.
* <code>
* ...some code...
* // ArrayNested->on()
* ...other code ...
* </code>
*/
* Turn on the Filter
* Use inside the code to beautify
* Ex.
* <code>
* ...some code...
* // ArrayNested->on()
* ...other code ...
* </code>
*/
final public function on()
{
$this->bOn = true;
}
/**
* Turn off the Filter
* Use inside the code to beautify
* Ex.
* <code>
* ...some code...
* // ArrayNested->off()
* ...other code ...
* </code>
*/
* Turn off the Filter
* Use inside the code to beautify
* Ex.
* <code>
* ...some code...
* // ArrayNested->off()
* ...other code ...
* </code>
*/
public function off()
{
$this->bOn = false;
}
/**
* Get a setting of the Filter
* @param string name of setting
* @return mixed value of setting or false
*/
* Get a setting of the Filter
* @param string name of setting
* @return mixed value of setting or false
*/
final public function getSetting($sSetting)
{
return (array_key_exists($sSetting, $this->aSettings)) ? $this->aSettings[$sSetting] : false;
}
/**
* Set a value of a Setting
* @param string name of setting
* @param mixed value of setting
*/
* Set a value of a Setting
* @param string name of setting
* @param mixed value of setting
*/
final public function setSetting($sSetting, $sValue)
{
if (array_key_exists($sSetting, $this->aSettings)) {
$this->aSettings[$sSetting] = $sValue;
}
}
/**
* Function called from {@link PHP_Beautifier::process()} to process the tokens.
*
* If the received token is one of the keys of {@link $aFilterTokenFunctions}
* a function with the same name of the value of that key is called.
* If the method doesn't exists, {@link __call()} is called, and return
* {@link PHP_Beautifier_Filter::BYPASS}. PHP_Beautifier, now, call the next Filter is its list.
* If the method exists, it can return true or {@link PHP_Beautifier_Filter::BYPASS}.
* @param array token
* @return bool true if the token is processed, false bypass to the next Filter
* @see PHP_Beautifier::process()
*/
* Function called from {@link PHP_Beautifier::process()} to process the tokens.
*
* If the received token is one of the keys of {@link $aFilterTokenFunctions}
* a function with the same name of the value of that key is called.
* If the method doesn't exists, {@link __call()} is called, and return
* {@link PHP_Beautifier_Filter::BYPASS}. PHP_Beautifier, now, call the next Filter is its list.
* If the method exists, it can return true or {@link PHP_Beautifier_Filter::BYPASS}.
* @param array token
* @return bool true if the token is processed, false bypass to the next Filter
* @see PHP_Beautifier::process()
*/
public function handleToken($token)
{
$this->aToken = $token;
Expand All @@ -188,40 +189,41 @@ public function handleToken($token)
}
$sValue = $token[1];
if ($sMethod) {
if ($this->oBeaut->iVerbose>5) {
echo $sMethod.":".trim($sValue) ."\n";
if ($this->oBeaut->iVerbose > 5) {
echo $sMethod . ":" . trim($sValue) . "\n";
}
// return false if PHP_Beautifier_Filter::BYPASS
return ($this->$sMethod($sValue) !== PHP_Beautifier_Filter::BYPASS);
} else { // WEIRD!!! -> Add the same received
$this->oBeaut->add($token[1]);
PHP_Beautifier_Common::getLog()->log("Add same received:".trim($token[1]), PEAR_LOG_DEBUG);
PHP_Beautifier_Common::getLog()->log("Add same received:" . trim($token[1]) , PEAR_LOG_DEBUG);
return true;
}
// never go here
return false;
}
/**
* @param string metodo
* @param array arguments
* @return mixed null or {@link PHP_Beautifier_Filter::BYPASS}
*/
* @param string metodo
* @param array arguments
* @return mixed null or {@link PHP_Beautifier_Filter::BYPASS}
*/
public function __call($sMethod, $aArgs)
{
return PHP_Beautifier_Filter::BYPASS;
}
/**
* Called from {@link PHP_Beautifier::process()} at the beginning
* of the processing
* @return void
*/
public function preProcess() {
}
* Called from {@link PHP_Beautifier::process()} at the beginning
* of the processing
* @return void
*/
public function preProcess()
{
}
/**
* Called from {@link PHP_Beautifier::process()} at the end of processing
* The post-process must be made in {@link PHP_Beautifier::$aOut}
* @return void
*/
* Called from {@link PHP_Beautifier::process()} at the end of processing
* The post-process must be made in {@link PHP_Beautifier::$aOut}
* @return void
*/
public function postProcess()
{
}
Expand Down Expand Up @@ -251,6 +253,5 @@ public function __toString()
// php_beautifier->setBeautify(true);
return $sOut;
}

}
?>

0 comments on commit 4aee239

Please sign in to comment.