Remove unnecessary type checks
These were added during initial testing of php8 compatibility using PHPStan and were false positive due PHPStan issues. [MAILPOET-2837]
This commit is contained in:
committed by
Veljko V
parent
8b58167ed9
commit
35a25e119f
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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',
|
||||
|
Reference in New Issue
Block a user