Description
Recently, we upgraded to latest (master) phpcs version and after some discussions decided to move away from our own Indent sniff to the upstream generic one without modification (accepting its way for #907 and other considerations).
But it seems that have come with a unexpected surprise that we were not experimenting earlier. It happens where there are a number of nested functions, some of them including also some array.
For reference, we have tracked the problem @ https://tracker.moodle.org/browse/CONTRIB-6206
Basically, phpcs (generic indent sniff) considers this correct:
$somevariable = some_function(another_function($param1, $param2),
more_function($param3, another_one(
$key1, $value1,
$key2, $value2)));
$continue = this_line_is_correct_and_works_ok();
But if I replace the another_one()
function with an array declaration, everything becomes crazy since that point:
$somevariable = some_function(another_function($param1, $param2),
more_function($param3, array(
$key1, $value1,
$key2, $value2)));
$continue = now_this_and_every_line_after_is_doomed();
And the situation becomes worse (crazier) if we face some construction like this (note I don't like/consider them correct, but shows the problem with arrays in an extreme way):
function read_competency_framework($id) {
global $PAGE;
$params = self::validate_parameters(self::read_competency_framework_parameters(),
array(
'id' => $id,
));
$framework = api::read_framework($params['id']);
self::validate_context($framework->get_context());
$output = $PAGE->get_renderer('tool_lp');
}
(here it asks for a thousand (heh, 40) of chars for the rest of the file).
Ciao :-)
PS: I'll be investigating this along the week, will put any solution if I'm able, just wanted to have it reported asap.