Fix PHPStan errors for Email editor PHP package unit test folder
MAILPOET-6318
This commit is contained in:
committed by
Jan Lysý
parent
bb71448c53
commit
a4ad960492
@@ -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
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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.
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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 '';
|
||||
}
|
||||
|
@@ -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'];
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
@@ -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 );
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user