Skip to content

Conversation

@swissspidy
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

❌ Patch coverage is 95.45455% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/WP_Export_WXR_Formatter.php 90.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy requested a review from Copilot November 3, 2025 08:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds PHPStan static analysis support at level 9 to the codebase. The changes focus on adding comprehensive type hints via PHPDoc annotations to enable strict type checking.

  • Adds PHPDoc type annotations for class properties and method parameters across multiple classes
  • Introduces #[\ReturnTypeWillChange] attributes to Iterator interface methods for PHP 8.x compatibility
  • Fixes a bug where an undefined property was being assigned in WP_Export_Returner

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
phpstan.neon.dist Adds PHPStan configuration file with level 9 analysis and selected error suppressions
src/WP_Post_IDs_Iterator.php Adds type annotations for all properties and an @implements tag for the Iterator interface
src/WP_Map_Iterator.php Adds type annotations for the callback property and constructor parameters
src/WP_Export_XML_Over_HTTP.php Adds type annotations for private properties and constructor parameters
src/WP_Export_WXR_Formatter.php Adds type annotations for properties and the before_posts method parameter
src/WP_Export_Returner.php Removes assignment to undefined property $this->private
src/Export_Command.php Adds PHPDoc blocks with type annotations and @phpstan-ignore directives for validation methods, plus adds type cast for getcwd()
functions.php Adds type annotations for the wp_export() function's parameter and restructures formatting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

swissspidy and others added 2 commits November 3, 2025 10:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy
Copy link
Member Author

@copilot Help me bring this over the finish line. These are the current PHPStan errors left:

 ------ ----------------------------------------------------------------------- 
  Line   src/Export_Command.php                                                 
 ------ ----------------------------------------------------------------------- 
  184    Call to deprecated function WP_CLI\Utils\wp_clear_object_cache():      
         1.5.0                                                                  
  191    Parameter #1 $args of function wp_export expects array{filters?:       
         array, format?: class-string<WP_Export_WXR_Formatter>, writer?:        
         class-string<WP_Export_Returner>, writer_args?: mixed},                
         array{filters: non-empty-array, writer: 'WP_Export_File…',             
         writer_args: 'php://output'} given.                                    
         💡 Offset 'writer' (class-string<WP_Export_Returner>) does not         
            accept type string.                                                 
  199    Parameter #1 $args of function wp_export expects array{filters?:       
         array, format?: class-string<WP_Export_WXR_Formatter>, writer?:        
         class-string<WP_Export_Returner>, writer_args?: mixed},                
         array{filters: non-empty-array, writer: 'WP_Export_Split…',            
         writer_args: array{max_file_size: mixed, destination_directory:        
         mixed, filename_template: mixed, include_once: mixed}} given.          
         💡 Offset 'writer' (class-string<WP_Export_Returner>) does not         
            accept type string.                                                 
  237    Parameter #1 $callback of function call_user_func expects callable():  
         mixed, array{$this(Export_Command), non-falsy-string} given.           
  288    Parameter #2 $timestamp of function date expects int|null, int|false   
         given.                                                                 
  307    Parameter #2 $timestamp of function date expects int|null, int|false   
         given.                                                                 
  423    Call to deprecated function get_users_of_blog():                       
         3.1.0 Use get_users()                                                  
  424    is_wp_error(array) will always evaluate to false.                      
  450    Method Export_Command::check_max_num_posts() is unused.                
  476    is_wp_error(string) will always evaluate to false.                     
  495    is_wp_error(array<string, string>) will always evaluate to false.      
 ------ ----------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------- 
  Line   src/WP_Export_Oxymel.php                                               
 ------ ----------------------------------------------------------------------- 
  13     Expression "$this->{$tag_name}->contains->cdata($contents)->end" on a  
         separate line does not do anything.                                    
 ------ ----------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------- 
  Line   src/WP_Export_Query.php                                               
 ------ ---------------------------------------------------------------------- 
  125    Parameter #1 $args of function get_terms expects array{taxonomy?:     
         array<string>|string, object_ids?: array<int>|int, orderby?: string,  
         order?: string, hide_empty?: bool|int, include?: array<int>|string,   
         exclude?: array<int>|string, exclude_tree?: array<int>|string, ...},  
         array<string, string> given.                                          
  326    Parameter #2 $value of function get_user_by expects int|string,       
         float|int|string given.                                               
         $comment->comment_parent)->tag('wp:comment_user_id',                                                                                                                                                                                                          
         $comment->user_id)->oxymel($this->comment_meta($comment))->end" on a                                                                                                                                                                                          
         separate line does not do anything.                                                                                                                                                                                                                           
  247    Access to an undefined property WP_Export_Oxymel::$end.                                                                                                                                                                                                       
         💡 Learn more:                                                                                                                                                                                                                                                
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                                                                                                                                                                      
  247    Expression "$oxymel->end" on a separate line does not do anything.                                                                                                                                                                                            
  254    Access to an undefined property Oxymel::$close_channel.                                                                                                                                                                                                       
         💡 Learn more:                                                                                                                                                                                                                                                
            https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                                                                                                                                                                                      
  269    Expression "$oxymel->optional_cdata('wp:term_name',                                                                                                                                                                                                           
         $term->name)->optional_cdata('wp:term_description',                                                                                                                                                                                                           
         $term->description)->end" on a separate line does not do anything.                                                                                                                                                                                            
  285    Expression                                                                                                                                                                                                                                                    
         "$oxymel->tag('wp:commentmeta')->contains->tag('wp:meta_key',                                                                                                                                                                                                 
         $meta->meta_key)->tag('wp:meta_value')->contains->cdata($meta->meta_value)->end->end"                                                                                                                                                                         
         on a separate line does not do anything.                                                                                                                                                                                                                      
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------- 
  Line   src/WP_Map_Iterator.php                                                
 ------ ----------------------------------------------------------------------- 
  3      Class WP_Map_Iterator extends generic class IteratorIterator but does  
         not specify its types: TKey, TValue, TIterator                         
 ------ ----------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------ 
  Line   src/WP_Post_IDs_Iterator.php                                      
 ------ ------------------------------------------------------------------ 
  94     Property WP_Post_IDs_Iterator::$results (array<object>) does not  
         accept array<int, stdClass>|null.                                 

Copilot AI mentioned this pull request Nov 4, 2025
16 tasks
Copy link

Copilot AI commented Nov 4, 2025

@swissspidy I've opened a new pull request, #126, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 7 commits November 4, 2025 14:36
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants