Skip to content

Add initial PHPStan config#486

Draft
swissspidy wants to merge 15 commits intomainfrom
fix/phpstan
Draft

Add initial PHPStan config#486
swissspidy wants to merge 15 commits intomainfrom
fix/phpstan

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@github-actions github-actions bot added the scope:testing Related to testing label Apr 2, 2026
@github-actions

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Copy link
Copy Markdown

@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 introduces PHPStan for static analysis, adding a configuration file, stubs, and comprehensive PHPDoc type hints throughout the project. It also migrates path-related utility calls to the "WP_CLI\Path" class and refactors type checks to use "instanceof". Key feedback points include the potential for compilation errors due to the removal of Blade component tag handling in "BladeGettextExtractor" and the breaking of inheritance and backward compatibility caused by renaming "multilineQuote" in "PotGenerator".

$blade_compiler->withoutComponentTags();
}

return $blade_compiler;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The removal of the withoutComponentTags() call might lead to compilation errors when BladeOne encounters Blade component tags (<x-...>). Since these tags are manually handled later in the extraction process, disabling their compilation in the main engine is important to prevent the compiler from failing on unresolved components in a non-Laravel environment.

		if ( method_exists( $blade_compiler, 'withoutComponentTags' ) ) {
			$blade_compiler->withoutComponentTags();
		}

		return $blade_compiler;

* @return string[]
*/
protected static function multilineQuote( $text ) {
protected static function wpMultilineQuote( $text ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Renaming multilineQuote to wpMultilineQuote breaks the override of the parent PoGenerator::multilineQuote method. This means any other methods in the parent class that use late static binding to call multilineQuote will no longer use the WP-specific implementation. It also breaks backward compatibility for any third-party code extending this class.

	protected static function multilineQuote( $text ) {

*/
protected static function addLines( array &$lines, $name, $value ) {
$newlines = self::multilineQuote( $value );
$newlines = self::wpMultilineQuote( $value );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This call should be updated to use the original method name and prefer static:: to allow for late static binding, consistent with how the parent PoGenerator class handles this method.

		$newlines = static::multilineQuote( $value );
References
  1. In PHP, prefer static:: over self:: for static access to allow consuming classes to override them via late static binding.

@swissspidy swissspidy added this to the 2.7.2 milestone Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant