diff --git a/mailpoet/tasks/phpstan/email-editor-phpstan.neon b/mailpoet/tasks/phpstan/email-editor-phpstan.neon index 8320ad8837..23e42d178d 100644 --- a/mailpoet/tasks/phpstan/email-editor-phpstan.neon +++ b/mailpoet/tasks/phpstan/email-editor-phpstan.neon @@ -2,12 +2,19 @@ parameters: level: 9 tmpDir: ../../temp/phpstan bootstrapFiles: + - ../../vendor/autoload.php - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php + - ../../vendor/codeception/codeception/autoload.php + - ../../vendor/codeception/verify/src/Codeception/Verify/Verify.php + inferPrivatePropertyTypeFromConstructor: true checkGenericClassInNonGenericObjectType: false parallel: processTimeout: 300.0 maximumNumberOfProcesses: 3 # Static analysis is running on Circle CI medium+ that has 3 CPUs + ignoreErrors: + - '#_before\(\) has no return type specified#' # skip integration test before errors + - '#Container::get\(\) is not referenced in a parameter.#' reportUnmatchedIgnoredErrors: true dynamicConstantNames: - MAILPOET_PREMIUM_INITIALIZED @@ -19,6 +26,7 @@ parameters: excludePaths: analyseAndScan: - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php # does not yet offer support for PHP 8.1 + - ../../../packages/php/email-editor/tests/unit/_stubs.php includes: - extensions/CodeceptionExtension/extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/interface-preprocessor.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/interface-preprocessor.php index fdddb4c338..d621a03329 100644 --- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/interface-preprocessor.php +++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/interface-preprocessor.php @@ -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 */ diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-content-renderer.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-content-renderer.php index 41636c6d95..ae7b4f58fb 100644 --- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-content-renderer.php +++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-content-renderer.php @@ -239,6 +239,6 @@ class Content_Renderer { $styles = ''; - return CssInliner::fromHtml( $styles . $html )->inlineCss()->render(); // @phpstan-ignore-line TODO: Install CssInliner + return CssInliner::fromHtml( $styles . $html )->inlineCss()->render(); // TODO: Install CssInliner. } } diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-process-manager.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-process-manager.php index ab4fa83715..2a4ff7e4fe 100644 --- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-process-manager.php +++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/class-process-manager.php @@ -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 */ diff --git a/packages/php/email-editor/src/Engine/Renderer/class-renderer.php b/packages/php/email-editor/src/Engine/Renderer/class-renderer.php index 95f4e7798b..689da1e435 100644 --- a/packages/php/email-editor/src/Engine/Renderer/class-renderer.php +++ b/packages/php/email-editor/src/Engine/Renderer/class-renderer.php @@ -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 ''; } diff --git a/packages/php/email-editor/src/Engine/class-theme-controller.php b/packages/php/email-editor/src/Engine/class-theme-controller.php index 692583dff2..298e333504 100644 --- a/packages/php/email-editor/src/Engine/class-theme-controller.php +++ b/packages/php/email-editor/src/Engine/class-theme-controller.php @@ -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']; diff --git a/packages/php/email-editor/src/class-container.php b/packages/php/email-editor/src/class-container.php index 444488156f..31b7ceea30 100644 --- a/packages/php/email-editor/src/class-container.php +++ b/packages/php/email-editor/src/class-container.php @@ -43,7 +43,7 @@ class Container { * Method for getting a registered service * * @template T - * @param class-string $name The name of the service. + * @param string|class-string $name The name of the service. * @return T * @throws \Exception If the service is not found. */ diff --git a/packages/php/email-editor/tasks/run-phpstan.php b/packages/php/email-editor/tasks/run-phpstan.php index a879bcef45..52732482aa 100644 --- a/packages/php/email-editor/tasks/run-phpstan.php +++ b/packages/php/email-editor/tasks/run-phpstan.php @@ -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 ); diff --git a/packages/php/email-editor/tests/unit/_bootstrap.php b/packages/php/email-editor/tests/unit/_bootstrap.php index 5dbb1e123b..810e308a09 100644 --- a/packages/php/email-editor/tests/unit/_bootstrap.php +++ b/packages/php/email-editor/tests/unit/_bootstrap.php @@ -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;