Weird print_r function indentation formatting with hard-coded array
I don't know why it's doing this:
echo "relevant user details: " . print_r([
'ID' => $user->getId(),
'First Name' => $user->getFirstName(),
'Last Name' => $user->getLastName(),
], true);
No matter what I do, it does that weird formatting. Shouldn't it be like this?
echo "relevant user details: " . print_r([
'ID' => $user->getId(),
'First Name' => $user->getFirstName(),
'Last Name' => $user->getLastName(),
], true);
That's at least more readable for me.
If I put the `true` on its own line, it just indents that to the same column as the above line. If I instead put the `);` on its own line, it de-indents by one, but it's still indented by 1 compared to the first line.
Note that this is just an example of similar functional code.
Please sign in to leave a comment.
Hi there,
Must be something in your Code Style -- works fine for me (makes the following):
Can you please export your Code Style in XML format, upload it to something like Google Drive/DropBox/OneDrive/iCloud or other file sharing service and share the link so it can be downloaded and tested locally.
Ideally also share the file where this fragment gets formatted this way. Could be something in a file as well (never know for sure).
TBH, I have seen similar issues somewhere some time ago .. but cannot find one now that would show the solution/what was wrong.
I think it was an odd contextual thing.
When I copy-pasted your example to a different file, and run formatting on it, it looks OK.
Just a wild guessing here but is there any chance that you have an .editorconfig file in a folder where the original file resides?
The only one is web/assets/vendor/select2/.editorconfig
This is a committed file. I don't know how it was generated. It only has 1 commit in the repo, from 2017. I don't see that anything uses it.
This exact file should not affect the project code styling, thanks for checking!
Just to confirm, is it still reproducible or it was a one-time occurrence?
I haven't run into the problem again.