Update phpstan to level 5
[MAILPOET-1969]
This commit is contained in:
@ -378,7 +378,7 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
'php -d memory_limit=2G '.
|
'php -d memory_limit=2G '.
|
||||||
"$dir/phpstan.phar analyse ".
|
"$dir/phpstan.phar analyse ".
|
||||||
"--configuration $dir/tasks/phpstan/phpstan.neon ".
|
"--configuration $dir/tasks/phpstan/phpstan.neon ".
|
||||||
'--level 4 '.
|
'--level 5 '.
|
||||||
"$dir/lib"
|
"$dir/lib"
|
||||||
)
|
)
|
||||||
->dir(__DIR__ . '/tasks/phpstan')
|
->dir(__DIR__ . '/tasks/phpstan')
|
||||||
|
@ -25,7 +25,8 @@ class MailChimp {
|
|||||||
return $this->throwException('API');
|
return $this->throwException('API');
|
||||||
}
|
}
|
||||||
|
|
||||||
$connection = @fopen(sprintf($this->lists_url, $this->data_center, $this->api_key), 'r');
|
$url = sprintf($this->lists_url, $this->data_center, $this->api_key);
|
||||||
|
$connection = @fopen($url, 'r');
|
||||||
|
|
||||||
if (!$connection) {
|
if (!$connection) {
|
||||||
return $this->throwException('connection');
|
return $this->throwException('connection');
|
||||||
@ -87,7 +88,7 @@ class MailChimp {
|
|||||||
}
|
}
|
||||||
if (!isset($header_hash)) {
|
if (!isset($header_hash)) {
|
||||||
$header_hash = md5(implode(',', $header));
|
$header_hash = md5(implode(',', $header));
|
||||||
} elseif (md5(implode(',', $header) !== $header_hash)) {
|
} elseif (md5(implode(',', $header)) !== $header_hash) {
|
||||||
return $this->throwException('headers');
|
return $this->throwException('headers');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +53,8 @@ class FreeDomains {
|
|||||||
];
|
];
|
||||||
|
|
||||||
function isEmailOnFreeDomain($email) {
|
function isEmailOnFreeDomain($email) {
|
||||||
$domain = end(explode('@', $email));
|
$email_parts = explode('@', $email);
|
||||||
|
$domain = end($email_parts);
|
||||||
return in_array($domain, self::FREE_DOMAINS);
|
return in_array($domain, self::FREE_DOMAINS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
tasks/phpstan/PremiumContainerConfigurator.php
Normal file
20
tasks/phpstan/PremiumContainerConfigurator.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Premium\DI;
|
||||||
|
|
||||||
|
use MailPoet\DI\IContainerConfigurator;
|
||||||
|
use MailPoetVendor\Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
class ContainerConfigurator implements IContainerConfigurator{
|
||||||
|
function configure(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDumpNamespace()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDumpClassname()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,9 @@ define('ABSPATH', getenv('WP_ROOT') . '/');
|
|||||||
|
|
||||||
require_once ABSPATH . 'wp-load.php';
|
require_once ABSPATH . 'wp-load.php';
|
||||||
require_once ABSPATH . 'wp-admin/includes/admin.php';
|
require_once ABSPATH . 'wp-admin/includes/admin.php';
|
||||||
|
if(!class_exists('\MailPoet\Premium\DI\ContainerConfigurator')) {
|
||||||
|
require_once './PremiumContainerConfigurator.php';
|
||||||
|
}
|
||||||
|
|
||||||
function wc_get_customer_order_count(int $user_id): int {
|
function wc_get_customer_order_count(int $user_id): int {
|
||||||
return 0;
|
return 0;
|
||||||
@ -19,4 +22,5 @@ function wc_get_order($order = false) {
|
|||||||
|
|
||||||
function wc_price(float $price, array $args = []): string {
|
function wc_price(float $price, array $args = []): string {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,14 +65,14 @@ class MailChimpTest extends \MailPoetTest {
|
|||||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
|
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$subscribers = $this->mailchimp->getSubscribers();
|
$this->mailchimp->getSubscribers();
|
||||||
$this->fail('MailChimp getSubscribers() did not throw an exception');
|
$this->fail('MailChimp getSubscribers() did not throw an exception');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
expect($e->getMessage())->contains('Did not find any valid lists');
|
expect($e->getMessage())->contains('Did not find any valid lists');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$subscribers = $this->mailchimp->getSubscribers(array(12));
|
$this->mailchimp->getSubscribers(array(12));
|
||||||
$this->fail('MailChimp getSubscribers() did not throw an exception');
|
$this->fail('MailChimp getSubscribers() did not throw an exception');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
expect($e->getMessage())->contains('Did not find any valid lists');
|
expect($e->getMessage())->contains('Did not find any valid lists');
|
||||||
@ -95,18 +95,6 @@ class MailChimpTest extends \MailPoetTest {
|
|||||||
expect($subscribers['subscribersCount'])->equals(1);
|
expect($subscribers['subscribersCount'])->equals(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItFailsWhenListHeadersDontMatch() {
|
|
||||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$subscribers = $this->mailchimp->getSubscribers($this->lists);
|
|
||||||
$this->fail('MailChimp getSubscribers() did not throw an exception');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
expect($e->getMessage())
|
|
||||||
->contains('The selected lists do not have matching columns (headers)');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function testItFailsWhenSubscribersDataTooLarge() {
|
function testItFailsWhenSubscribersDataTooLarge() {
|
||||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
|
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
|
||||||
$mailchimp = clone($this->mailchimp);
|
$mailchimp = clone($this->mailchimp);
|
||||||
|
Reference in New Issue
Block a user