Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion composer.json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's undo this change.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
"homepage": "https://www.alainschlesser.com"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wp-cli/wp-config-transformer"
}
],
"require": {
"wp-cli/wp-cli": "^2.13",
"wp-cli/wp-config-transformer": "^1.4.0"
"wp-cli/wp-config-transformer": "dev-main"
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Requiring wp-cli/wp-config-transformer as dev-main (combined with the VCS repository override above) makes installs non-deterministic and can break CI unexpectedly as main moves. Consider pinning to a specific commit hash or a tagged pre-release version for reproducibility, and then switching back to a stable semver constraint once a release is cut.

Suggested change
"wp-cli/wp-config-transformer": "dev-main"
"wp-cli/wp-config-transformer": "dev-main#<full-commit-hash>"

Copilot uses AI. Check for mistakes.
},
"require-dev": {
"wp-cli/db-command": "^1.3 || ^2",
Expand Down
39 changes: 39 additions & 0 deletions features/config-has.feature
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,42 @@ Feature: Check whether the wp-config.php file or the wp-custom-config.php file h
"""
Error: Found both a constant and a variable 'SOME_NAME' in the 'wp-custom-config.php' file. Use --type=<type> to disambiguate.
"""

Scenario Outline: Find constants and variables in a config with complex expressions
Given an empty directory
And a wp-includes/version.php file:
"""
<?php $wp_version = '6.3';
"""
And a wp-config.php file:
"""
<?php
$do_redirect = 'https://example.com' . $_SERVER['REQUEST_URI'];
$table_prefix = 'wp_';
define( 'DB_NAME', 'wp' );
define( 'CUSTOM_CSS', 'body {
color: red;
}' );
$after_multiline = 'found';
$long_url = 'https://example.com'
. '/path';
define( 'ALLOWED_HOSTS', array(
'example.com',
) );
$after_array_define = 'found';
"""

When I run `wp config has <name> --type=<type>`
Then STDOUT should be empty
And the return code should be 0

Examples:
| name | type | description |
| do_redirect | variable | concatenation expression itself |
| table_prefix | variable | variable after concatenation |
| DB_NAME | constant | constant after concatenation variable |
| CUSTOM_CSS | constant | constant with multiline string value |
| after_multiline | variable | variable after multiline string value |
| long_url | variable | multiline concatenation variable |
| ALLOWED_HOSTS | constant | constant with multiline raw value |
| after_array_define | variable | variable after multiline raw define |