对齐还是不对齐...
以下方法的优缺点。
我喜欢使用第一种情况。因为我认为这是最佳的,但其他人却不这么认为。
- 向文件添加新常量时 - diff 是 1 个字符串,而不是更多
- 更清晰,更美丽
- 链式调用 (-> -> -> ->) - 更清晰
你怎么看?可能有关于它的 PSR 吗?
案例风格1
class A {
const AB = 1;
const PAGE = 2;
const PP_SOMETHING_VERY_LONG = 3;
public function testLoooooooooong()
{
$a = 1;
$somethingWeryLong = 2;
$c = 3;
$res = $a + $c;
$b = 1;
$n = 100;
return 0;
}
public function test2($objectttttttttttttttLooooooong)
{
$objectttttttttttttttLooooooong->callSooooooooomethingLooooooong()
->call(
$this->testLoooooooooong(),
$this->testLoooooooooong2(),
$this->testLoooooooooong3()
)
->call(
$this->testLoooooooooong(),
$this->testLoooooooooong2(),
$this->testLoooooooooong3()
);
}
}
案例风格2
class A {
const AB = 1;
const PAGE = 2;
const PP_SOMETHING_VERY_LONG = 3;
public function testLoooooooooong() {
$a = 1;
$somethingWeryLong = 2;
$c = 3;
$res = $a + $c;
$b = 1;
$n = 100;
return 0;
}
public function test2($objectttttttttttttttLooooooong) {
$objectttttttttttttttLooooooong->callSooooooooomethingLooooooong()
->call(
$this->testLoooooooooong(),
$this->testLoooooooooong2(),
$this->testLoooooooooong3()
)
->call(
$this->testLoooooooooong(),
$this->testLoooooooooong2(),
$this->testLoooooooooong3()
);
}
}