Fix PHPStan errors for Email editor PHP package unit test folder

MAILPOET-6318
This commit is contained in:
Oluwaseun Olorunsola
2024-11-22 15:36:51 +01:00
committed by Jan Lysý
parent bb71448c53
commit a4ad960492
9 changed files with 19 additions and 9 deletions

View File

@@ -16,7 +16,7 @@ interface Preprocessor {
* Method to preprocess the content before rendering
*
* @param array $parsed_blocks Parsed blocks of the email.
* @param array{contentSize: string, wideSize: string, allowEditing: bool, allowCustomContentAndWideSize: bool} $layout Layout of the email.
* @param array{contentSize: string, wideSize?: string, allowEditing?: bool, allowCustomContentAndWideSize?: bool} $layout Layout of the email.
* @param array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles Styles of the email.
* @return array
*/

View File

@@ -239,6 +239,6 @@ class Content_Renderer {
$styles = '<style>' . wp_strip_all_tags( (string) apply_filters( 'mailpoet_email_content_renderer_styles', $styles, $post ) ) . '</style>';
return CssInliner::fromHtml( $styles . $html )->inlineCss()->render(); // @phpstan-ignore-line TODO: Install CssInliner
return CssInliner::fromHtml( $styles . $html )->inlineCss()->render(); // TODO: Install CssInliner.
}
}

View File

@@ -65,7 +65,7 @@ class Process_Manager {
* Method to preprocess blocks
*
* @param array $parsed_blocks Parsed blocks.
* @param array{contentSize: string, wideSize: string, allowEditing: bool, allowCustomContentAndWideSize: bool} $layout Layout.
* @param array{contentSize: string, wideSize?: string, allowEditing?: bool, allowCustomContentAndWideSize?: bool} $layout Layout.
* @param array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles Styles.
* @return array
*/

View File

@@ -143,7 +143,7 @@ class Renderer {
* @return string
*/
private function inline_css_styles( $template ) {
return CssInliner::fromHtml( $template )->inlineCss()->render(); // @phpstan-ignore-line TODO: Install CssInliner
return CssInliner::fromHtml( $template )->inlineCss()->render(); // TODO: Install CssInliner.
}
/**
@@ -154,7 +154,7 @@ class Renderer {
*/
private function render_text_version( $template ) {
$template = ( mb_detect_encoding( $template, 'UTF-8', true ) ) ? $template : mb_convert_encoding( $template, 'UTF-8', mb_list_encodings() );
$result = Html2Text::convert( $template ); // @phpstan-ignore-line TODO: Install Html2Text
$result = Html2Text::convert( $template ); // TODO: Install Html2Text.
if ( false === $result ) {
return '';
}

View File

@@ -160,7 +160,7 @@ class Theme_Controller {
/**
* Get layout settings from the theme.
*
* @return array{contentSize: string, wideSize: string, allowEditing: bool, allowCustomContentAndWideSize: bool}
* @return array{contentSize: string, wideSize: string, allowEditing?: bool, allowCustomContentAndWideSize?: bool}
*/
public function get_layout_settings(): array {
return $this->get_theme()->get_settings()['layout'];

View File

@@ -43,7 +43,7 @@ class Container {
* Method for getting a registered service
*
* @template T
* @param class-string<T> $name The name of the service.
* @param string|class-string<T> $name The name of the service.
* @return T
* @throws \Exception If the service is not found.
*/

View File

@@ -31,8 +31,8 @@ $commands = array(
"$phpStanBin analyse ",
"-c $emailEditorCustomConfig ",
"$emailEditorPhpDir/src ",
// "$emailEditorPhpDir/tests/integration ", // TODO: will uncomment after fixing src errors
// "$emailEditorPhpDir/tests/unit ", // TODO: will uncomment after fixing tests/integration errors
// "$emailEditorPhpDir/tests/integration ", // TODO: will uncomment after fixing src errors
"$emailEditorPhpDir/tests/unit ",
);
$allCommands = implode( ' ', $commands );

View File

@@ -16,6 +16,7 @@ if ( ! function_exists( 'esc_attr' ) ) {
* Mock esc_attr function.
*
* @param string $attr Attribute to escape.
* @return string
*/
function esc_attr( $attr ) {
return $attr;
@@ -27,6 +28,7 @@ if ( ! function_exists( 'esc_html' ) ) {
* Mock esc_html function.
*
* @param string $text Text to escape.
* @return string
*/
function esc_html( $text ) {
return $text;