Skip to content

Refactor: remove unused imports#6277

Merged
swissspidy merged 3 commits intowp-cli:mainfrom
Soean:remove_unused_imports
Mar 16, 2026
Merged

Refactor: remove unused imports#6277
swissspidy merged 3 commits intowp-cli:mainfrom
Soean:remove_unused_imports

Conversation

@Soean
Copy link
Copy Markdown
Contributor

@Soean Soean commented Mar 16, 2026

This pull request makes minor code cleanups by removing unused import statements in several files. These changes help keep the codebase tidy and reduce unnecessary dependencies.

@Soean Soean requested a review from a team as a code owner March 16, 2026 11:03
@github-actions
Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added the command:cli Related to 'cli' command label Mar 16, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on minor code refactoring by eliminating unused import statements. The changes contribute to a cleaner and more maintainable codebase by removing declarations that are no longer needed, thereby reducing potential confusion and improving overall code health.

Highlights

  • Code Cleanup: Removed unused import statements across several PHP files to improve code tidiness and reduce unnecessary dependencies.
Changelog
  • php/WP_CLI/Bootstrap/CheckRoot.php
    • Removed the WP_CLI\Utils import statement.
  • php/WP_CLI/Context/Admin.php
    • Removed the WP_Session_Tokens import statement.
  • php/WP_CLI/Runner.php
    • Removed multiple unused import statements, specifically WP_CLI\Dispatcher, WP_CLI\Fetchers, WP_CLI\Loggers, and WP_CLI\Utils.
  • php/WP_CLI/ShutdownHandler.php
    • Removed the WP_CLI\Utils import statement.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request removes unused use statements across several PHP files. The changes are straightforward and I've confirmed that the removed imports are indeed not used in the respective files. The refactoring is correct and I have no further feedback.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy
Copy link
Copy Markdown
Member

Thanks!

I would love if this would be automated instead to reduce maintenance burden. I usually use slevomat/coding-standard with the SlevomatCodingStandard.Namespaces.UnusedUses rule. Would be a great addition for our wp-cli-tests package so we can automatically use it across all our packages.

@Soean
Copy link
Copy Markdown
Contributor Author

Soean commented Mar 16, 2026

I created an issue: wp-cli/wp-cli-tests#310

@swissspidy swissspidy added this to the 3.0.0 milestone Mar 16, 2026
@swissspidy swissspidy merged commit 1c28b98 into wp-cli:main Mar 16, 2026
69 checks passed
@Soean Soean deleted the remove_unused_imports branch March 16, 2026 14:58
swissspidy pushed a commit to apermo/wp-cli that referenced this pull request Mar 16, 2026
swissspidy added a commit that referenced this pull request Mar 16, 2026
…6270)

* fix(context): resolve admin user dynamically

Replace hardcoded user ID 1 fallback in Admin
context with smart user resolution. On multisite,
queries get_super_admins() to find a valid super
admin. On single site, queries for the first user
with the administrator role. Emits a clear error
if no suitable user is found.

Fixes #6269

* fix(context): optimize query and add test cases

Use get_users() with login__in for single DB query
instead of looping get_user_by(). Add single-site
error case test. Replace wp super-admin commands
with direct option manipulation in tests.

* fix(context): fix linting issues

Use single quotes for strings per PHPCS rules.
Fix gherkin use-and lint violations by replacing
consecutive When steps with And.

* fix(context): address review feedback

Revert multisite super admin lookup from get_users()
back to foreach + get_user_by('login') loop because
get_users() only fetches users on the current site
but a super admin might not be a member of any site.

Add debug logging after resolving admin user ID.

* fix(context): use instanceof for type safety

* Fix autoloader priority: locally installed packages now fully override phar-bundled versions (#6218)

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>

* Add environment variable configuration support to wp-cli.yml (#6169)

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>

* Autocomplete `--url` (#5704)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>

* Add WP-CLI handbook link to `wp help` output (#6273)

* Initial plan

* Add WP-CLI handbook URL reference to wp help output

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

* Update file(s) from wp-cli/.github

* Update file(s) from wp-cli/.github

* Fix SSH alias path not forwarded to remote when defined as a separate config key (#6274)

* Initial plan

* Fix SSH alias path not forwarded to remote when path is a separate config key

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

* Fix: forward active alias to runcommand subprocess (#6272)

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Fix vagrant SSH strict host key checking failure (#6275)

* Initial plan

* Fix vagrant SSH strict host key checking failure

When ssh: vagrant is configured and vagrant ssh-config is parsed,
add -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null to
the SSH command to match what vagrant itself sets. This prevents
failures when the vagrant VM has been recreated and has a different
host key than what is stored in ~/.ssh/known_hosts.

Adds a Behat test scenario to verify the fix.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @swissspidy

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Add optional `$newline` parameter to `WP_CLI::log()` and `WP_CLI::line()` (#6276)

* Initial plan

* Add optional $newline parameter to WP_CLI::log(), WP_CLI::line(), and logger info() methods

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

* Undo Base class change

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>

* Refactor: remove unused imports (#6277)

* Harden some tests on macOS

* Update tests

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Pascal Birchler <pascalb@google.com>
Co-authored-by: Ian Dunn <ian@iandunn.name>
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-authored-by: swissspidy <swissspidy@users.noreply.github.com>
Co-authored-by: Sören Wünsch <soerenwrede@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cli Related to 'cli' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants