-
Sub-task
-
Resolution: Unresolved
-
Low
-
None
https://docs.moodle.org/dev/Coding_style#Wrapping_lines
if (a_long_condition() &&
|
a_nother_long_condition()) {
|
do_something();
|
}
|
https://docs.moodle.org/dev/Coding_style#Wrapping_Control_Structures
$coursecategory = ($element['object']->is_course_item() or $element['object']->is_category_item());
|
$scalevalue = in_array($element['object']->gradetype, array(GRADE_TYPE_SCALE, GRADE_TYPE_VALUE));
|
|
if ($coursecategory and $scalevalue) {
|
So do we add to new line with extra spaces, or do we break it into variable assignments with tests?
My preference is a variation on the latter:
$dosomething = a_long_condition();
|
$dosomething = $dosomething && a_nother_long_condition();
|
|
if ($dosomething) {
|
do_something();
|
}
|
Either way, the examples offer opposing advice - the 'good' example in wrapping control structure is basically the 'bad' example in wrapping lines.
- has a non-specific relationship to
-
MDLSITE-4184 Improve control structure wrapping style
-
- Open
-
-
MDLSITE-4389 RFC: Coding style for wrapping the code
-
- Open
-