Home » PHP » PHP_Beautifier » Bug #5711
Pear Filter does not work correctly
Details
| Submitted | 2005-10-18 08:11 UTC |
|---|---|
| From | nohn at php dot net |
| Assigned | clbustos |
| Status | Closed |
| Package | PHP_Beautifier |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-10-18 08:11 UTC] nohn at php dot net
Description:
------------
PEAR filter does not work correctly. See http://pear.php.net/manual/en/standards.funcdef.php for example.
Test script:
---------------
<?php
error_reporting(E_ALL|E_STRICT);
require_once ('PHP/Beautifier.php');
require_once ('PHP/Beautifier/Batch.php');
$file = $_SERVER['argv'][1];
if (file_exists($file)) {
try {
$oBeaut = new PHP_Beautifier();
$oBatch = new PHP_Beautifier_Batch($oBeaut);
$oBatch->addFilter('Pear');
$oBatch->setInputFile($file);
$oBatch->setOutputFile($file.'.beautified');
$oBatch->process();
$oBatch->save();
}
catch(Exception $oExp) {
echo ($oExp);
}
} else {
die('Could not find '.$file);
}
?>
------------------------------------------------------
<?php
class CampaignManagerConfig {
const BLOCKSIZE_ALL = 9999999;
public static function getStagingUrl($liveUrl) {
return true;
}
}
?>
Expected result:
----------------
<?php
class CampaignManagerConfig
{
const BLOCKSIZE_ALL = 9999999;
public static function getStagingUrl($liveUrl)
{
return true;
}
}
?>
Actual result:
--------------
<?php
class CampaignManagerConfig {
const BLOCKSIZE_ALL = 9999999;
public static function getStagingUrl($liveUrl) {
return true;
}
}
?>
[2005-11-17 01:32 UTC] clbustos at php dot net
Please, wait until version 0.2.0
[2005-11-24 10:51 UTC] karsten at plamo dot de
Kubuntu, latest release.
PHP5 CLI installed by kubuntu.
I installed the latest version and use php_beautifier with
the following options:
php_beautifier -l Pear() -l ArrayNested() -l NewLines() -t
This did work great before and eased my work so very much.
Your example:
<?php
$aMyArray = array( array( array( getText('dfdf'),
array( 'el'=>1, 'el'=>2 ) ) ) );
$a=array('1','2',array( ),array( ),array( ));
for($x;$x<10;$x++) {}
?>
The output grows with every run by some new lines and the
indend is totally messed:
<?php
$aMyArray = array(
array(
array(
getText('dfdf') ,
array(
'el'=>1,
'el'=>2
)
)
)
);
$a = array(
'1',
'2',
array() ,
array() ,
array()
);
for ($x;$x<10;$x++) {
}
?>
[2005-11-25 02:55 UTC] clbustos at php dot net
New Lines filter is the guilty one. In every pass, add new lines to the output, breaking your format
[2005-11-25 03:04 UTC] clbustos at php dot net
Expected output should be
<code>
<?php
class CampaignManagerConfig
{
const BLOCKSIZE_ALL = 9999999;
public static function getStagingUrl($liveUrl)
{
return true;
}
}
?>
</code>
not
<code>
<?php
class CampaignManagerConfig
{
const BLOCKSIZE_ALL = 9999999;
public static function getStagingUrl($liveUrl)
{
return true;
}
}
?>
</code>
[2006-04-01 18:02 UTC] clbustos at php dot net
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/get/PHP_Beautifier
The bug about pear filter was fixed on 0.1.8. The other bug, about spaces in New Line filter, should be posted on a new bug report.