Skip to content

Conversation

a-leurs
Copy link
Collaborator

@a-leurs a-leurs commented Jan 6, 2023

  • #26061 Change format of output
  • #25895 Add command for all config paths and subset of config paths

Copy link
Contributor

@avstudnitz avstudnitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good changes in general, just a couple of details.

$scopeValues = array();
foreach($all_configs as $element) {
$result_values = $this->scopeHintService->getConfigValuesForScopes($element);
foreach($result_values as $element2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a speaking name instead of $element2. I cannot figure out what $element2 contains by just looking at this function.


function displayArrayRecursively($array, &$result_array, $path) : void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I try to avoid variables as references and use return values instead. Usually (including this case), it's more readable.
Also please add types for the input parameters.

return [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$this->displayArrayRecursively($value, $result_array, $path . $key . '/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good usecase for recursive function calls. It's also good to have the "recursive" keyword in the function name 👍

@@ -104,6 +115,9 @@ public function getConfigValuesForScopes(
}
}

$configValues[0]["values"] = str_replace('\n', ' ', $configValues[0]["values"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, we only use single quotation marks in PHP code. An exception would be "\n", which doesn't work if it is '\n'. I am interested: does it work here?
So, I'd use single quotation marks where you use double quotation marks and vice versa in the code block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avstudnitz You're right. '\n' doesn't do anything. It needs to be put in double quotes.
But I only did that because I thought the line break destroys the creation of the cells of the table.
But it doesn't. So the code can be removed.

Change variable names to Camel case, removed reference from recursive function, removed unnecessary code
Copy link
Contributor

@avstudnitz avstudnitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better now, thanks.
There are still some formatting / code style issues like spaces and line breaks in the wrong position or missing. I'd suggest you configure code style checking with PHPMD and PHPCS and at least run it manually on the command line.

@a-leurs a-leurs merged commit 15ced4a into master Jan 11, 2023
@a-leurs
Copy link
Collaborator Author

a-leurs commented Jan 11, 2023

@avstudnitz Thanks. I will check the coding style with PHPMD and PHPCS later. Had to merge this PR because it was blocking me on another task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants