Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
7834a80
Fix type hinting for prompt function
valera-seregin Jan 12, 2021
80bb837
Update Streams.php
dan-m-joh Jul 26, 2021
0618eb0
Update file(s) from wp-cli/.github
schlessera Aug 8, 2022
b6a91b0
Update file(s) from wp-cli/.github
schlessera Aug 11, 2022
b565706
Merge pull request #146 from dan-m-joh/patch-1
schlessera Aug 11, 2022
b6edd35
Update file(s) from wp-cli/.github
schlessera Aug 15, 2022
9ee8aae
Update file(s) from wp-cli/.github
schlessera Oct 6, 2022
c4f1165
Update file(s) from wp-cli/.github
schlessera Oct 17, 2022
ef14081
Update file(s) from wp-cli/.github
schlessera Oct 17, 2022
02e2521
Update file(s) from wp-cli/.github
schlessera Oct 17, 2022
9967c84
Update file(s) from wp-cli/.github
schlessera Oct 27, 2022
c3e2df0
Add annotations to remove deprecated warning message on php8.1 (#152)
aerogus Nov 3, 2022
c32e51a
Add CODEOWNERS so we get pings
danielbachhuber Nov 3, 2022
41d941e
Add a `phpunit.xml.dist` file to restore PHPUnit tests
danielbachhuber Nov 4, 2022
fce23f1
Update `composer.json` with necessary goodness
danielbachhuber Nov 4, 2022
2641de1
Apply a `branch-alias`
danielbachhuber Nov 4, 2022
7c88b87
Update file(s) from wp-cli/.github
danielbachhuber Nov 4, 2022
9663792
Update file(s) from wp-cli/.github
schlessera Nov 4, 2022
2b89116
First pass at PHPUnit v9 support
danielbachhuber Nov 6, 2022
a255a87
Update assertions
danielbachhuber Nov 6, 2022
217cb51
Skip this unexpectedly failing test
danielbachhuber Nov 6, 2022
567cee5
Use `WP_CLI\Tests\TestCase` for better PHP version compat
danielbachhuber Nov 6, 2022
243ec85
Remove `:void()` statements for PHP version compat
danielbachhuber Nov 6, 2022
1f8fdf0
Remove `: void` for PHP version compat
danielbachhuber Nov 6, 2022
f86ff11
Use these version-agnostic `setUp()` and `tearDown()` methods
danielbachhuber Nov 6, 2022
5c1497c
Merge pull request #155 from wp-cli/150-restore-phpunit
schlessera Nov 10, 2022
a464831
Update file(s) from wp-cli/.github
schlessera Jan 3, 2023
acd7ae8
Update file(s) from wp-cli/.github
danielbachhuber Jan 5, 2023
eca758e
Update file(s) from wp-cli/.github
schlessera Jan 10, 2023
f6be76b
Update file(s) from wp-cli/.github
schlessera Jan 12, 2023
0f503a7
fix PHP Deprecated: Creation of dynamic property (#158)
aerogus Apr 4, 2023
22270f4
Update file(s) from wp-cli/.github
schlessera May 27, 2023
2d27f0d
Prevent warnings in PHP 8.2 when `$col_values` is empty (#160)
danielbachhuber Jul 21, 2023
d788a2c
Update to WPCS v3 (#161)
danielbachhuber Sep 1, 2023
b3457a8
PHP 8.2: strwidth() & Colors::pad()/decolorize() should always work w…
slaFFik Sep 29, 2023
0c04162
Make type more precise
swissspidy Nov 2, 2023
79e1610
Merge pull request #141 from valeriySeregin/fix-default-value-in-prompt
swissspidy Nov 3, 2023
b2c601b
Remove inexistent `post-install-cmd` (#167)
swissspidy Nov 10, 2023
8ffd0cf
Use class instead of static variables for the speed measurement (#168)
pfefferle Nov 16, 2023
f49e2fa
Fix maxFlag to flagMax and maxOption to optionMax typos in HelpScreen…
kodie Dec 3, 2023
a6bb946
Merge pull request #170 from kodie/fix-maxFlag-and-maxOption-typo
swissspidy Dec 3, 2023
4f9ecb7
Rename class files
swissspidy May 22, 2024
011d727
Remove Travis config
swissspidy May 22, 2024
4aa8c54
Bump PHP requirement
swissspidy May 22, 2024
891d6ed
Add back `use` statements
swissspidy May 22, 2024
3ffb098
Make data providers static
swissspidy May 22, 2024
3a5cdd1
Fix `expectWarning` usage
swissspidy May 22, 2024
6507ba2
Undo some changes
swissspidy May 22, 2024
8a56070
Use `strtolower`
swissspidy May 22, 2024
2d1da47
Merge pull request #172 from wp-cli/fix/unit-tests
swissspidy May 22, 2024
5edc06b
PHP 8.4 | Fix implicitly nullable parameters
jrfnl Sep 16, 2024
b70a964
PHP 8.1: fix "passing null to non-nullable"
jrfnl Sep 16, 2024
615bdb6
Merge pull request #174 from jrfnl/feature/php-8.1-fix-passing-null-t…
swissspidy Sep 17, 2024
46ddc1d
Merge pull request #173 from jrfnl/feature/php-8.4-fix-implicitly-nul…
swissspidy Sep 17, 2024
7147e95
PHP 8.4 | Example code: remove use of `E_STRICT`
jrfnl Sep 18, 2024
75bb5ad
Merge pull request #175 from jrfnl/feature/php-8.4-remove-estrict
swissspidy Sep 24, 2024
387cabe
PHPUnit: convert deprecations to exceptions
swissspidy Oct 1, 2024
d1fe500
Merge pull request #176 from wp-cli/update-phpunit-config
swissspidy Oct 1, 2024
62f1f00
Properly handle line breaks in column value (#179)
mrsdizzie Mar 3, 2025
77616d6
Allow manually triggering tests (#180)
swissspidy Mar 3, 2025
8063b4d
Replace tabs in tables with 4 spaces (#181)
swissspidy Mar 3, 2025
1556134
Support line breaks and tab replacement in tabular table values (#182)
mrsdizzie Mar 4, 2025
fbb9c6e
Fix removal of trailing tab / whitespace in tabular table (#184)
mrsdizzie Mar 5, 2025
34b83b4
Convert null values to empty strings (#185)
mrsdizzie Mar 26, 2025
c7ff991
Require PHP 7.2.24+
swissspidy May 10, 2025
cd6be7a
Merge pull request #186 from wp-cli/add/bump-requirements
mrsdizzie May 12, 2025
3be67d9
Update wp-cli-tests to v5 (#187)
swissspidy Jul 4, 2025
f12b650
Fix `null` array access in `Colors.php` (#188)
swissspidy Sep 11, 2025
e6f078b
Update file(s) from wp-cli/.github
swissspidy Oct 8, 2025
a98408c
Update file(s) from wp-cli/.github
swissspidy Oct 8, 2025
81098df
Update file(s) from wp-cli/.github
swissspidy Nov 11, 2025
65b12ff
Update file(s) from wp-cli/.github
swissspidy Dec 11, 2025
0d17191
Update file(s) from wp-cli/.github
swissspidy Dec 11, 2025
f13b62b
Update file(s) from wp-cli/.github
swissspidy Dec 12, 2025
e974555
Update file(s) from wp-cli/.github
schlessera Dec 12, 2025
c9e78f4
Update file(s) from wp-cli/.github
schlessera Dec 12, 2025
68a82ac
Fix test_strwidth() ICU version-dependent behavior for Devanagari con…
Copilot Dec 12, 2025
87a1c35
Update file(s) from wp-cli/.github
swissspidy Dec 17, 2025
900ff43
Update file(s) from wp-cli/.github
swissspidy Dec 20, 2025
77652fd
Update file(s) from wp-cli/.github
swissspidy Jan 6, 2026
bd83c3f
Update file(s) from wp-cli/.github
swissspidy Jan 6, 2026
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
3 changes: 3 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configuration file for nektos/act.
# See https://github.com/nektos/act#configuration
-P ubuntu-latest=shivammathur/node:latest
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

# From https://github.com/WordPress/wordpress-develop/blob/trunk/.editorconfig with a couple of additions.

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[{*.yml,*.feature,.jshintrc,*.json}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[{*.txt,wp-config-sample.php}]
end_of_line = crlf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @wp-cli/committers
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ updates:
open-pull-requests-limit: 10
labels:
- scope:distribution
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- scope:distribution

14 changes: 14 additions & 0 deletions .github/workflows/check-branch-alias.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check Branch Alias

on:
release:
types: [released]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
check-branch-alias:
uses: wp-cli/.github/.github/workflows/reusable-check-branch-alias.yml@main
12 changes: 12 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code Quality Checks

on:
pull_request:
push:
branches:
- main
- master

jobs:
code-quality:
uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main
46 changes: 46 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Copilot Setup Steps"

on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml

jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Check existence of composer.json file
id: check_composer_file
uses: andstor/file-existence-action@v3
with:
files: "composer.json"

- name: Set up PHP environment
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: 'none'
tools: composer,cs2pr
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Composer dependencies & cache dependencies
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: ramsey/composer-install@v3
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
26 changes: 26 additions & 0 deletions .github/workflows/issue-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Issue and PR Triage

'on':
issues:
types: [opened]
pull_request_target:
types: [opened]
workflow_dispatch:
inputs:
issue_number:
description: 'Issue/PR number to triage (leave empty to process all)'
required: false
type: string

jobs:
issue-triage:
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main
with:
issue_number: >-
${{
(github.event_name == 'workflow_dispatch' && inputs.issue_number) ||
(github.event_name == 'pull_request_target' && github.event.pull_request.number) ||
(github.event_name == 'issues' && github.event.issue.number) ||
''
}}
19 changes: 19 additions & 0 deletions .github/workflows/manage-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Manage Labels

'on':
workflow_dispatch:
push:
branches:
- main
- master
paths:
- 'composer.json'

permissions:
issues: write
contents: read

jobs:
manage-labels:
uses: wp-cli/.github/.github/workflows/reusable-manage-labels.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/regenerate-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Regenerate README file

on:
workflow_dispatch:
push:
branches:
- main
- master
paths-ignore:
- "features/**"
- "README.md"

jobs:
regenerate-readme:
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Testing

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- master
schedule:
- cron: '17 1 * * *' # Run every day on a seemly random time.

jobs:
test:
uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main
12 changes: 12 additions & 0 deletions .github/workflows/welcome-new-contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Welcome New Contributors

on:
pull_request_target:
types: [opened]
branches:
- main
- master

jobs:
welcome:
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor
.*.swp
composer.lock
.phpunit.result.cache
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

121 changes: 121 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Instructions

This package is part of WP-CLI, the official command line interface for WordPress. For a detailed explanation of the project structure and development workflow, please refer to the main @README.md file.

## Best Practices for Code Contributions

When contributing to this package, please adhere to the following guidelines:

* **Follow Existing Conventions:** Before writing any code, analyze the existing codebase in this package to understand the coding style, naming conventions, and architectural patterns.
* **Focus on the Package's Scope:** All changes should be relevant to the functionality of the package.
* **Write Tests:** All new features and bug fixes must be accompanied by acceptance tests using Behat. You can find the existing tests in the `features/` directory. There may be PHPUnit unit tests as well in the `tests/` directory.
* **Update Documentation:** If your changes affect the user-facing functionality, please update the relevant inline code documentation.

### Building and running

Before submitting any changes, it is crucial to validate them by running the full suite of static code analysis and tests. To run the full suite of checks, execute the following command: `composer test`.

This single command ensures that your changes meet all the quality gates of the project. While you can run the individual steps separately, it is highly recommended to use this single command to ensure a comprehensive validation.

### Useful Composer Commands

The project uses Composer to manage dependencies and run scripts. The following commands are available:

* `composer install`: Install dependencies.
* `composer test`: Run the full test suite, including linting, code style checks, static analysis, and unit/behavior tests.
* `composer lint`: Check for syntax errors.
* `composer phpcs`: Check for code style violations.
* `composer phpcbf`: Automatically fix code style violations.
* `composer phpstan`: Run static analysis.
* `composer phpunit`: Run unit tests.
* `composer behat`: Run behavior-driven tests.

### Coding Style

The project follows the `WP_CLI_CS` coding standard, which is enforced by PHP_CodeSniffer. The configuration can be found in `phpcs.xml.dist`. Before submitting any code, please run `composer phpcs` to check for violations and `composer phpcbf` to automatically fix them.

## Documentation

The `README.md` file might be generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). In that case, changes need to be made against the corresponding part of the codebase.

### Inline Documentation

Only write high-value comments if at all. Avoid talking to the user through comments.

## Testing

The project has a comprehensive test suite that includes unit tests, behavior-driven tests, and static analysis.

* **Unit tests** are written with PHPUnit and can be found in the `tests/` directory. The configuration is in `phpunit.xml.dist`.
* **Behavior-driven tests** are written with Behat and can be found in the `features/` directory. The configuration is in `behat.yml`.
* **Static analysis** is performed with PHPStan.

All tests are run on GitHub Actions for every pull request.

When writing tests, aim to follow existing patterns. Key conventions include:

* When adding tests, first examine existing tests to understand and conform to established conventions.
* For unit tests, extend the base `WP_CLI\Tests\TestCase` test class.
* For Behat tests, only WP-CLI commands installed in `composer.json` can be run.

### Behat Steps

WP-CLI makes use of a Behat-based testing framework and provides a set of custom step definitions to write feature tests.

> **Note:** If you are expecting an error output in a test, you need to use `When I try ...` instead of `When I run ...` .

#### Given

* `Given an empty directory` - Creates an empty directory.
* `Given /^an? (empty|non-existent) ([^\s]+) directory$/` - Creates or deletes a specific directory.
* `Given an empty cache` - Clears the WP-CLI cache directory.
* `Given /^an? ([^\s]+) (file|cache file):$/` - Creates a file with the given contents.
* `Given /^"([^"]+)" replaced with "([^"]+)" in the ([^\s]+) file$/` - Search and replace a string in a file using regex.
* `Given /^that HTTP requests to (.*?) will respond with:$/` - Mock HTTP requests to a given URL.
* `Given WP files` - Download WordPress files without installing.
* `Given wp-config.php` - Create a wp-config.php file using `wp config create`.
* `Given a database` - Creates an empty database.
* `Given a WP install(ation)` - Installs WordPress.
* `Given a WP install(ation) in :subdir` - Installs WordPress in a given directory.
* `Given a WP install(ation) with Composer` - Installs WordPress with Composer.
* `Given a WP install(ation) with Composer and a custom vendor directory :vendor_directory` - Installs WordPress with Composer and a custom vendor directory.
* `Given /^a WP multisite (subdirectory|subdomain)?\s?(install|installation)$/` - Installs WordPress Multisite.
* `Given these installed and active plugins:` - Installs and activates one or more plugins.
* `Given a custom wp-content directory` - Configure a custom `wp-content` directory.
* `Given download:` - Download multiple files into the given destinations.
* `Given /^save (STDOUT|STDERR) ([\'].+[^\'])?\s?as \{(\w+)\}$/` - Store STDOUT or STDERR contents in a variable.
* `Given /^a new Phar with (?:the same version|version "([^"]+)")$/` - Build a new WP-CLI Phar file with a given version.
* `Given /^a downloaded Phar with (?:the same version|version "([^"]+)")$/` - Download a specific WP-CLI Phar version from GitHub.
* `Given /^save the (.+) file ([\'].+[^\'])? as \{(\w+)\}$/` - Stores the contents of the given file in a variable.
* `Given a misconfigured WP_CONTENT_DIR constant directory` - Modify wp-config.php to set `WP_CONTENT_DIR` to an empty string.
* `Given a dependency on current wp-cli` - Add `wp-cli/wp-cli` as a Composer dependency.
* `Given a PHP built-in web server` - Start a PHP built-in web server in the current directory.
* `Given a PHP built-in web server to serve :subdir` - Start a PHP built-in web server in the given subdirectory.

#### When

* ``When /^I launch in the background `([^`]+)`$/`` - Launch a given command in the background.
* ``When /^I (run|try) `([^`]+)`$/`` - Run or try a given command.
* ``When /^I (run|try) `([^`]+)` from '([^\s]+)'$/`` - Run or try a given command in a subdirectory.
* `When /^I (run|try) the previous command again$/` - Run or try the previous command again.

#### Then

* `Then /^the return code should( not)? be (\d+)$/` - Expect a specific exit code of the previous command.
* `Then /^(STDOUT|STDERR) should( strictly)? (be|contain|not contain):$/` - Check the contents of STDOUT or STDERR.
* `Then /^(STDOUT|STDERR) should be a number$/` - Expect STDOUT or STDERR to be a numeric value.
* `Then /^(STDOUT|STDERR) should not be a number$/` - Expect STDOUT or STDERR to not be a numeric value.
* `Then /^STDOUT should be a table containing rows:$/` - Expect STDOUT to be a table containing the given rows.
* `Then /^STDOUT should end with a table containing rows:$/` - Expect STDOUT to end with a table containing the given rows.
* `Then /^STDOUT should be JSON containing:$/` - Expect valid JSON output in STDOUT.
* `Then /^STDOUT should be a JSON array containing:$/` - Expect valid JSON array output in STDOUT.
* `Then /^STDOUT should be CSV containing:$/` - Expect STDOUT to be CSV containing certain values.
* `Then /^STDOUT should be YAML containing:$/` - Expect STDOUT to be YAML containing certain content.
* `Then /^(STDOUT|STDERR) should be empty$/` - Expect STDOUT or STDERR to be empty.
* `Then /^(STDOUT|STDERR) should not be empty$/` - Expect STDOUT or STDERR not to be empty.
* `Then /^(STDOUT|STDERR) should be a version string (<|<=|>|>=|==|=|<>) ([+\w.{}-]+)$/` - Expect STDOUT or STDERR to be a version string comparing to the given version.
* `Then /^the (.+) (file|directory) should( strictly)? (exist|not exist|be:|contain:|not contain):$/` - Expect a certain file or directory to (not) exist or (not) contain certain contents.
* `Then /^the contents of the (.+) file should( not)? match (((\/.*\/)|(#.#))([a-z]+)?)$/` - Match file contents against a regex.
* `Then /^(STDOUT|STDERR) should( not)? match (((\/.*\/)|(#.#))([a-z]+)?)$/` - Match STDOUT or STDERR against a regex.
* `Then /^an email should (be sent|not be sent)$/` - Expect an email to be sent (or not).
* `Then the HTTP status code should be :code` - Expect the HTTP status code for visiting `http://localhost:8080`.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
PHP Command Line Tools
======================

[![Build Status](https://travis-ci.org/wp-cli/php-cli-tools.png?branch=master)](https://travis-ci.org/wp-cli/php-cli-tools)

A collection of functions and classes to assist with command line development.

Requirements

* PHP >= 5.3
* PHP >= 5.6

Suggested PHP extensions

Expand Down
Loading