Convert variable names to camel case in strings

[MAILPOET-1796]
This commit is contained in:
Jan Jakeš
2020-01-09 15:10:24 +01:00
committed by Jan Jakeš
parent 8c848cfa28
commit 3bbc8ea2af
42 changed files with 116 additions and 115 deletions

View File

@ -298,7 +298,7 @@ class RoboFile extends \Robo\Tasks {
$configurator = new \MailPoet\DI\ContainerConfigurator();
$dumpFile = __DIR__ . '/generated/' . $configurator->getDumpClassname() . '.php';
$this->say('Deleting DI Container');
$this->_exec("rm -f $dump_file");
$this->_exec("rm -f $dumpFile");
$this->say('Generating DI container cache');
$containerFactory = new \MailPoet\DI\ContainerFactory($configurator);
$container = $containerFactory->getConfiguredContainer();
@ -316,8 +316,8 @@ class RoboFile extends \Robo\Tasks {
public function doctrineGenerateMetadata() {
$doctrineMetadataDir = \MailPoet\Doctrine\ConfigurationFactory::METADATA_DIR;
$validatorMetadataDir = \MailPoet\Doctrine\Validator\ValidatorFactory::METADATA_DIR;
$this->_exec("rm -rf $doctrine_metadata_dir");
$this->_exec("rm -rf $validator_metadata_dir");
$this->_exec("rm -rf $doctrineMetadataDir");
$this->_exec("rm -rf $validatorMetadataDir");
$entityManager = $this->createDoctrineEntityManager();
$doctrineMetadata = $entityManager->getMetadataFactory()->getAllMetadata();
@ -330,13 +330,13 @@ class RoboFile extends \Robo\Tasks {
$validator->getMetadataFor($metadata->getName());
}
$this->say("Doctrine metadata generated to: $doctrine_metadata_dir");
$this->say("Validator metadata generated to: $validator_metadata_dir");
$this->say("Doctrine metadata generated to: $doctrineMetadataDir");
$this->say("Validator metadata generated to: $validatorMetadataDir");
}
public function doctrineGenerateProxies() {
$proxyDir = \MailPoet\Doctrine\ConfigurationFactory::PROXY_DIR;
$this->_exec("rm -rf $proxy_dir");
$this->_exec("rm -rf $proxyDir");
// set ArrayCache for metadata to avoid reading & writing them on filesystem as a side effect
$entityManager = $this->createDoctrineEntityManager();
@ -344,7 +344,7 @@ class RoboFile extends \Robo\Tasks {
$entityManager->getProxyFactory()->generateProxyClasses(
$entityManager->getMetadataFactory()->getAllMetadata()
);
$this->say("Doctrine proxies generated to: $proxy_dir");
$this->say("Doctrine proxies generated to: $proxyDir");
}
public function qa() {
@ -556,7 +556,7 @@ class RoboFile extends \Robo\Tasks {
$this->say("Failed to access " . $pluginDistFile);
return;
} elseif (!file_exists($svnDir . "/.svn/")) {
$this->say("$svn_dir/.svn/ dir not found, is it a SVN repository?");
$this->say("$svnDir/.svn/ dir not found, is it a SVN repository?");
return;
} elseif (file_exists($svnDir . "/tags/" . $pluginVersion)) {
$this->say("A SVN tag already exists: " . $pluginVersion);
@ -566,44 +566,44 @@ class RoboFile extends \Robo\Tasks {
$collection = $this->collectionBuilder();
// Clean up tmp dirs if the previous run was halted
if (file_exists("$svn_dir/trunk_new") || file_exists("$svn_dir/trunk_old")) {
if (file_exists("$svnDir/trunk_new") || file_exists("$svnDir/trunk_old")) {
$collection->taskFileSystemStack()
->stopOnFail()
->remove(["$svn_dir/trunk_new", "$svn_dir/trunk_old"]);
->remove(["$svnDir/trunk_new", "$svnDir/trunk_old"]);
}
// Extract the distributable zip to tmp trunk dir
$collection->taskExtract($pluginDistFile)
->to("$svn_dir/trunk_new")
->to("$svnDir/trunk_new")
->preserveTopDirectory(false);
// Rename current trunk
if (file_exists("$svn_dir/trunk")) {
if (file_exists("$svnDir/trunk")) {
$collection->taskFileSystemStack()
->rename("$svn_dir/trunk", "$svn_dir/trunk_old");
->rename("$svnDir/trunk", "$svnDir/trunk_old");
}
// Replace old trunk with a new one
$collection->taskFileSystemStack()
->stopOnFail()
->rename("$svn_dir/trunk_new", "$svn_dir/trunk")
->remove("$svn_dir/trunk_old");
->rename("$svnDir/trunk_new", "$svnDir/trunk")
->remove("$svnDir/trunk_old");
// Add new repository assets
$collection->taskFileSystemStack()
->mirror('./plugin_repository/assets', "$svn_dir/assets_new");
->mirror('./plugin_repository/assets', "$svnDir/assets_new");
// Rename current assets folder
if (file_exists("$svn_dir/assets")) {
if (file_exists("$svnDir/assets")) {
$collection->taskFileSystemStack()
->rename("$svn_dir/assets", "$svn_dir/assets_old");
->rename("$svnDir/assets", "$svnDir/assets_old");
}
// Replace old assets with new ones
$collection->taskFileSystemStack()
->stopOnFail()
->rename("$svn_dir/assets_new", "$svn_dir/assets")
->remove("$svn_dir/assets_old");
->rename("$svnDir/assets_new", "$svnDir/assets")
->remove("$svnDir/assets_old");
// Windows compatibility
$awkCmd = '{print " --force \""$2"\""}';
@ -622,14 +622,14 @@ class RoboFile extends \Robo\Tasks {
$result = $collection->run();
if ($result->wasSuccessful()) {
$repoUrl = "https://plugins.svn.wordpress.org/$plugin_dist_name";
$releaseCmd = "svn ci -m \"Release $plugin_version\"";
$tagCmd = "svn copy $repo_url/trunk $repo_url/tags/$plugin_version -m \"Tag $plugin_version\"";
$repoUrl = "https://plugins.svn.wordpress.org/$pluginDistName";
$releaseCmd = "svn ci -m \"Release $pluginVersion\"";
$tagCmd = "svn copy $repoUrl/trunk $repoUrl/tags/$pluginVersion -m \"Tag $pluginVersion\"";
$svnLogin = getenv('WP_SVN_USERNAME');
$svnPassword = getenv('WP_SVN_PASSWORD');
if ($svnLogin && $svnPassword) {
$releaseCmd .= " --username $svn_login --password $svn_password";
$tagCmd .= " --username $svn_login --password $svn_password";
$releaseCmd .= " --username $svnLogin --password $svnPassword";
$tagCmd .= " --username $svnLogin --password $svnPassword";
} else {
$releaseCmd .= ' --force-interactive';
$tagCmd .= ' --force-interactive';
@ -860,7 +860,7 @@ class RoboFile extends \Robo\Tasks {
$version = $this->releaseVersionGetNext($version);
$jiraController = $this->createJiraController();
$jiraVersion = $jiraController->releaseVersion($version);
$this->say("JIRA version '$jira_version[name]' was released.");
$this->say("JIRA version '$jiraVersion[name]' was released.");
}
public function releasePublishSlack($version = null) {

View File

@ -36,7 +36,7 @@ class Reporter {
$segments = Segment::getAnalytics();
$hasWc = $this->woocommerceHelper->isWooCommerceActive();
$inactiveSubscribersMonths = (int)round((int)$this->settings->get('deactivate_subscriber_after_inactive_days') / 30);
$inactiveSubscribersStatus = $inactiveSubscribersMonths === 0 ? 'never' : "$inactive_subscribers_months months";
$inactiveSubscribersStatus = $inactiveSubscribersMonths === 0 ? 'never' : "$inactiveSubscribersMonths months";
$result = [
'PHP version' => PHP_VERSION,

View File

@ -367,7 +367,7 @@ class MP2Migrator {
$sql = "
SELECT l.list_id, l.name, l.description, l.is_enabled, l.created_at
FROM `$table` l
WHERE l.list_id > '$last_id'
WHERE l.list_id > '$lastId'
ORDER BY l.list_id
LIMIT $limit
";
@ -604,7 +604,7 @@ class MP2Migrator {
$sql = "
SELECT u.*
FROM `$table` u
WHERE u.user_id > '$last_id'
WHERE u.user_id > '$lastId'
ORDER BY u.user_id
LIMIT $limit
";
@ -701,7 +701,7 @@ class MP2Migrator {
$sql = "
SELECT ul.list_id, ul.sub_date, ul.unsub_date
FROM `$table` ul
WHERE ul.user_id = '$user_id'
WHERE ul.user_id = '$userId'
";
$userLists = $wpdb->get_results($sql, ARRAY_A);
@ -852,7 +852,7 @@ class MP2Migrator {
$sql = "
SELECT f.*
FROM `$table` f
WHERE f.form_id > '$last_id'
WHERE f.form_id > '$lastId'
ORDER BY f.form_id
LIMIT $limit
";
@ -1116,7 +1116,7 @@ class MP2Migrator {
$sql = "
SELECT e.*
FROM `$table` e
WHERE e.email_id = '$email_id'
WHERE e.email_id = '$emailId'
";
$email = $wpdb->get_row($sql, ARRAY_A);

View File

@ -50,7 +50,7 @@ class ConnectionFactory {
private function getDriverOptions($timezoneOffset, $charset, $collation) {
$driverOptions = [
"@@session.time_zone = '$timezone_offset'",
"@@session.time_zone = '$timezoneOffset'",
'@@session.sql_mode = REPLACE(@@sql_mode, "ONLY_FULL_GROUP_BY", "")',
// We need to use CONVERT for MySQL 8, Maria DB bug which triggers #1232 - Incorrect argument type to variable 'wait_timeout`
// https://stackoverflow.com/questions/35187378/mariadb-type-error-when-setting-session-variable

View File

@ -71,7 +71,7 @@ abstract class Repository {
$connection = $this->entityManager->getConnection();
$connection->transactional(function(Connection $connection) use ($tableName) {
$connection->query('SET FOREIGN_KEY_CHECKS=0');
$q = "TRUNCATE $table_name";
$q = "TRUNCATE $tableName";
$connection->executeUpdate($q);
$connection->query('SET FOREIGN_KEY_CHECKS=1');
});

View File

@ -17,8 +17,8 @@ class ValidationException extends \RuntimeException {
$this->violations = $violations;
$linePrefix = ' ';
$message = "Validation failed for '$resource_name'.\nDetails:\n";
$message .= $linePrefix . implode("\n$line_prefix", $this->getErrors());
$message = "Validation failed for '$resourceName'.\nDetails:\n";
$message .= $linePrefix . implode("\n$linePrefix", $this->getErrors());
parent::__construct($message);
}

View File

@ -96,7 +96,7 @@ class MailerError {
$message .= implode(
', ',
array_map(function (SubscriberError $subscriberError) {
return "($subscriber_error)";
return "($subscriberError)";
}, $this->subscribersErrors)
);
return $message;

View File

@ -129,6 +129,6 @@ class MailPoetMapper {
]
);
return "$message<br><br>$subscriber_limit_message<br>$deliverability_message<br>";
return "$message<br><br>$subscriberLimitMessage<br>$deliverabilityMessage<br>";
}
}

View File

@ -66,7 +66,7 @@ class StatisticsClicks extends Model {
";
return static::tableAlias('clicks')
->whereRaw("clicks.id IN ($latest_click_ids_per_newsletter_query)", [
->whereRaw("clicks.id IN ($latestClickIdsPerNewsletterQuery)", [
'subscriber_id' => $subscriber->id,
'from' => $from->format('Y-m-d H:i:s'),
'to' => $to->format('Y-m-d H:i:s'),

View File

@ -27,7 +27,7 @@ class SettingsRepository extends Repository {
$now = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
$tableName = $this->entityManager->getClassMetadata(SettingEntity::class)->getTableName();
$this->entityManager->getConnection()->executeUpdate("
INSERT INTO $table_name (name, value, created_at, updated_at)
INSERT INTO $tableName (name, value, created_at, updated_at)
VALUES (:name, :value, :now, :now)
ON DUPLICATE KEY UPDATE value = :value, updated_at = :now
", [

View File

@ -92,13 +92,13 @@ class InactiveSubscribersController {
$inactivesTaskIdsTable = sprintf("
CREATE TEMPORARY TABLE IF NOT EXISTS inactives_task_ids
(INDEX task_id_ids (id))
SELECT DISTINCT task_id as id FROM $sending_queues_table as sq
JOIN $scheduled_tasks_table as st ON sq.task_id = st.id
SELECT DISTINCT task_id as id FROM $sendingQueuesTable as sq
JOIN $scheduledTasksTable as st ON sq.task_id = st.id
WHERE st.processed_at > '%s'
AND st.processed_at < '%s'
AND EXISTS (
SELECT 1
FROM $statistics_opens_table as so
FROM $statisticsOpensTable as so
WHERE so.created_at > '%s'
AND so.newsletter_id = sq.newsletter_id
)",
@ -113,23 +113,23 @@ class InactiveSubscribersController {
$endId = $startId + $batchSize;
$inactiveSubscriberIdsTmpTable = 'inactive_subscriber_ids';
ORM::rawExecute("
CREATE TEMPORARY TABLE IF NOT EXISTS $inactive_subscriber_ids_tmp_table
CREATE TEMPORARY TABLE IF NOT EXISTS $inactiveSubscriberIdsTmpTable
(UNIQUE subscriber_id (id))
SELECT DISTINCT s.id FROM $subscribers_table as s
JOIN $scheduled_task_subcribres_table as sts USE INDEX (subscriber_id) ON s.id = sts.subscriber_id
SELECT DISTINCT s.id FROM $subscribersTable as s
JOIN $scheduledTaskSubcribresTable as sts USE INDEX (subscriber_id) ON s.id = sts.subscriber_id
JOIN inactives_task_ids task_ids ON task_ids.id = sts.task_id
WHERE s.last_subscribed_at < ? AND s.status = ? AND s.id >= ? AND s.id < ?",
[$thresholdDateIso, Subscriber::STATUS_SUBSCRIBED, $startId, $endId]
);
$idsToDeactivate = ORM::forTable($inactiveSubscriberIdsTmpTable)->rawQuery("
SELECT s.id FROM $inactive_subscriber_ids_tmp_table s
LEFT OUTER JOIN $statistics_opens_table as so ON s.id = so.subscriber_id AND so.created_at > ?
SELECT s.id FROM $inactiveSubscriberIdsTmpTable s
LEFT OUTER JOIN $statisticsOpensTable as so ON s.id = so.subscriber_id AND so.created_at > ?
WHERE so.id IS NULL",
[$thresholdDateIso]
)->findArray();
ORM::rawExecute("DROP TABLE $inactive_subscriber_ids_tmp_table");
ORM::rawExecute("DROP TABLE $inactiveSubscriberIdsTmpTable");
$idsToDeactivate = array_map(
function ($id) {
@ -160,19 +160,19 @@ class InactiveSubscribersController {
$mp2MigrationDate = $this->getMP2MigrationDate();
if ($mp2MigrationDate && $mp2MigrationDate > $thresholdDate) {
// If MP2 migration occurred during detection interval re-activate all subscribers created before migration
$idsToActivate = ORM::forTable($subscribersTable)->select("$subscribers_table.id")
->whereLt("$subscribers_table.created_at", $mp2MigrationDate)
->where("$subscribers_table.status", Subscriber::STATUS_INACTIVE)
$idsToActivate = ORM::forTable($subscribersTable)->select("$subscribersTable.id")
->whereLt("$subscribersTable.created_at", $mp2MigrationDate)
->where("$subscribersTable.status", Subscriber::STATUS_INACTIVE)
->limit($batchSize)
->findArray();
} else {
$idsToActivate = ORM::forTable($subscribersTable)->select("$subscribers_table.id")
->leftOuterJoin($statsOpensTable, "$subscribers_table.id = $stats_opens_table.subscriber_id AND $stats_opens_table.created_at > '$threshold_date'")
->whereLt("$subscribers_table.last_subscribed_at", $thresholdDate)
->where("$subscribers_table.status", Subscriber::STATUS_INACTIVE)
->whereRaw("$stats_opens_table.id IS NOT NULL")
$idsToActivate = ORM::forTable($subscribersTable)->select("$subscribersTable.id")
->leftOuterJoin($statsOpensTable, "$subscribersTable.id = $statsOpensTable.subscriber_id AND $statsOpensTable.created_at > '$thresholdDate'")
->whereLt("$subscribersTable.last_subscribed_at", $thresholdDate)
->where("$subscribersTable.status", Subscriber::STATUS_INACTIVE)
->whereRaw("$statsOpensTable.id IS NOT NULL")
->limit($batchSize)
->groupByExpr("$subscribers_table.id")
->groupByExpr("$subscribersTable.id")
->findArray();
}

View File

@ -31,7 +31,7 @@ class DoctrinePanel implements IBarPanel {
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACUAAAAyCAYAAADbTRIgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAABONJREFUWEe9WFtsVEUYrtEQE4zRqA8mBqJGHlTWiBdAUXxAH9QEL2gQFJSrGoFtK4Ix3q8J1kIVCREEEjCaqNEY0QcevEIDRKi0SQm2AhZdlaqlu3vO7O454/ef/q175sycy7qHL/nS7cz8//ftnNl/5kxDFIpLM2dZSzLPgj34XMbff8AP8flyHnJyAeELYOAwKDW0wJk89OQBopurTOhYAe/m4enDahxPpv6oMmCiDU7jsHSRz14xCmJulXgYB4tLMhM5ND0Uh2bqT0U8jP0wlv7ih9B6RTiKx2DsQg5PB/j1nQ+hnCIcxUMUxynSAb75VRAaUISj2AFjZ3OKdABjN0GI6pLOgInfw9hoTpEOIDIdpIquM2DilzA2ilOkA4jMBeOWiWF+UFyWOZVTpAOIZBXROFyfz44/hVPUH/mmy8jYi4poHL6KgsxZ6ogCCirWyGQIbFcE43I5p6oPYOYSJP1UEUlKWo8LOGXtyC/LnIaS8BSSJS0JJtLJYganTw7Mzlgk2FWVsF6kk8UtLBMfMDQVgeEbcuPVUqy6T9ovTdf3h7MATmG5aOBx3YUA+ja6ZB5LG5uke6JfDsM5fEDar9ypHRtCOlmMY1kzMEN3YHBJCfbRfv42KSsltlOF4gkpXp+tjQlhFzTPYPkg0DkJg4pKUIClbc+wCw2swVqMvcMW/IChc9DZpwzWUrTOYQcGFGGs5QFtrIFUKoJHajRuqRoUSad7FzswwMpL8UYiY52+PRKzdCUaE2209pNTpdt3kB0YQMYwq7p4A2exJW+WtiqdsWivvEE6R7vYgQE2jK1+UBuvYTttZQ2FpZkz8U/k4jbRfuJ66fz8IzswwC7ENoanNo5q0gxdZyIuv046PT+wAwPiG2uiR9emNI7QfvpmKdYuluLtR6R4a6EUbfPBeV5y0TrXW8iiZTZKwCwp1syT7vE+dmAA6pj9cmSB/YhMfaU0Sis7QVb2bpfSdTlb/eDmeqXVdI1fz89uMhW4wCh/vIpTpIPyJ60+PYV5MjWoNErnYDuHpwO3r9unp9AlU4E3FKd3P4enAzfX49NTKMiUUBpl+fO1HJ4Oyp+1+fQU5shU8LW8+VpZ2b8jnYXef0xaj0/y6/m5m0x9pzSO0F55o/cTFi33S/HmgqHSsO5RLhGLUB7QtuYhbyuh/92/fmVpA8oCZSRy29lEplYrjclJxbN3HysbUC7J0oZGfXwVUcwXkalb1Y5E9LaZDlY2QBQxuw/r4/10sc2MoRMC3dj9rnTGor1iinSOhG/IbmEgziMb5jdyxUUjp4TnlM5o4qUhar9zB45L+7V79PEa4tHdO+QIwGzRXXmcS9cRlndsZmk96Fdmv3C7NtbAAwX1IgSNc5RBRtIBT/viwHB/6/E2c12sgbSWgsfhQta7eH1fGawlvRiY4Bzp9EqJLi6EG9hGEHA7GgP2KgFBori6f+fYxn9wDu1BeZisjzGzAwfN8Bs/GDsPAzuVwABpAdOseEANqnz9XtSRRMej0BvD0uHAwHMREOsOgcqC1TxR2xfBn6BzMUvGA6b0dASuA5NeJ8bhF/TFWSo5UDumIUmXkrRW5pBv/mA28/+vGql+INlMJP0WrGXm9oGPRS7oWkELEwILwXfBdpBe9elCjS7D6O8v4E5wI7iY1o3dfClHx0FDw7+Sb2560wLhYgAAAABJRU5ErkJggg=="
style="height: 15px"
/>';
return $img . '<span class="tracy-label" >' . "$count $count_suffix / $time ms" . '</span>';
return $img . '<span class="tracy-label" >' . "$count $countSuffix / $time ms" . '</span>';
}
public function getPanel() {

View File

@ -46,7 +46,7 @@ class Handlebars extends AbstractExtension {
$output = <<<EOL
<script id="$id" type="text/x-handlebars-template">
$rendered_template
$renderedTemplate
</script>
EOL;

View File

@ -56,7 +56,7 @@ class UnauthorizedEmailInNewslettersNotice {
$linkText = $this->wp->_x('Update the from address of %s', '%s will be replaced by a newsletter subject', 'mailpoet');
$linkText = str_replace('%s', EscapeHelper::escapeHtmlText($error['subject']), $linkText);
$linkUrl = $this->wp->adminUrl('admin.php?page=' . Menu::MAIN_PAGE_SLUG . '#/send/' . $error['newsletter_id']);
$link = Helpers::replaceLinkTags("[link]{$link_text}[/link]", $linkUrl, ['target' => '_blank']);
$link = Helpers::replaceLinkTags("[link]{$linkText}[/link]", $linkUrl, ['target' => '_blank']);
$links .= "<p>$link</p>";
}
return $links;
@ -73,9 +73,9 @@ class UnauthorizedEmailInNewslettersNotice {
$authorizeLink = str_replace('%s', EscapeHelper::escapeHtmlText($emails[0]), $authorizeLink);
}
$authorizeLink = Helpers::replaceLinkTags("[link]{$authorize_link}[/link]", 'https://account.mailpoet.com/authorization', ['target' => '_blank']);
$authorizeLink = Helpers::replaceLinkTags("[link]{$authorizeLink}[/link]", 'https://account.mailpoet.com/authorization', ['target' => '_blank']);
$html = '<p><b>' . $this->wp->_x('OR', 'User has to choose between two options', 'mailpoet') . '</b></p>';
$html .= "<p>$authorize_link</p>";
$html .= "<p>$authorizeLink</p>";
return $html;
}

View File

@ -62,9 +62,9 @@ class UnauthorizedEmailNotice {
$email = $validationError['invalid_sender_address'];
$authorizeLink = $this->wp->_x('Authorize %s', 'Link for user to authorize their email address', 'mailpoet');
$authorizeLink = str_replace('%s', EscapeHelper::escapeHtmlText($email), $authorizeLink);
$authorizeLink = Helpers::replaceLinkTags("[link]{$authorize_link}[/link]", 'https://account.mailpoet.com/authorization', ['target' => '_blank']);
$authorizeLink = Helpers::replaceLinkTags("[link]{$authorizeLink}[/link]", 'https://account.mailpoet.com/authorization', ['target' => '_blank']);
$html = '<p><b>' . $this->wp->_x('OR', 'User has to choose between two options', 'mailpoet') . '</b></p>';
$html .= "<p>$authorize_link</p>";
$html .= "<p>$authorizeLink</p>";
return $html;
}

View File

@ -48,7 +48,7 @@ class Helper {
global $wpdb;
$result = $wpdb->get_var( "
SELECT DISTINCT count(p.ID) FROM {$wpdb->prefix}posts as p
WHERE p.post_type = 'shop_order' AND p.post_date < '{$date_time}'
WHERE p.post_type = 'shop_order' AND p.post_date < '{$dateTime}'
" );
return (int)$result;
}

View File

@ -24,7 +24,7 @@ if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracyPath)) {
}
if (!is_writable($logDir)) {
throw new RuntimeException("Logging directory '$log_dir' is not writable.'");
throw new RuntimeException("Logging directory '$logDir' is not writable.'");
}
Debugger::enable(Debugger::PRODUCTION, $logDir);
@ -42,7 +42,7 @@ if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracyPath)) {
// set higher number of displayed AJAX rows
$maxAjaxRows = 4;
$tracyScriptHtml .= "<script>window.TracyMaxAjaxRows = $max_ajax_rows;</script>\n";
$tracyScriptHtml .= "<script>window.TracyMaxAjaxRows = $maxAjaxRows;</script>\n";
echo $tracyScriptHtml;
}
add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0);

View File

@ -24,7 +24,7 @@ foreach ($files as $file) {
$nestingLevel = substr_count(str_replace('\\', '/', $path), '/');
$search = 'namespace MailPoetVendor;';
$requirePath = str_repeat('/..', $nestingLevel) . '/swift_init.php';
$data = str_replace($search, "$search\n\nrequire_once __DIR__ . '$require_path';", $data);
$data = str_replace($search, "$search\n\nrequire_once __DIR__ . '$requirePath';", $data);
}
file_put_contents($file, $data);
}

View File

@ -182,4 +182,5 @@
<!-- Enforce camelCase naming of variables and properties -->
<rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps"/>
<rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps"/>
<rule ref="Squiz.NamingConventions.ValidVariableName.StringNotCamelCaps"/>
</ruleset>

View File

@ -71,7 +71,7 @@ class ChangelogController {
private function updateReadme($heading, $changesList) {
$headingPrefix = explode(self::HEADING_GLUE, $heading)[0];
$readme = file_get_contents($this->readmeFile);
$changelog = "$heading\n$changes_list";
$changelog = "$heading\n$changesList";
if (strpos($readme, $headingPrefix) !== false) {
$start = preg_quote($headingPrefix);

View File

@ -36,7 +36,7 @@ class CircleCiController {
'headers' => [
'Accept' => 'application/json',
],
'base_uri' => 'https://circleci.com/api/v1.1/project/github/' . urlencode($username) . "/$circle_ci_project/",
'base_uri' => 'https://circleci.com/api/v1.1/project/github/' . urlencode($username) . "/$circleCiProject/",
]);
$this->githubController = $githubController;
}
@ -70,7 +70,7 @@ class CircleCiController {
private function checkZipBuildJob(array $job) {
if ($job['status'] !== self::JOB_STATUS_SUCCESS) {
$expectedStatus = self::JOB_STATUS_SUCCESS;
throw new \Exception("Job has invalid status '$job[status]', '$expected_status' expected");
throw new \Exception("Job has invalid status '$job[status]', '$expectedStatus' expected");
}
if ($job['has_artifacts'] === false) {
@ -87,7 +87,7 @@ class CircleCiController {
}
private function getReleaseZipUrl($buildNumber) {
$response = $this->httpClient->get("$build_number/artifacts");
$response = $this->httpClient->get("$buildNumber/artifacts");
$artifacts = json_decode($response->getBody()->getContents(), true);
$pattern = preg_quote($this->zipFilename, '~');

View File

@ -30,7 +30,7 @@ class GitHubController {
'headers' => [
'Accept' => 'application/vnd.github.v3+json',
],
'base_uri' => "https://api.github.com/repos/mailpoet/$github_path/",
'base_uri' => "https://api.github.com/repos/mailpoet/$githubPath/",
]);
}
@ -51,10 +51,10 @@ class GitHubController {
}
private function assignPullRequest($pullRequestNumber) {
$this->httpClient->post("pulls/$pull_request_number/requested_reviewers", [
$this->httpClient->post("pulls/$pullRequestNumber/requested_reviewers", [
'json' => ['reviewers' => [self::QA_GITHUB_LOGIN]],
]);
$this->httpClient->post("issues/$pull_request_number/assignees", [
$this->httpClient->post("issues/$pullRequestNumber/assignees", [
'json' => ['assignees' => [self::QA_GITHUB_LOGIN]],
]);
}
@ -108,7 +108,7 @@ class GitHubController {
}
private function checkPullRequestReviews($pullRequestNumber) {
$response = $this->httpClient->get("pulls/$pull_request_number/reviews");
$response = $this->httpClient->get("pulls/$pullRequestNumber/reviews");
$response = json_decode($response->getBody()->getContents(), true);
$approved = 0;
foreach ($response as $review) {

View File

@ -40,7 +40,7 @@ class JiraController {
$urlToken = urlencode($this->token);
$jiraDomain = self::JIRA_DOMAIN;
$jiraApiVersion = self::JIRA_API_VERSION;
$baseUri = "https://$url_user:$url_token@$jira_domain/rest/api/$jira_api_version/";
$baseUri = "https://$urlUser:$urlToken@$jiraDomain/rest/api/$jiraApiVersion/";
$this->httpClient = new Client(['base_uri' => $baseUri]);
}

View File

@ -32,10 +32,10 @@ class SlackNotifier {
$pluginType = $this->project === self::PROJECT_MAILPOET ? 'Free' : 'Premium';
$githubPath = $this->project === self::PROJECT_MAILPOET ? 'mailpoet' : 'mailpoet-premium';
$message = "*$plugin_type plugin `$version` released :tada:!*\n";
$message = "*$pluginType plugin `$version` released :tada:!*\n";
$message .= "\n";
$message .= "GitHub: https://github.com/mailpoet/$github_path/releases/tag/$version\n";
$message .= "JIRA: https://mailpoet.atlassian.net/projects/$this->project/versions/$release_id\n";
$message .= "GitHub: https://github.com/mailpoet/$githubPath/releases/tag/$version\n";
$message .= "JIRA: https://mailpoet.atlassian.net/projects/$this->project/versions/$releaseId\n";
if ($this->project === self::PROJECT_MAILPOET) {
$message .= "WordPress: https://wordpress.org/plugins/mailpoet/#developers\n";
}

View File

@ -14,10 +14,10 @@ class WooCommerceCustomer {
$unique_id = bin2hex(random_bytes(7)); // phpcs:ignore
$this->tester = $tester;
$this->data = [
'first_name' => "FirstName_$unique_id",
'last_name' => "LastName_$unique_id",
'email' => "woo_customer_$unique_id@example.com",
'password' => "woo_customer_$unique_id",
'first_name' => "FirstName_$uniqueId",
'last_name' => "LastName_$uniqueId",
'email' => "woo_customer_$uniqueId@example.com",
'password' => "woo_customer_$uniqueId",
];
}

View File

@ -29,9 +29,9 @@ class WooCommerceOrder {
'city' => 'Paris',
'address_1' => 'Rue Galien 2',
'country' => 'FR',
'first_name' => "Guest_First_$unique_id",
'last_name' => "Guest_Last_$unique_id",
'email' => "guest_$unique_id@example.com",
'first_name' => "Guest_First_$uniqueId",
'last_name' => "Guest_Last_$uniqueId",
'email' => "guest_$uniqueId@example.com",
],
'currency' => 'EUR',
'products' => null,

View File

@ -243,7 +243,7 @@ class WooCommercePastRevenues {
if ($generatedCount % self::LOG_BATCH_SIZE !== 0) {
return;
}
return "$data_type: $generated_count";
return "$dataType: $generatedCount";
}
private function prepareDatabaseTables() {
@ -335,7 +335,7 @@ class WooCommercePastRevenues {
// Add subscribers to task
$batchData = [];
foreach ($subscribersIds as $subscriberId) {
$batchData[] = "({$task->id}, $subscriber_id, 1, '$sent_at')";
$batchData[] = "({$task->id}, $subscriberId, 1, '$sentAt')";
if (count($batchData) % 1000 === 0) {
ORM::rawExecute(
"INSERT INTO " . ScheduledTaskSubscriber::$_table . " (`task_id`, `subscriber_id`, `processed`, `created_at`) VALUES " . implode(', ', $batchData)
@ -426,12 +426,12 @@ class WooCommercePastRevenues {
*/
private function createCompletedWooCommerceOrder($subscriberId, $email, $products = [], Carbon $completedAt = null) {
$address = [
'first_name' => "name_$subscriber_id",
'last_name' => "lastname_$subscriber_id",
'first_name' => "name_$subscriberId",
'last_name' => "lastname_$subscriberId",
'email' => $email,
'phone' => '123-456-789',
'address_1' => "$subscriber_id Main st.",
'city' => "City of $subscriber_id",
'address_1' => "$subscriberId Main st.",
'city' => "City of $subscriberId",
'postcode' => '92121',
'country' => 'France',
];

View File

@ -13,7 +13,7 @@ class ConfirmTitleAlignmentSettingsInALCBlockCest {
$subject = 'ALC Newsletter';
$postTitle = 'Post for ALC newsletter testing';
$postBody = 'Magna primis leo neque litora quisque phasellus nunc himenaeos per, cursus porttitor rhoncus primis cubilia condimentum magna semper curabitur nibh, nunc nulla porttitor aptent aliquet dui nec accumsan quisque pharetra non pellentesque senectus hendrerit bibendum.';
$post = $i->cliToArray(['post', 'create', '--format=json', '--porcelain', "--post_title=$post_title", "--post_content=$post_body", '--post_status=publish']);
$post = $i->cliToArray(['post', 'create', '--format=json', '--porcelain', "--post_title=$postTitle", "--post_content=$postBody", '--post_status=publish']);
$i->cli(['media', 'import', dirname(__DIR__) . '/_data/600x400.jpg', "--post_id=$post[0]", '--title=A downloaded picture', '--featured_image']);
$newsletterFactory = new Newsletter();
$newsletter = $newsletterFactory->withSubject($subject)->create();

View File

@ -43,7 +43,7 @@ class ReceivePostNotificationCest {
->create();
$i->wait(1); //waiting 1 second so that post created time is after the newsletter
$i->cli(['post', 'create', "--post_title=$post_title", '--post_content=Lorem Ipsum', '--post_status=publish']);
$i->cli(['post', 'create', "--post_title=$postTitle", '--post_content=Lorem Ipsum', '--post_status=publish']);
$i->login();

View File

@ -16,7 +16,7 @@ class SettingsSubscriptionPageCest {
$pageContent = '[mailpoet_manage_subscription]';
$i->login();
$i->amOnMailPoetPage('Settings');
$i->cli(['post', 'create', '--post_type=page', "--post_title=$page_title", "--post_content=$page_content"]);
$i->cli(['post', 'create', '--post_type=page', "--post_title=$pageTitle", "--post_content=$pageContent"]);
$i->click(['css' => '#subscription_manage_page.mailpoet_page_selection']);
$i->checkOption('select#subscription_manage_page', $pageTitle);
$i->click('[data-automation-id="preview_manage_subscription_page_link"]');

View File

@ -74,10 +74,10 @@ class WooCommerceListImportPageCest {
$submitButton = '[data-automation-id="submit_woo_commerce_list_import"]';
$i->cantSeeCheckboxIsChecked($unsubscribedRadio);
$i->cantSeeCheckboxIsChecked($subscribedRadio);
$i->seeElement("$submit_button:disabled");
$i->seeElement("$submitButton:disabled");
$i->selectOption($unsubscribedRadio, 'unsubscribed');
$i->canSeeCheckboxIsChecked($unsubscribedRadio);
$i->seeElement("$submit_button:not(:disabled)");
$i->seeElement("$submitButton:not(:disabled)");
$i->seeNoJSErrors();
$i->click($submitButton);
$i->seeNoJSErrors();

View File

@ -21,7 +21,7 @@ class FeatureFlagsTest extends \MailPoetTest {
parent::_before();
$this->repository = $this->diContainer->get(FeatureFlagsRepository::class);
$tableName = $this->entityManager->getClassMetadata(FeatureFlagEntity::class)->getTableName();
$this->entityManager->getConnection()->executeUpdate("TRUNCATE $table_name");
$this->entityManager->getConnection()->executeUpdate("TRUNCATE $tableName");
}
public function testItReturnsDefaults() {

View File

@ -62,6 +62,6 @@ class UserFlagsTest extends \MailPoetTest {
private function cleanup() {
$tableName = $this->entityManager->getClassMetadata(UserFlagEntity::class)->getTableName();
$this->entityManager->getConnection()->executeUpdate("TRUNCATE $table_name");
$this->entityManager->getConnection()->executeUpdate("TRUNCATE $tableName");
}
}

View File

@ -366,7 +366,7 @@ class MP2MigratorTest extends \MailPoetTest {
$table = MP_SUBSCRIBER_SEGMENT_TABLE;
$segmentId = $importedSegmentsMapping[$listId];
$subscriberId = $importedSubscribersMapping[$userId];
$subscriberSegment = $wpdb->get_row("SELECT * FROM $table WHERE subscriber_id='$subscriber_id' AND segment_id='$segment_id'");
$subscriberSegment = $wpdb->get_row("SELECT * FROM $table WHERE subscriber_id='$subscriberId' AND segment_id='$segmentId'");
expect($subscriberSegment)->notNull();
}
@ -422,7 +422,7 @@ class MP2MigratorTest extends \MailPoetTest {
$importedSubscribersMapping = $this->MP2Migrator->getImportedMapping('subscribers');
$table = MP_SUBSCRIBER_CUSTOM_FIELD_TABLE;
$subscriberId = $importedSubscribersMapping[$userId];
$subscriberCustomField = $wpdb->get_row("SELECT * FROM $table WHERE subscriber_id='$subscriber_id' AND custom_field_id='$cf_id'");
$subscriberCustomField = $wpdb->get_row("SELECT * FROM $table WHERE subscriber_id='$subscriberId' AND custom_field_id='$cfId'");
expect($subscriberCustomField->value)->equals($customFieldValue);
}

View File

@ -173,7 +173,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
$click->linkId = 1;
$click->count = 1;
$timestamp = new DateTime("-$created_days_ago days");
$timestamp = new DateTime("-$createdDaysAgo days");
$click->createdAt = $timestamp->format('Y-m-d H:i:s');
$click->updatedAt = $timestamp->format('Y-m-d H:i:s');
return $click->save();

View File

@ -42,7 +42,7 @@ class ValidationTest extends \MailPoetTest {
$this->fail('Validation exception was not thrown.');
} catch (ValidationException $e) {
$entityClass = get_class($entity);
expect($e->getMessage())->same("Validation failed for '$entity_class'.\nDetails:\n [name] This value should not be blank.");
expect($e->getMessage())->same("Validation failed for '$entityClass'.\nDetails:\n [name] This value should not be blank.");
}
}
@ -59,7 +59,7 @@ class ValidationTest extends \MailPoetTest {
$this->fail('Validation exception was not thrown.');
} catch (ValidationException $e) {
$entityClass = get_class($entity);
expect($e->getMessage())->same("Validation failed for '$entity_class'.\nDetails:\n [name] This value is too short. It should have 3 characters or more.");
expect($e->getMessage())->same("Validation failed for '$entityClass'.\nDetails:\n [name] This value is too short. It should have 3 characters or more.");
}
}

View File

@ -122,13 +122,13 @@ class SettingsControllerTest extends \MailPoetTest {
private function createOrUpdateSetting($name, $value) {
$tableName = $this->entityManager->getClassMetadata(SettingEntity::class)->getTableName();
$this->connection->executeUpdate("
INSERT INTO $table_name (name, value) VALUES (?, ?)
INSERT INTO $tableName (name, value) VALUES (?, ?)
ON DUPLICATE KEY UPDATE value = ?
", [$name, $value, $value]);
}
private function getSettingValue($name) {
$tableName = $this->entityManager->getClassMetadata(SettingEntity::class)->getTableName();
return $this->connection->executeQuery("SELECT value FROM $table_name WHERE name = ?", [$name])->fetchColumn();
return $this->connection->executeQuery("SELECT value FROM $tableName WHERE name = ?", [$name])->fetchColumn();
}
}

View File

@ -116,6 +116,6 @@ class UserFlagsControllerTest extends \MailPoetTest {
private function cleanup() {
$tableName = $this->entityManager->getClassMetadata(UserFlagEntity::class)->getTableName();
$this->connection->executeUpdate("TRUNCATE $table_name");
$this->connection->executeUpdate("TRUNCATE $tableName");
}
}

View File

@ -315,7 +315,7 @@ class WooCommercePurchasesTest extends \MailPoetTest {
$click->linkId = (int)$link->id;
$click->count = 1;
$timestamp = new DateTime("-$created_days_ago days");
$timestamp = new DateTime("-$createdDaysAgo days");
$click->createdAt = $timestamp->format('Y-m-d H:i:s');
$click->updatedAt = $timestamp->format('Y-m-d H:i:s');
return $click->save();

View File

@ -300,13 +300,13 @@ class InactiveSubscribersControllerTest extends \MailPoetTest {
private function createSetting($name, $value, $createdAt) {
$tableName = $this->entityManager->getClassMetadata(SettingEntity::class)->getTableName();
$this->connection->executeUpdate(
"INSERT INTO $table_name (name, value, created_at) VALUES (?, ?, ?)",
"INSERT INTO $tableName (name, value, created_at) VALUES (?, ?, ?)",
[$name, $value, $createdAt]
);
}
private function removeSetting($name) {
$tableName = $this->entityManager->getClassMetadata(SettingEntity::class)->getTableName();
$this->connection->executeUpdate("DELETE FROM $table_name WHERE name = ?", [$name]);
$this->connection->executeUpdate("DELETE FROM $tableName WHERE name = ?", [$name]);
}
}

View File

@ -60,7 +60,7 @@ foreach ($entities as $entity) {
$tableName = $entityManager->getClassMetadata($entity)->getTableName();
$connection->transactional(function(Connection $connection) use ($tableName) {
$connection->query('SET FOREIGN_KEY_CHECKS=0');
$connection->executeUpdate("TRUNCATE $table_name");
$connection->executeUpdate("TRUNCATE $tableName");
$connection->query('SET FOREIGN_KEY_CHECKS=1');
});
}

View File

@ -21,8 +21,8 @@ if (!file_exists($vendorDir)) {
// download all tools
foreach ($tools as $url => $path) {
$pharPath = "$vendor_dir/$path";
$pharInfoPath = "$phar_path.info";
$pharPath = "$vendorDir/$path";
$pharInfoPath = "$pharPath.info";
fwrite(STDERR, "Downloading '$url'...");
if (file_exists($pharPath) && file_exists($pharInfoPath) && file_get_contents($pharInfoPath) === $url) {