Skip to content

Add --pretty-print flag to make-php command - #458

Merged
swissspidy merged 4 commits into
mainfrom
copilot/add-pretty-print-arg
Dec 11, 2025
Merged

swissspidy merged 4 commits into
mainfrom
copilot/add-pretty-print-arg

Conversation

Copilot AI commented Nov 2, 2025 •

Copy link
Copy Markdown
Contributor

The make-php command currently generates single-line minified PHP files, making them impractical to work with when replacing PO/MO files with PHP translations.

Changes

  • MakePhpCommand: Added --pretty-print flag that passes formatting option to PhpArrayGenerator
  • PhpArrayGenerator: Enhanced var_export() to support formatted output with proper indentation, newlines, and spacing when prettyPrint option is enabled
  • Tests: Added Behat scenario validating pretty-print functionality

Usage

# Default behavior (unchanged)
$ wp i18n make-php example-plugin-de_DE.po
# Creates: ['domain'=>'foo','messages'=>[...]]

# With pretty-print
$ wp i18n make-php example-plugin-de_DE.po --pretty-print
# Creates:
# [
#     'domain' => 'foo',
#     'messages' => [
#         'Hello' => 'Hallo',
#     ],
# ]

Both formats produce identical arrays when loaded. Follows the existing pattern from make-json --pretty-print.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Behat/Gherkin/zipball/34c9b59c59355a7b4c53b9f041c8dbd1c8acc3b4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/EFTEC/BladeOne/zipball/a19bf66917de0b29836983db87a455a4f6e32148
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ad545ea9c1b7d270ce0fc9cbfb884161cd706119
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/mck89/peast/zipball/c6a63f32410d2e4ee2cd20fe94b35af147fb852d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-gettext/Gettext/zipball/11af89ee6c087db3cf09ce2111a150bca5c46e12
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Fnltt2 /usr/bin/composer require gettext/gettext:^4.8 --no-interaction (http block)
  • https://api.github.com/repos/php-gettext/Languages/zipball/0b0b0851c55168e1dfb14305735c64019732b5f1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Fnltt2 /usr/bin/composer require gettext/gettext:^4.8 --no-interaction (http block)
  • https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/bVqpxp /usr/bin/composer install (http block)
  • https://api.github.com/repos/symfony/finder/zipball/9f696d2f1e340484b4683f7853b273abff94421f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
  • https://api.github.com/repos/wp-cli/mustache.php/zipball/ca23b97ac35fbe01c160549eb634396183d04a59
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
  • https://api.github.com/repos/wp-cli/php-cli-tools/zipball/f12b650d3738e471baed6dd47982d53c5c0ab1c3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)
  • https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/qWrmKa /usr/bin/composer install --no-dev (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>make-php - Make output file content pretty</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing

When we do wp i18n make-php it creates PHP files containing one line, like minified PHP, but If we want to delete the old .po/.mo files to work with only PHP translations, working one line generated files is not practical

image

Describe the solution you'd like

Formatted output will look better

image

</issue_description>

<agent_instructions>Add a new --pretty-print arg for the make-php command</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@swissspidy We can add a `pretty-print` option like we have for make-json. Wanna help put a PR together? :)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 2, 2025 14:19
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add --pretty-print argument for make-php command Add --pretty-print flag to make-php command Nov 2, 2025
Copilot AI requested a review from swissspidy November 2, 2025 14:27
@codecov

codecov Bot commented Nov 2, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/PhpArrayGenerator.php 93.75% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
swissspidy marked this pull request as ready for review November 2, 2025 14:33
@swissspidy
swissspidy requested a review from a team as a code owner November 2, 2025 14:33
@swissspidy swissspidy added the command:i18n-make-php Related to 'i18n make-php' command label Dec 11, 2025
@swissspidy
swissspidy merged commit 5becb64 into main Dec 11, 2025
51 checks passed
@swissspidy
swissspidy deleted the copilot/add-pretty-print-arg branch December 11, 2025 13:08
@swissspidy swissspidy added this to the 2.6.7 milestone Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:i18n-make-php Related to 'i18n make-php' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make-php - Make output file content pretty

2 participants