Home » PHP » PHP_Beautifier » Bug #7825
Add token for string concat
Details
| Request #7825 | Add token for string concat |
|---|---|
| Submitted | 2006-06-07 03:06 UTC |
| From | studio at peptolab dot com |
| Assigned | clbustos |
| Status | Closed |
| Package | PHP_Beautifier |
| PHP Version | Irrelevant |
| OS | Any |
| Roadmaps | (Not assigned) |
Comments
[2006-06-07 03:06 UTC] studio at peptolab dot com
Description:
------------
I'm currently writing a new filter to take care of the new
Zend Framework style of coding standards, and I noticed that
PHP_BEautifier doesn't have any hooks for formatting the
string concat '.' operator.
The Zend framework recommends a space before and after the
'.', but this won't be modified with the current
implementation.
I see there was a bug #7313 referencing this issue, but I
don't see a problem with adding a hook for this token - even
if you decide the default behaviour is to ignore the
whitespace. It would be great to have the flexibility to add
it to a custom filter, though.
Test script:
---------------
Changes to Beautifier.php
from:
':'=>'T_COLON',
to:
':'=>'T_COLON',
'.'=>'T_CONCAT',
Changes to Default.filter.php
from:
function t_question($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' '.$sTag.' ');
}
to:
function t_question($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' '.$sTag.' ');
}
function t_concat($sTag)
{
$this->oBeaut->removeWhitespace();
$this->oBeaut->add(' '.$sTag.' ');
}
Expected result:
----------------
By default, this will allow PHP_Beautifier to format the
concat operator as desired. In the above example, it will
always add 1 space around the token either side, which is a
reasonable choice for defaults.
[2006-06-07 03:10 UTC] studio at peptolab dot com
I forgot to ask about the concatenating assignment operator as
well! :)
Sorry for the late request so close to the final release,
too...
[2006-06-07 04:56 UTC] clbustos at php dot net
Hey, no problem.
This is the only update to the package? Maybe, I can create a Zend filter, which put all the changes you need.
[2006-06-07 05:02 UTC] studio at peptolab dot com
That would be v. cool! The current rules are at http://
framework.zend.com/manual/en/coding-standard.coding-style.html
but I don't think they're wildly different from the PEAR
standards (except for the curly braces around functions and a
couple of other smaller aesthetic touches).
Let me know if you need some help, though - cheers Claudio!
[2006-06-08 04:38 UTC] clbustos at php dot net
Ufff... I haven't much time now. Did you say you're writing a filter? Add anything you want, including the base class. I'll review it and soon as I can, I merge all in a new version.
[2006-06-14 21:22 UTC] soporte at onfocus dot cl
I vote +1 for the inclusion of the first metioned change in the default filter.
I tested it, and does work, without noticing any side effects.
[2007-02-10 04:39 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