diff --git a/tasks/phpstan/bootstrap.php b/tasks/phpstan/bootstrap.php index 8e99a40a30..9e09aa8ed4 100644 --- a/tasks/phpstan/bootstrap.php +++ b/tasks/phpstan/bootstrap.php @@ -1,21 +1,11 @@ defineTables(); MailPoet\Config\Env::$dbPrefix = 'wp_'; // Classes needed in runtime -MailPoet\Mailer\WordPress\PHPMailerLoader::load(); -require_once(ABSPATH . 'wp-includes/class-wp-widget.php'); // We extend this class it is need in runtime +class_alias(\PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer'); +class_alias(\PHPMailer\PHPMailer\Exception::class, 'phpmailerException'); // Load tracy $tracyPath = __DIR__ . '/../../tools/vendor/tracy.phar'; require_once($tracyPath); diff --git a/tasks/phpstan/phpstan-baseline-integration-tests.neon b/tasks/phpstan/phpstan-baseline-integration-tests.neon index d6b9aada72..6d3f480c45 100644 --- a/tasks/phpstan/phpstan-baseline-integration-tests.neon +++ b/tasks/phpstan/phpstan-baseline-integration-tests.neon @@ -291,7 +291,7 @@ parameters: path: ../../tests/integration/Cron/Workers/SendingQueue/Tasks/PostsTest.php - - message: "#^Cannot access property \\$post_title on array\\|WP_Post\\|null\\.$#" + message: "#^Cannot access property \\$post_title on WP_Post\\|null\\.$#" count: 1 path: ../../tests/integration/Cron/Workers/SendingQueue/Tasks/ShortcodesTest.php @@ -595,7 +595,7 @@ parameters: path: ../../tests/integration/Newsletter/Scheduler/PostNotificationTest.php - - message: "#^Cannot access property \\$post_title on array\\|WP_Post\\|null\\.$#" + message: "#^Cannot access property \\$post_title on WP_Post\\|null\\.$#" count: 1 path: ../../tests/integration/Newsletter/ShortcodesTest.php diff --git a/tasks/phpstan/phpstan-tests.neon b/tasks/phpstan/phpstan-tests.neon index df22984957..055cda4a28 100644 --- a/tasks/phpstan/phpstan-tests.neon +++ b/tasks/phpstan/phpstan-tests.neon @@ -19,8 +19,6 @@ parameters: - PremiumContainerConfigurator.php - woocommerce.php - function-stubs.php - dynamicConstantNames: - - WP_DEBUG ignoreErrors: - '/Parameter #1 \$cssOrXPath of method AcceptanceTester::moveMouseOver\(\) expects string\|null, array given./' - '/Function expect invoked with 1 parameter, 0 required\./' @@ -37,9 +35,9 @@ parameters: checkMissingTypehints: false includes: - - _phpstan-wp-source.neon # Config file that adds paths to WP source code. Generated from phpstan-wp-source.neon by Robo - vendor/phpstan/phpstan-doctrine/extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/szepeviktor/phpstan-wordpress/extension.neon - extensions/CodeceptionExtension/extension.neon - phpstan-baseline-unit-tests.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff - phpstan-baseline-integration-tests.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff diff --git a/tasks/phpstan/phpstan.neon b/tasks/phpstan/phpstan.neon index b0f2d43f42..7265f51202 100644 --- a/tasks/phpstan/phpstan.neon +++ b/tasks/phpstan/phpstan.neon @@ -22,7 +22,6 @@ parameters: count: 2 reportUnmatchedIgnoredErrors: true dynamicConstantNames: - - WP_DEBUG - MAILPOET_PREMIUM_INITIALIZED doctrine: objectManagerLoader: create-entity-manager.php @@ -37,8 +36,8 @@ parameters: excludes_analyse: - ../../lib/Config/PopulatorData/Templates includes: - - _phpstan-wp-source.neon # Config file that adds paths to WP source code. Generated from phpstan-wp-source.neon by Robo - vendor/phpstan/phpstan-doctrine/extension.neon - vendor/phpstan/phpstan-doctrine/rules.neon + - vendor/szepeviktor/phpstan-wordpress/extension.neon - phpstan-baseline.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff - php-version-dependent-config-libs.php # PHP version detection + configuraton dependent on PHP version