정렬하거나 정렬하지 않으려면 ...'='및 '-'에 대한 PHP 코드 스타일 정렬
다음 접근법의 장단점.
첫 번째 사례를 사용하고 싶습니다. 나는 그것이 최적이라고 생각하기 때문에 다른 누군가는 그렇지 않다고 생각합니다.
- 파일에 새로운 일정 추가 - (-> -> -> ->) - 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()
);
}
}
케이스 스타일이
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를 선호합니다. 종종 '='를 맞 춥니 다. 하지만 항상 그런 것은 아닙니다. 그러나 자주. 들여 쓰기에 관해서는 들여 쓰기해야 할 때 항상 코드를 들여 쓰기 위해서 4 칸 밖에 사용하지 않습니다. 이것은 예를 들어 IF 내부의 콘텐츠에 적용됩니다. 들여 쓰기에는 TAB을 사용하지 않습니다. 그것은 추천하지 않습니다. – halojoy
실제로 테스트하지 않고 예제 1은 PSR2와 일치하는 것으로 보입니다. –
이 질문은 기본적으로 스타일 및 전적으로 의견을 기반으로하기 때문에이 질문을 닫는 투표가 있습니다. 당신이해야 할 유일한 일은 파일 전체에 일관성을 유지하는 것입니다. – Philipp