-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect indent behavior using deep-nested function and arrays #945
Labels
Comments
Some debug output to show what is going on (just for my records): First case 1: <?php
2: $somevariable = some_function(another_function($param1, $param2),
3: more_function($param3, another_one(
4: $key1, $value1,
5: $key2, $value2)));
6: $continue = this_line_is_correct_and_works_ok();
Second case 1: <?php
2: $somevariable = some_function(another_function($param1, $param2),
3: more_function($param3, array(
4: $key1, $value1,
5: $key2, $value2)));
6: $continue = now_this_and_every_line_after_is_doomed();
Third case 1: <?php
2: function read_competency_framework($id) {
3: global $PAGE;
4:
5: $params = self::validate_parameters(self::read_competency_framework_parameters(),
6: array(
7: 'id' => $id,
8: ));
9:
10: $framework = api::read_framework($params['id']);
11: self::validate_context($framework->get_context());
12: $output = $PAGE->get_renderer('tool_lp');
13: }
|
gsherwood
changed the title
Strange behavior using deep-nested function and arrays
Incorrect indent behavior using deep-nested function and arrays
May 31, 2016
gsherwood
added a commit
that referenced
this issue
May 31, 2016
This has been fixed now. |
Thanks, just confirming it fixed all our reported cases! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
But if I replace the
another_one()
function with an array declaration, everything becomes crazy since that point: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):
(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.
The text was updated successfully, but these errors were encountered: