Conversation
Summary of ChangesHello @swissspidy, 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 addressing newly reported PHPStan errors by modernizing the codebase. It updates array initializations to use the contemporary short array syntax and refines PHPDoc type hints for improved accuracy in static analysis. These changes enhance code consistency and help prevent potential issues identified by static analysis tools. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
|
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:
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:123You can find a list of all available Behat steps in our handbook. |
There was a problem hiding this comment.
Code Review
This pull request modernizes array syntax and improves PHPDoc types to address PHPStan errors. The changes are generally good, but I've found a few areas for improvement. The new type hints for $author_data are not entirely accurate as they don't reflect that the user_email property is optional. I've left specific suggestions to correct this. Additionally, I found a redundant PHPDoc block that should be removed to improve code clarity. Overall, good work on improving the codebase's quality.
|
|
||
| $author_data = array(); | ||
| /** | ||
| * @var array<object{user_email: string, user_login: string}> $author_data |
There was a problem hiding this comment.
The PHPDoc type for $author_data is not entirely correct. The property user_email is optional, as it's only set if isset( $wxr_author['author_email'] ) in the loop below. The current type object{user_email: string, user_login: string} suggests user_email is always present, which can mislead static analysis tools and developers. Please mark it as optional.
* @var array<object{user_login: string, user_email?: string}> $author_data| /** | ||
| * @var array<\WP_User> $author_data | ||
| * @var array<object{user_email: string, user_login: string}> $author_data | ||
| */ |
| * | ||
| * @param string $authors_arg The `--author` argument originally passed to command | ||
| * @param array<\WP_User> $author_data An array of WP_User-esque author objects | ||
| * @param array<\WP_User|object{user_email: string, user_login: string}> $author_data An array of WP_User-esque author objects |
There was a problem hiding this comment.
The type hint for the $author_data parameter is incorrect. The user_email property on the object shape is optional, but it's not marked as such. This can cause issues with static analysis. Please mark user_email as optional.
* @param array<\WP_User|object{user_login: string, user_email?: string}> $author_data An array of WP_User-esque author objects| * Creates users if they don't exist, and build an author mapping file. | ||
| * | ||
| * @param array<\WP_User> $author_data | ||
| * @param array<\WP_User|object{user_email: string, user_login: string}> $author_data |
There was a problem hiding this comment.
The type hint for the $author_data parameter is incorrect. The user_email property on the object shape is optional, but it's not marked as such. This is evident from the code within this function which checks isset( $author->user_email ). Please mark user_email as optional to reflect this.
* @param array<\WP_User|object{user_login: string, user_email?: string}> $author_data
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This pull request aims to fix PHPStan errors by updating array syntax from array() to [] and improving PHPDoc type annotations. The changes address static analysis issues detected by PHPStan level 9 configuration.
Changes:
- Converted several empty array initializations from
array()to[]syntax - Added and updated PHPDoc type annotations for
$author_datavariables to use object shape syntax - Updated method parameter and return type documentation to reflect actual types used in the code
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * | ||
| * @param string $authors_arg The `--author` argument originally passed to command | ||
| * @param array<\WP_User> $author_data An array of WP_User-esque author objects | ||
| * @param array<\WP_User|object{user_email: string, user_login: string}> $author_data An array of WP_User-esque author objects |
There was a problem hiding this comment.
The type annotation is incomplete and inconsistent with lines 131-133. The objects can have optional properties display_name, first_name, and last_name in addition to user_login and user_email. The type should be array<\WP_User|object{user_login: string, user_email?: string, display_name?: string, first_name?: string, last_name?: string}> to accurately reflect all possible properties.
| * @param array<\WP_User|object{user_email: string, user_login: string}> $author_data An array of WP_User-esque author objects | |
| * @param array<\WP_User|object{user_login: string, user_email?: string, display_name?: string, first_name?: string, last_name?: string}> $author_data An array of WP_User-esque author objects |
| * Creates users if they don't exist, and build an author mapping file. | ||
| * | ||
| * @param array<\WP_User> $author_data | ||
| * @param array<\WP_User|object{user_email: string, user_login: string}> $author_data |
There was a problem hiding this comment.
The type annotation is incomplete and inconsistent with lines 131-133. The objects can have optional properties display_name, first_name, and last_name in addition to user_login and user_email. The type should be array<\WP_User|object{user_login: string, user_email?: string, display_name?: string, first_name?: string, last_name?: string}> to accurately reflect all possible properties.
| * @param array<\WP_User|object{user_email: string, user_login: string}> $author_data | |
| * @param array<\WP_User|object{user_login: string, user_email?: string, display_name?: string, first_name?: string, last_name?: string}> $author_data |
| /** | ||
| * @var array<\WP_User> $author_data | ||
| * @var array<object{user_email: string, user_login: string}> $author_data | ||
| */ |
There was a problem hiding this comment.
This PHPDoc comment on lines 157-159 is redundant and adds no value. The variable $author_data already has the same type annotation on lines 131-133 just 23 lines above, and its type hasn't changed in between. This duplicate comment should be removed.
| $author_mapping[] = array( | ||
| 'old_user_login' => $author->user_login, |
There was a problem hiding this comment.
Inconsistent array syntax. Lines 416, 450, 460, 467, and 483 in the file all use array( for multi-line array initialization, while line 414 in this same method uses []. For consistency with the pattern established in this PR (converting array() to []), these should also be converted.
No description provided.