Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

  • Move SearchReplacer functionality into Search_Replace_Command as private methods
  • Replace the two new SearchReplacer() instantiations with calls to new methods
  • Add deprecation notice to SearchReplacer class
  • Remove unused import of SearchReplacer from Search_Replace_Command
  • Fix incomplete comment in run_search_replace_recursively method
  • Add clarifying comments for boolean parameters
  • Fix spelling errors in comments
  • Update test to reflect refactored method name (SearchReplacer::run_recursively → Search_Replace_Command::run_search_replace_recursively)
  • Run tests to verify changes work correctly
  • Run linter and static analysis to ensure code quality
  • Complete code review and address all feedback
Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor WP_CLI\SearchReplacer functionality.</issue_title>
<issue_description>See #62 (comment)

The WP_CLI\SearchReplacer class now takes a load of args on construction which just mirror those being set in Search_Replace_Command which doesn't make much sense to me.

I think it should be deprecated (and left around unused for BC maybe) and its functionality either put straight into Search_Replace_Command (as it once was 29454e3), or put into a utils function (as it once was aa7df69) where it would now take a closure callback that would have all the info and do the actual replacement.

Note also that the phpunit tests tests/test-search-replace.php were never moved from wp-cli/wp-cli.</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Refactor WP_CLI\SearchReplacer functionality Refactor SearchReplacer into Search_Replace_Command Feb 1, 2026
Copilot AI requested a review from swissspidy February 1, 2026 19:49
@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 71.73913% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Search_Replace_Command.php 71.73% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy
Copy link
Member

@copilot Looks like a test needs updating:

001 Scenario: Warn and ignore type-hinted objects that have some error in deserialization (PHP < 8.0) # features/search-replace.feature:1127

        --- Expected
        +++ Actual
        @@ @@
        -Warning: WP_CLI\SearchReplacer::run_recursively(): Couldn't fetch mysqli_result
        +PHP Warning:  Search_Replace_Command::run_search_replace_recursively(): Couldn't fetch mysqli_result in src/Search_Replace_Command.php on line 1265
        +Warning: Search_Replace_Command::run_search_replace_recursively(): Couldn't fetch mysqli_result in src/Search_Replace_Command.php on line 1265

Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot Looks like a test needs updating:

...

Updated the test in cf02fb8 to reflect the refactored method name: SearchReplacer::run_recursively()Search_Replace_Command::run_search_replace_recursively()

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor WP_CLI\SearchReplacer functionality.

2 participants