Skip to content
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

Improve array output format for etc.php and config.php #14042

Merged

Conversation

avstudnitz
Copy link
Contributor

@avstudnitz avstudnitz commented Mar 10, 2018

Description

This improved the syntax of the generated files app/etc/env.php and app/etc/config.php by using 4 instead of 2 spaces and by removing whitelines after "=>".

Fixed Issues (if relevant)

The generated array code wasn't compliant to formatting standard. Example from config.php:

<?php
return [
  'modules' => 
  [
    'Magento_Store' => 1,
    'Magento_AdvancedPricingImportExport' => 1,

Manual testing scenarios

  1. Run a command which regenerates env.php and/or config.php, i.e. bin/magento config:set general/store_information/name "My Store" --lock-config
  2. Check that the generated file (i.e. app/etc/config.php) is formatted like this, with 4 space indent and removed line breaks:
<?php
return [
    'modules' => [
        'Magento_Store' => 1,
        'Magento_AdvancedPricingImportExport' => 1,

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@avstudnitz
Copy link
Contributor Author

Regarding the Codacy review which says I should not use else:

I can change this section:

                if (is_array($value)) {
                    $elements[] = $prefix . $this->varExportShort($key) . ' => [';
                    $elements[] = $this->formatData($value, [], '    ' . $prefix);
                    $elements[] = $prefix . '],';
                } else {
                    $elements[] = $prefix . $this->varExportShort($key) . ' => ' . $this->varExportShort($value) . ',';
                }

to

                if (is_array($value)) {
                    $elements[] = $prefix . $this->varExportShort($key) . ' => [';
                    $elements[] = $this->formatData($value, [], '    ' . $prefix);
                    $elements[] = $prefix . '],';
                    continue;
                } 
                $elements[] = $prefix . $this->varExportShort($key) . ' => ' . $this->varExportShort($value) . ',';

I wouldn't like to make that change as it's easier to understand with the else statement.

@sidolov
Copy link
Contributor

sidolov commented Mar 11, 2018

Hi @avstudnitz , I'm ok with your decision regarding else statement, you may ignore Codacy failures

@magento-engcom-team
Copy link
Contributor

Hi @mzeis, thank you for the review.
ENGCOM-844 has been created to process this Pull Request

@mzeis
Copy link
Contributor

mzeis commented Mar 16, 2018

Hi @avstudnitz, thank you very much for your PR! It has been merged into 2.2-develop.

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

Successfully merging this pull request may close these issues.

4 participants