phpCodeBeautifierで汚くなる件
Do You PHP? - phpCodeBeautifier - コーディングスタイルを統一する
でも紹介*1されているPHPのソースコードを整形するphpCodeBeautifierですが、最近linux版も出たし、マニュアル に書いている内容を見てワクワクして突っ込んだんですが、汚くなる。
PEAR標準にするっぽい、サンプルの整形定義をPEAR.phpにそのまま突っ込んでも
before
function PEAR($error_class = null) { $classname = strtolower(get_class($this)); if ($this->_debug) { print "PEAR constructor called, class=$classname\n"; } if ($error_class !== null) { $this->_error_class = $error_class; } while ($classname && strcasecmp($classname, "pear")) { $destructor = "_$classname"; if (method_exists($this, $destructor)) { global $_PEAR_destructor_object_list; $_PEAR_destructor_object_list[] = &$this; if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { register_shutdown_function("_PEAR_call_destructors"); $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; } break; } else { $classname = get_parent_class($classname); } } }
after
function PEAR($error_class = null) { $classname = strtolower(get_class($this)); if ($this -> _debug) { print "PEAR constructor called, class=$classname\n"; } if ($error_class !== null) { $this -> _error_class = $error_class; } while ($classname && strcasecmp($classname, "pear")) { $destructor = "_$classname"; if (method_exists($this, $destructor)) { global $_PEAR_destructor_object_list; $_PEAR_destructor_object_list[] = &$this; if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { register_shutdown_function("_PEAR_call_destructors"); $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; } break; } else { $classname = get_parent_class($classname); } } }
こんな感じ。
alignとかも上手くいかない。
...Perltidyは凄いなあ。
追記
- --optimize-eol を追加したらちょっとましになった。でも空行が潰れるようになって見難い。
- --align-equal-statements-to-fixed-posを入れると結構大変なことに。function定義がこんな感じになど
function &raiseError($message = null,
$code = null,
$mode = null,
$options = null,
$userinfo = null,
$error_class = null,
$skipmsg = false)
{
*1:shimookaさんからいただいたコメントにもあるよう、オプションは全て「--」になっています。