Skip to content

Commit

Permalink
Release 0.1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
clbustos committed Feb 14, 2007
1 parent 7a610f8 commit f827278
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Beautifier/Common.php
Expand Up @@ -192,7 +192,7 @@ public static function getLog()
* @param string
* @return string
*/
function wsToString($sText)
public static function wsToString($sText)
{
// ArrayNested->off();
return str_replace(array("\r", "\n", "\t"), array('\r', '\n', '\t'), $sText);
Expand Down Expand Up @@ -235,4 +235,4 @@ public function get();
*/
public function save($sFile = null);
}
?>
?>
36 changes: 25 additions & 11 deletions Beautifier/Filter/Pear.filter.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Filter the code to make it compatible with PEAR Coding Standars
* Filter the code to make it compatible with PEAR Coding Standards
*
* PHP version 5
*
Expand All @@ -25,7 +25,7 @@
*/
require_once ('PEAR/Config.php');
/**
* Filter the code to make it compatible with PEAR Coding Standars
* Filter the code to make it compatible with PEAR Coding Standards
*
* The default filter, {@link PHP_Beautifier_Filter_Default} have most of the specs
* but adhere more to GNU C.
Expand All @@ -40,6 +40,11 @@
* <code>
* $oBeaut->addFilter('Pear',array('add_header'=>'php'));
* </code>
* Two extra options allows to break the spec about newline before braces
* on function and classes. By default, they are set to true. Use
* <code>
* $oBeaut->addFilter('Pear',array('newline_class'=>false, 'newline_function'=>false));
* </code>
* @category PHP
* @package PHP_Beautifier
* @subpackage Filter
Expand All @@ -53,9 +58,7 @@
*/
class PHP_Beautifier_Filter_Pear extends PHP_Beautifier_Filter
{
protected $aSettings = array(
'add_header' => false
);
protected $aSettings = array('add_header' => false, 'newline_class' => true, 'newline_function' => true);
protected $sDescription = 'Filter the code to make it compatible with PEAR Coding Specs';
private $bOpenTag = false;
function t_open_tag_with_echo($sTag)
Expand All @@ -64,16 +67,17 @@ function t_open_tag_with_echo($sTag)
}
function t_semi_colon($sTag)
{
// TODO: What is the function of this structure?
// I don't remember it....
// A break statement and the next statement are separated by an empty line
if ($this->oBeaut->isPreviousTokenConstant(T_BREAK)) {
$this->oBeaut->removeWhitespace();
$this->oBeaut->add($sTag);
$this->oBeaut->addNewLine();
$this->oBeaut->add($sTag); // add the semicolon
$this->oBeaut->addNewLine(); // empty line
$this->oBeaut->addNewLineIndent();
} elseif ($this->oBeaut->getControlParenthesis() == T_FOR) {
// The three terms in the head of a for loop are separated by the string "; "
$this->oBeaut->removeWhitespace();
$this->oBeaut->add($sTag . " "); // Bug 8327

} else {
return PHP_Beautifier_Filter::BYPASS;
}
Expand All @@ -97,10 +101,20 @@ function t_default($sTag)
function t_break($sTag)
{
$this->oBeaut->add($sTag);
if ($this->oBeaut->isNextTokenConstant(T_LNUMBER)) {
$this->oBeaut->add(" ");
}
}
function t_open_brace($sTag)
{
if ($this->oBeaut->getControlSeq() != T_CLASS and $this->oBeaut->getControlSeq() != T_FUNCTION) {
$bypass = true;
if ($this->oBeaut->getControlSeq() == T_CLASS and $this->getSetting('newline_class')) {
$bypass = false;
}
if ($this->oBeaut->getControlSeq() == T_FUNCTION and $this->getSetting('newline_function')) {
$bypass = false;
}
if ($bypass) {
return PHP_Beautifier_Filter::BYPASS;
}
$this->oBeaut->addNewLineIndent();
Expand Down Expand Up @@ -163,4 +177,4 @@ function addHeaderComment()
$this->oBeaut->addNewLineIndent();
}
}
?>
?>
41 changes: 29 additions & 12 deletions package2.xml
Expand Up @@ -15,26 +15,21 @@ http://pear.php.net/dtd/package-2.0.xsd">
<email>clbustos+php_beautifier@gmail.com</email>
<active>yes</active>
</lead>
<date>2007-02-10</date>
<time>01:30:00</time>
<date>2007-02-14</date>
<time>03:00:00</time>
<version>
<release>0.1.12</release>
<release>0.1.13</release>
<api>0.1.12</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://www.php.net/license">PHP License</license>
<notes>Bug fix release
- Bug fix[9078]:php_beautifier script use addFilter defore addFilterDirectory. Fixed file php_beautifier
- Bug fix[7706 and rolfhub_at_web.de 2007-02-07-1]: The beautifer removes the whitespaces left and right of the operator, so for example "echo 2 . 1 . 0 . "\n";" becomes "echo 2.1.0."\n";". Added space after and before questions.
- Bug fix[rolfhub_at_web.de 2007-02-07-2]: When using the "break" command, the command takes an optional parameter, see http://de.php.net/break for details. But this doesn't work when using the beautifier, because, for example "break 2;" morphs to "break2;"
- Bug fix[rolfhub_at_web.de 2007-01-31]: I think that I have found and fixed a bug in the PHP Beautifier, in the file Common.php in the function getFilesByGlob(). It fails if used under MS-Windows because of the different path separators.
- Bug fix[8327]: There is one extra space before semicolon in Pear filter
+ Added -h option on php_beautifier for usage message
+ New package2.xml

<notes>Small Rolf bug fix release:
- Bug fix[rolfhub_at_web.de 2007-02-07-2/pear]: Pear filter delete the space between break and a number.
- Bug fix[rolfhub_at_web.de 2007-02-12]: function wsToString($sText) to public static function wsToString($sText)
+ Two new settings on Pear filter: "newline_class" and "newline_class"
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -224,6 +219,28 @@ http://pear.php.net/dtd/package-2.0.xsd">
</filelist>
</phprelease>
<changelog>
<release>
<version>
<release>0.1.12</release>
<api>0.1.12</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2007-02-10</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>Bug fix release
- Bug fix[9078]:php_beautifier script use addFilter defore addFilterDirectory. Fixed file php_beautifier
- Bug fix[7706 and rolfhub_at_web.de 2007-02-07-1]: The beautifer removes the whitespaces left and right of the operator, so for example "echo 2 . 1 . 0 . "\n";" becomes "echo 2.1.0."\n";". Added space after and before questions.
- Bug fix[rolfhub_at_web.de 2007-02-07-2]: When using the "break" command, the command takes an optional parameter, see http://de.php.net/break for details. But this doesn't work when using the beautifier, because, for example "break 2;" morphs to "break2;"
- Bug fix[rolfhub_at_web.de 2007-01-31]: I think that I have found and fixed a bug in the PHP Beautifier, in the file Common.php in the function getFilesByGlob(). It fails if used under MS-Windows because of the different path separators.
- Bug fix[8327]: There is one extra space before semicolon in Pear filter
+ Added -h option on php_beautifier for usage message
+ New package2.xml

</notes>
</release>
<release>
<version>
<release>0.1.11</release>
Expand Down
42 changes: 42 additions & 0 deletions tests/Beautifier_Bugs.phpt
Expand Up @@ -545,7 +545,49 @@ while (++\$i) {
SCRIPT;
$this->assertEquals($sExpected, $this->oBeaut->get());
}
/**
* When using the "break" command, the command takes an optional parameter, see http://de.php.net/break for details. But this doesn't work when using the beautifier, because, for example "break 2;" morphs to "break2;" (notice the missing space, which makes the PHP interpreter quite sour :-(
*/
function testBug_rolfhub_2007_02_07_1_pear() {
$this->oBeaut->addFilter("Pear");
$sText=<<<SCRIPT
<?php
\$i = 0;
while (++\$i) {
switch (\$i) {
case 5:
echo "At 5<br />";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br />";
break 2; /* Exit the switch and the while. */
default:
break;
}
}
?>
SCRIPT;
$this->setText($sText);

$sExpected = <<<SCRIPT
<?php
\$i = 0;
while (++\$i) {
switch (\$i) {
case 5:
echo "At 5<br />";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br />";
break 2; /* Exit the switch and the while. */
default:
break;
}
}
?>
SCRIPT;
$this->assertEquals($sExpected, $this->oBeaut->get());
}
/**
* The beautifer removes the whitespaces left and right of the operator, so for example "echo 2 . 1 . 0 . "\n";" becomes "echo 2.1.0."\n";"
*/
Expand Down

0 comments on commit f827278

Please sign in to comment.