Update PHPStan and fix new issues

[MAILPOET-4175]
This commit is contained in:
Rostislav Wolny
2022-03-23 16:04:34 +01:00
committed by Veljko V
parent f4f2af0f40
commit 095f85c897
5 changed files with 21 additions and 42 deletions

View File

@@ -71,7 +71,7 @@ class CronWorkerRunner {
$this->processTask($worker, $task); $this->processTask($worker, $task);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
if ($task && $e->getCode() !== CronHelper::DAEMON_EXECUTION_LIMIT_REACHED) { if (isset($task) && $task && $e->getCode() !== CronHelper::DAEMON_EXECUTION_LIMIT_REACHED) {
$this->cronWorkerScheduler->rescheduleProgressively($task); $this->cronWorkerScheduler->rescheduleProgressively($task);
} }
throw $e; throw $e;

View File

@@ -1,10 +1,10 @@
{ {
"require": { "require": {
"php-stubs/woocommerce-stubs": "^6.0", "php-stubs/woocommerce-stubs": "^6.0",
"phpstan/phpstan": "1.4.8", "phpstan/phpstan": "1.4.10",
"phpstan/phpstan-doctrine": "1.2.11", "phpstan/phpstan-doctrine": "1.2.11",
"phpstan/phpstan-phpunit": "1.0.0", "phpstan/phpstan-phpunit": "1.0.0",
"szepeviktor/phpstan-wordpress": "1.0.2" "szepeviktor/phpstan-wordpress": "1.0.3"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "6298983b6de60bbf967cde283553c278", "content-hash": "ff830b6e9cbe937699c148d8d53b907b",
"packages": [ "packages": [
{ {
"name": "php-stubs/woocommerce-stubs", "name": "php-stubs/woocommerce-stubs",
@@ -99,16 +99,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.4.8", "version": "1.4.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "2a6d6704b17c4db6190cc3104056c0aad740cb15" "reference": "898c479c39caa727bedf4311dd294a8f4e250e72"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/2a6d6704b17c4db6190cc3104056c0aad740cb15", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/898c479c39caa727bedf4311dd294a8f4e250e72",
"reference": "2a6d6704b17c4db6190cc3104056c0aad740cb15", "reference": "898c479c39caa727bedf4311dd294a8f4e250e72",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -122,11 +122,6 @@
"phpstan.phar" "phpstan.phar"
], ],
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": { "autoload": {
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
@@ -139,7 +134,7 @@
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan/issues", "issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.4.8" "source": "https://github.com/phpstan/phpstan/tree/1.4.10"
}, },
"funding": [ "funding": [
{ {
@@ -159,7 +154,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-03-04T13:03:56+00:00" "time": "2022-03-14T10:25:45+00:00"
}, },
{ {
"name": "phpstan/phpstan-doctrine", "name": "phpstan/phpstan-doctrine",
@@ -289,7 +284,7 @@
}, },
{ {
"name": "symfony/polyfill-php73", "name": "symfony/polyfill-php73",
"version": "v1.24.0", "version": "v1.25.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php73.git", "url": "https://github.com/symfony/polyfill-php73.git",
@@ -348,7 +343,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0"
}, },
"funding": [ "funding": [
{ {
@@ -368,16 +363,16 @@
}, },
{ {
"name": "szepeviktor/phpstan-wordpress", "name": "szepeviktor/phpstan-wordpress",
"version": "v1.0.2", "version": "v1.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/szepeviktor/phpstan-wordpress.git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git",
"reference": "d44b5abcaa529698e138b2d21bc2a7cf9834039c" "reference": "265d06b4673572fa379567d2b99df7794c0ab27a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/d44b5abcaa529698e138b2d21bc2a7cf9834039c", "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/265d06b4673572fa379567d2b99df7794c0ab27a",
"reference": "d44b5abcaa529698e138b2d21bc2a7cf9834039c", "reference": "265d06b4673572fa379567d2b99df7794c0ab27a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -387,7 +382,7 @@
"symfony/polyfill-php73": "^1.12.0" "symfony/polyfill-php73": "^1.12.0"
}, },
"require-dev": { "require-dev": {
"composer/composer": "^1.10.23", "composer/composer": "^2.1.12",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7", "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-parallel-lint/php-parallel-lint": "^1.1", "php-parallel-lint/php-parallel-lint": "^1.1",
"phpstan/phpstan-strict-rules": "^1.0", "phpstan/phpstan-strict-rules": "^1.0",
@@ -421,7 +416,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues",
"source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.0.2" "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.0.3"
}, },
"funding": [ "funding": [
{ {
@@ -429,7 +424,7 @@
"type": "custom" "type": "custom"
} }
], ],
"time": "2021-11-19T12:47:11+00:00" "time": "2022-03-05T07:34:50+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
@@ -440,5 +435,5 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.1.0" "plugin-api-version": "2.2.0"
} }

View File

@@ -19,7 +19,6 @@ use MailPoet\Newsletter\Renderer\Preprocessor;
use MailPoet\Newsletter\Renderer\Renderer; use MailPoet\Newsletter\Renderer\Renderer;
use MailPoet\Util\pQuery\pQuery; use MailPoet\Util\pQuery\pQuery;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use WP_Error;
class RendererTest extends \MailPoetTest { class RendererTest extends \MailPoetTest {
public $dOMParser; public $dOMParser;
@@ -634,9 +633,6 @@ class RendererTest extends \MailPoetTest {
'post_status' => 'publish', 'post_status' => 'publish',
] ]
); );
if ($postId instanceof WP_Error) {
$this->fail('Error preparing data for test: failed to create post.');
}
$filename = dirname(__DIR__) . '/../../tests/_data/600x400.jpg'; $filename = dirname(__DIR__) . '/../../tests/_data/600x400.jpg';
$contents = file_get_contents($filename); $contents = file_get_contents($filename);
@@ -646,9 +642,6 @@ class RendererTest extends \MailPoetTest {
$upload = wp_upload_bits(basename($filename), null, $contents); $upload = wp_upload_bits(basename($filename), null, $contents);
$attachmentId = $this->makeAttachment($upload); $attachmentId = $this->makeAttachment($upload);
if ($attachmentId instanceof WP_Error) {
$this->fail('Error preparing data for test: failed to create attachment.');
}
set_post_thumbnail($postId, $attachmentId); set_post_thumbnail($postId, $attachmentId);
$this->newsletter->setBody(json_decode( $this->newsletter->setBody(json_decode(
@@ -684,9 +677,6 @@ class RendererTest extends \MailPoetTest {
]; ];
$id = wp_insert_attachment($attachment, $upload['file'], $parentPostId); $id = wp_insert_attachment($attachment, $upload['file'], $parentPostId);
if ($id instanceof WP_Error) {
return $id;
}
$metadata = wp_generate_attachment_metadata($id, $upload['file']); $metadata = wp_generate_attachment_metadata($id, $upload['file']);
wp_update_attachment_metadata($id, $metadata); wp_update_attachment_metadata($id, $metadata);

View File

@@ -152,14 +152,11 @@ class WooCommerceSubscriptionTest extends \MailPoetTest {
'post_title' => $name, 'post_title' => $name,
]; ];
$productId = wp_insert_post($productData); $productId = wp_insert_post($productData);
if (is_wp_error($productId)) {
throw new \RuntimeException("Could not create product '$name': " . $productId->get_error_message());
}
$this->products[] = (int)$productId; $this->products[] = (int)$productId;
return (int)$productId; return (int)$productId;
} }
private function createSubscription(array $args, int $user, int ...$productIds): ?int { private function createSubscription(array $args, int $user, int ...$productIds): int {
global $wpdb; global $wpdb;
$defaults = [ $defaults = [
'post_status' => 'wc-active', 'post_status' => 'wc-active',
@@ -169,9 +166,6 @@ class WooCommerceSubscriptionTest extends \MailPoetTest {
$args = wp_parse_args($args, $defaults); $args = wp_parse_args($args, $defaults);
$orderId = wp_insert_post($args); $orderId = wp_insert_post($args);
if (is_wp_error($orderId)) {
return null;
}
$orderId = (int)$orderId; $orderId = (int)$orderId;
update_post_meta( $orderId, '_customer_user', $user ); update_post_meta( $orderId, '_customer_user', $user );