Permalink
Browse files

Version 0.1.14

Big bug fix release: "Thanks for the patience, bug reporters. The fishes were good, too!"
This is the last beta release, before going to stable. This package has more than 3 years!!!!
 
 - Bug fix #10091: CS issue: throw should not have parens
 - Bug fix #10839: T_CLONE and T_ARRAY formatting bugs with default filter
 - Bug fix #11661: Function getPreviousWhitespace Overly Aggressive
 - Bug fix #11662: Please add T_DOUBLE_QUOTE to $aTokensToChange
 - Bug fix #11941: Nested ternary operators add newlines
 - Bug fix #13600: Extra space after close parenthesis on function definition deleted.
 - Bug fix #13602: Pear filter breaks output - for valid, curly syntax "$this->{$method}();"
 - Bug fix #13795: "else echo" gets turned into "elseecho"
 - Bug fix #13805: Pear filter doesn't follow example for switch format
 - Bug fix #14175: HEREDOC: failure when heredoc string enclosed in function call

 + New phpBB filter, courtesy of Jim Wigginton
  • Loading branch information...
1 parent e9b9d2f commit c8f34df6de96df24f92ee0bd072cb2840b859722 @clbustos committed Jun 22, 2008
View
@@ -139,6 +139,11 @@ class PHP_Beautifier implements PHP_Beautifier_Interface
* @var int
*/
public $iArray = 0;
+ /**
+ * Level of ternary operator nesting
+ * @var int
+ */
+ public $iTernary = 0;
/**
* Level of parenthesis nesting
* @var int
@@ -163,7 +168,7 @@ class PHP_Beautifier implements PHP_Beautifier_Interface
* Type of newline
* @var string
*/
- public $sNewLine = "\n";
+ public $sNewLine = PHP_EOL;
/**
* Type of whitespace to use for indent
* @var string
@@ -280,6 +285,20 @@ public function __construct()
'<' => 'T_EQUAL',
'>' => 'T_EQUAL',
'.' => 'T_DOT',
+ '[' => 'T_OPEN_SQUARE_BRACE',
+ ']' => 'T_CLOSE_SQUARE_BRACE',
+ /* OPERATOR*/
+ '+' => 'T_OPERATOR',
+ '-' => 'T_OPERATOR',
+ '*' => 'T_OPERATOR',
+ '/' => 'T_OPERATOR',
+ '%' => 'T_OPERATOR',
+ '&' => 'T_OPERATOR',
+ '|' => 'T_OPERATOR',
+ '^' => 'T_OPERATOR',
+ '~' => 'T_OPERATOR',
+ T_SL => 'T_OPERATOR',
+ T_SR => 'T_OPERATOR',
T_OBJECT_OPERATOR => 'T_OBJECT_OPERATOR',
/* INCLUDE */
T_INCLUDE => 'T_INCLUDE',
@@ -880,6 +899,7 @@ private function controlToken($aCurrentToken)
case '?':
$this->setMode('ternary_operator');
+ $this->iTernary++;
break;
case '"':
@@ -928,7 +948,12 @@ private function controlTokenPost($aCurrentToken)
break;
}
if ($this->getTokenFunction($aCurrentToken[0]) == 't_colon') {
- $this->unsetMode('ternary_operator');
+ if ($this->iTernary) {
+ $this->iTernary--;
+ }
+ if(!$this->iTernary) {
+ $this->unsetMode('ternary_operator');
+ }
}
}
/**
@@ -1397,5 +1422,8 @@ public function &getToken($iIndex)
return $this->aTokens[$iIndex];
}
}
+ public function openBraceDontProcess() {
+ return $this->isPreviousTokenConstant(T_VARIABLE) or $this->isPreviousTokenConstant(T_OBJECT_OPERATOR) or ($this->isPreviousTokenConstant(T_STRING) and $this->getPreviousTokenConstant(2) == T_OBJECT_OPERATOR) or $this->getMode('double_quote');
+ }
}
?>
@@ -1,67 +1,68 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
-* Abstract class to superclass all batch class
-*
-* 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 Batch
-* @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:$
-*/
+ * Abstract class to superclass all batch class
+ *
+ * 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 Batch
+ * @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:$
+ */
/**
-* Abstract class to superclass all batch class
-*
-* @category PHP
-* @package PHP_Beautifier
-* @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_Batch_Output {
+ * Abstract class to superclass all batch class
+ *
+ * @category PHP
+ * @package PHP_Beautifier
+ * @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_Batch_Output
+{
protected $oBatch;
- public function __construct(PHP_Beautifier_Batch $oBatch)
+ public function __construct(PHP_Beautifier_Batch $oBatch)
{
$this->oBatch = $oBatch;
}
- protected function beautifierSetInputFile($sFile)
+ protected function beautifierSetInputFile($sFile)
{
return $this->oBatch->callBeautifier($this, 'setInputFile', array(
$sFile
));
}
- protected function beautifierProcess()
+ protected function beautifierProcess()
{
return $this->oBatch->callBeautifier($this, 'process');
}
- protected function beautifierGet()
+ protected function beautifierGet()
{
return $this->oBatch->callBeautifier($this, 'get');
}
- protected function beautifierSave($sFile)
+ protected function beautifierSave($sFile)
{
return $this->oBatch->callBeautifier($this, 'save', array(
$sFile
));
}
- public function get()
+ public function get()
{
}
- public function save()
+ public function save()
{
}
}
View
@@ -1,36 +1,36 @@
<?php
/**
-* Exception.php
-* Definition for Exceptions
-* 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
-* @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:$
-*/
-
+ * Exception.php
+ * Definition for Exceptions
+ * 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
+ * @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:$
+ */
/**
-* Exception for Filters
-*
-* @category PHP
-* @package PHP_Beautifier
-* @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@
-*/
-class Exception_PHP_Beautifier_Filter extends PEAR_Exception {
+ * Exception for Filters
+ *
+ * @category PHP
+ * @package PHP_Beautifier
+ * @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@
+ */
+class Exception_PHP_Beautifier_Filter extends PEAR_Exception
+{
}
?>
View
@@ -89,7 +89,7 @@
* @param PHP_Beautifier
* @param array settings for the Filter
*/
- public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
+ public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
{
$this->oBeaut = $oBeaut;
if ($aSettings) {
@@ -100,7 +100,7 @@ public function __construct(PHP_Beautifier $oBeaut, $aSettings = array())
* Add a setting definition
* @param string
*/
- protected function addSettingDefinition($sSetting, $sType, $sDescription)
+ protected function addSettingDefinition($sSetting, $sType, $sDescription)
{
$this->aSettingsDefinition[$sSetting] = array(
'type' => $sType,
@@ -110,7 +110,7 @@ protected function addSettingDefinition($sSetting, $sType, $sDescription)
/**
* return @string
*/
- public function getName()
+ public function getName()
{
return str_ireplace('PHP_Beautifier_Filter_', '', get_class($this));
}
@@ -124,7 +124,7 @@ public function getName()
* ...other code ...
* </code>
*/
- final public function on()
+ final public function on()
{
$this->bOn = true;
}
@@ -138,7 +138,7 @@ public function getName()
* ...other code ...
* </code>
*/
- public function off()
+ public function off()
{
$this->bOn = false;
}
@@ -147,7 +147,7 @@ public function off()
* @param string name of setting
* @return mixed value of setting or false
*/
- final public function getSetting($sSetting)
+ final public function getSetting($sSetting)
{
return (array_key_exists($sSetting, $this->aSettings)) ? $this->aSettings[$sSetting] : false;
}
@@ -156,7 +156,7 @@ public function off()
* @param string name of setting
* @param mixed value of setting
*/
- final public function setSetting($sSetting, $sValue)
+ final public function setSetting($sSetting, $sValue)
{
if (array_key_exists($sSetting, $this->aSettings)) {
$this->aSettings[$sSetting] = $sValue;
@@ -174,7 +174,7 @@ public function off()
* @return bool true if the token is processed, false bypass to the next Filter
* @see PHP_Beautifier::process()
*/
- public function handleToken($token)
+ public function handleToken($token)
{
$this->aToken = $token;
if (!$this->bOn) {
@@ -207,7 +207,7 @@ public function handleToken($token)
* @param array arguments
* @return mixed null or {@link PHP_Beautifier_Filter::BYPASS}
*/
- public function __call($sMethod, $aArgs)
+ public function __call($sMethod, $aArgs)
{
return PHP_Beautifier_Filter::BYPASS;
}
@@ -216,28 +216,28 @@ public function __call($sMethod, $aArgs)
* of the processing
* @return void
*/
- public function preProcess()
+ 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
*/
- public function postProcess()
+ public function postProcess()
{
}
- public function __sleep()
+ public function __sleep()
{
return array(
'aSettings'
);
}
- public function getDescription()
+ public function getDescription()
{
return $this->sDescription;
}
- public function __toString()
+ public function __toString()
{
// php_beautifier->setBeautify(false);
$sOut='Filter: '.$this->getName()."\n".
Oops, something went wrong.

0 comments on commit c8f34df

Please sign in to comment.