Adjust PHP stan configs to use wordpress extension

[MAILPOET-2837]
This commit is contained in:
Rostislav Wolny
2020-12-29 18:00:27 +01:00
committed by Veljko V
parent 332dd6ea58
commit 0bc0dd1808
4 changed files with 6 additions and 19 deletions

View File

@@ -1,21 +1,11 @@
<?php <?php
// Constants // Constants
define('ABSPATH', getenv('WP_ROOT') . '/');
define('WPINC', 'wp-includes'); define('WPINC', 'wp-includes');
define('WP_DEBUG', false);
define('WP_LANG_DIR', 'wp-content/languages'); define('WP_LANG_DIR', 'wp-content/languages');
define('WP_PLUGIN_DIR', 'wp-content/plugins'); define('WP_PLUGIN_DIR', 'wp-content/plugins');
define('WP_MEMORY_LIMIT', 268435456); define('WP_MEMORY_LIMIT', 268435456);
define('WP_MAX_MEMORY_LIMIT', 268435456); define('WP_MAX_MEMORY_LIMIT', 268435456);
define('ARRAY_A', 'ARRAY_A');
define('OBJECT', 'OBJECT');
define('MINUTE_IN_SECONDS', 60);
define('HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS);
define('DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS);
define('WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS);
define('MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS);
define('YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS);
define('MAILPOET_VERSION', '1.0.0'); define('MAILPOET_VERSION', '1.0.0');
define('DB_HOST', 'localhost'); define('DB_HOST', 'localhost');
define('DB_NAME', 'wordpress'); define('DB_NAME', 'wordpress');
@@ -30,8 +20,8 @@ $dbConfig->defineTables();
MailPoet\Config\Env::$dbPrefix = 'wp_'; MailPoet\Config\Env::$dbPrefix = 'wp_';
// Classes needed in runtime // Classes needed in runtime
MailPoet\Mailer\WordPress\PHPMailerLoader::load(); class_alias(\PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer');
require_once(ABSPATH . 'wp-includes/class-wp-widget.php'); // We extend this class it is need in runtime class_alias(\PHPMailer\PHPMailer\Exception::class, 'phpmailerException');
// Load tracy // Load tracy
$tracyPath = __DIR__ . '/../../tools/vendor/tracy.phar'; $tracyPath = __DIR__ . '/../../tools/vendor/tracy.phar';
require_once($tracyPath); require_once($tracyPath);

View File

@@ -291,7 +291,7 @@ parameters:
path: ../../tests/integration/Cron/Workers/SendingQueue/Tasks/PostsTest.php 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 count: 1
path: ../../tests/integration/Cron/Workers/SendingQueue/Tasks/ShortcodesTest.php path: ../../tests/integration/Cron/Workers/SendingQueue/Tasks/ShortcodesTest.php
@@ -595,7 +595,7 @@ parameters:
path: ../../tests/integration/Newsletter/Scheduler/PostNotificationTest.php 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 count: 1
path: ../../tests/integration/Newsletter/ShortcodesTest.php path: ../../tests/integration/Newsletter/ShortcodesTest.php

View File

@@ -19,8 +19,6 @@ parameters:
- PremiumContainerConfigurator.php - PremiumContainerConfigurator.php
- woocommerce.php - woocommerce.php
- function-stubs.php - function-stubs.php
dynamicConstantNames:
- WP_DEBUG
ignoreErrors: ignoreErrors:
- '/Parameter #1 \$cssOrXPath of method AcceptanceTester::moveMouseOver\(\) expects string\|null, array<string, string> given./' - '/Parameter #1 \$cssOrXPath of method AcceptanceTester::moveMouseOver\(\) expects string\|null, array<string, string> given./'
- '/Function expect invoked with 1 parameter, 0 required\./' - '/Function expect invoked with 1 parameter, 0 required\./'
@@ -37,9 +35,9 @@ parameters:
checkMissingTypehints: false checkMissingTypehints: false
includes: 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/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/szepeviktor/phpstan-wordpress/extension.neon
- extensions/CodeceptionExtension/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-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 - phpstan-baseline-integration-tests.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff

View File

@@ -22,7 +22,6 @@ parameters:
count: 2 count: 2
reportUnmatchedIgnoredErrors: true reportUnmatchedIgnoredErrors: true
dynamicConstantNames: dynamicConstantNames:
- WP_DEBUG
- MAILPOET_PREMIUM_INITIALIZED - MAILPOET_PREMIUM_INITIALIZED
doctrine: doctrine:
objectManagerLoader: create-entity-manager.php objectManagerLoader: create-entity-manager.php
@@ -37,8 +36,8 @@ parameters:
excludes_analyse: excludes_analyse:
- ../../lib/Config/PopulatorData/Templates - ../../lib/Config/PopulatorData/Templates
includes: 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/extension.neon
- vendor/phpstan/phpstan-doctrine/rules.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 - 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 - php-version-dependent-config-libs.php # PHP version detection + configuraton dependent on PHP version