diff --git a/lib/AdminPages/Pages/Forms.php b/lib/AdminPages/Pages/Forms.php index 19a9966810..c2a653c649 100644 --- a/lib/AdminPages/Pages/Forms.php +++ b/lib/AdminPages/Pages/Forms.php @@ -65,7 +65,7 @@ class Forms { $data['premium_plugin_active'] = License::getLicense(); $data['current_wp_user_firstname'] = $this->wp->wpGetCurrentUser()->user_firstname; $installedAtDiff = (new \DateTime($this->settings->get('installed_at')))->diff(new \DateTime()); - $data['installed_days_ago'] = $installedAtDiff instanceof \DateInterval ? (int)$installedAtDiff->format('%a') : null; + $data['installed_days_ago'] = (int)$installedAtDiff->format('%a'); $data['display_nps_survey'] = true; $this->userFlags->set('display_new_form_editor_nps_survey', false); } diff --git a/lib/AdminPages/Pages/Newsletters.php b/lib/AdminPages/Pages/Newsletters.php index 76fd0c0c86..5ac92f9284 100644 --- a/lib/AdminPages/Pages/Newsletters.php +++ b/lib/AdminPages/Pages/Newsletters.php @@ -134,7 +134,7 @@ class Newsletters { $data['roles']['mailpoet_all'] = $this->wp->__('In any WordPress role', 'mailpoet'); $installedAtDiff = (new \DateTime($this->settings->get('installed_at')))->diff(new \DateTime()); - $data['installed_days_ago'] = $installedAtDiff instanceof \DateInterval ? (int)$installedAtDiff->format('%a') : null; + $data['installed_days_ago'] = (int)$installedAtDiff->format('%a'); $data['subscribers_limit'] = $this->subscribersFeature->getSubscribersLimit(); $data['subscribers_limit_reached'] = $this->subscribersFeature->check(); diff --git a/lib/Doctrine/Driver/PDOConnection.php b/lib/Doctrine/Driver/PDOConnection.php index 0c8ad5e3c5..deab5b6b48 100644 --- a/lib/Doctrine/Driver/PDOConnection.php +++ b/lib/Doctrine/Driver/PDOConnection.php @@ -3,7 +3,6 @@ namespace MailPoet\Doctrine\Driver; use MailPoet\InvalidStateException; -use MailPoet\RuntimeException; class PDOConnection implements \MailPoetVendor\Doctrine\DBAL\Driver\Connection, \MailPoetVendor\Doctrine\DBAL\Driver\ServerInfoAwareConnection { /** @var \PDO */ @@ -51,9 +50,6 @@ class PDOConnection implements \MailPoetVendor\Doctrine\DBAL\Driver\Connection, public function prepare($prepareString, $driverOptions = []) { try { $preparedStatement = $this->connection->prepare($prepareString, $driverOptions); - if ($preparedStatement === false) { - throw new RuntimeException('Unable to prepare PDOStatement.'); - } return $this->createStatement($preparedStatement); } catch (\PDOException $exception) { throw new \MailPoetVendor\Doctrine\DBAL\Driver\PDOException($exception); @@ -99,14 +95,9 @@ class PDOConnection implements \MailPoetVendor\Doctrine\DBAL\Driver\Connection, public function lastInsertId($name = null) { try { if ($name === null) { - $lastId = $this->connection->lastInsertId(); - } else { - $lastId = $this->connection->lastInsertId($name); + return $this->connection->lastInsertId(); } - if ($lastId === false) { - return ''; - } - return $lastId; + return $this->connection->lastInsertId($name); } catch (\PDOException $exception) { throw new \MailPoetVendor\Doctrine\DBAL\Driver\PDOException($exception); } diff --git a/tasks/phpstan/php-version-dependent-config-libs.php b/tasks/phpstan/php-version-dependent-config-libs.php index f3b514fbb1..7bad77c75d 100644 --- a/tasks/phpstan/php-version-dependent-config-libs.php +++ b/tasks/phpstan/php-version-dependent-config-libs.php @@ -8,26 +8,6 @@ $config['parameters']['phpVersion'] = $phpVersion; # PHPStan gets smarter when runs on PHP8 and some type checks added because of PHP8 are reported as unnecessary when we run PHPStan on PHP7 # see https://github.com/phpstan/phpstan/issues/4060 if ($phpVersion < 80000) { - $config['parameters']['ignoreErrors'][] = [ - 'message' => '#^Else branch is unreachable because ternary operator condition is always true#', - 'path' => __DIR__ . '/../../lib/AdminPages/Pages/Forms.php', - 'count' => 1, - ]; - $config['parameters']['ignoreErrors'][] = [ - 'message' => '#^Else branch is unreachable because ternary operator condition is always true#', - 'path' => __DIR__ . '/../../lib/AdminPages/Pages/Newsletters.php', - 'count' => 1, - ]; - $config['parameters']['ignoreErrors'][] = [ - 'message' => '#^Strict comparison using === between PDOStatement and false will always evaluate to false#', - 'path' => __DIR__ . '/../../lib/Doctrine/Driver/PDOConnection.php', - 'count' => 1, - ]; - $config['parameters']['ignoreErrors'][] = [ - 'message' => '#^Strict comparison using === between string and false will always evaluate to false#', - 'path' => __DIR__ . '/../../lib/Doctrine/Driver/PDOConnection.php', - 'count' => 1, - ]; $config['parameters']['ignoreErrors'][] = [ 'message' => '#^Cannot access offset \\(int\\|string\\) on array\\|false#', 'path' => __DIR__ . '/../../lib/Features/FeatureFlagsController.php',