diff --git a/Buildplan/Dockerfile-Jenkins b/Buildplan/Dockerfile-Jenkins index bc6d9670..2c918ee2 100644 --- a/Buildplan/Dockerfile-Jenkins +++ b/Buildplan/Dockerfile-Jenkins @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.04 ARG ACF_PRO_VERSION=latest ARG WP_VERSION=latest diff --git a/composer.json b/composer.json index 71ed6d1b..9562b256 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "smartling/wordpress-connector", "license": "GPL-2.0-or-later", - "version": "3.10.0", + "version": "4.0.0", "description": "", "type": "wordpress-plugin", "repositories": [ @@ -13,7 +13,7 @@ "require": { "galbar/jsonpath": "^2.0", "vsolovei-smartling/retry": "^2.0.1", - "php": ">=8.0", + "php": ">=8.3", "monolog/monolog": "~1", "symfony/dependency-injection": "~2.8", "symfony/expression-language": "~2.8", diff --git a/inc/Smartling/ApiWrapper.php b/inc/Smartling/ApiWrapper.php index d6c8d5eb..4dd3279f 100644 --- a/inc/Smartling/ApiWrapper.php +++ b/inc/Smartling/ApiWrapper.php @@ -45,7 +45,7 @@ class ApiWrapper implements ApiWrapperInterface { use LoggerSafeTrait; - private const ADDITIONAL_HEADERS = ['X-SL-UseSecondaryDB' => 'true']; + private const array ADDITIONAL_HEADERS = ['X-SL-UseSecondaryDB' => 'true']; private SettingsManager $settings; private string $pluginName; diff --git a/inc/Smartling/ApiWrapperInterface.php b/inc/Smartling/ApiWrapperInterface.php index 3fa82c95..8c81ea06 100644 --- a/inc/Smartling/ApiWrapperInterface.php +++ b/inc/Smartling/ApiWrapperInterface.php @@ -19,7 +19,7 @@ interface ApiWrapperInterface { - public const CREATE_JOB_RESPONSE = [ + public const array CREATE_JOB_RESPONSE = [ 'translationJobUid' => 'string', 'jobName' => 'string', 'jobNumber' => 'string', @@ -38,8 +38,8 @@ interface ApiWrapperInterface 'referenceNumber' => 'string', 'customFields' => [], ]; - public const DAILY_BUCKET_JOB_NAME_PREFIX = "Daily Bucket Job"; - public const JOB_STATUSES_FOR_DAILY_BUCKET_JOB = [ + public const string DAILY_BUCKET_JOB_NAME_PREFIX = "Daily Bucket Job"; + public const array JOB_STATUSES_FOR_DAILY_BUCKET_JOB = [ JobStatus::AWAITING_AUTHORIZATION, JobStatus::IN_PROGRESS, JobStatus::COMPLETED, diff --git a/inc/Smartling/ApiWrapperWithRetries.php b/inc/Smartling/ApiWrapperWithRetries.php index a7eec352..e027c6fd 100644 --- a/inc/Smartling/ApiWrapperWithRetries.php +++ b/inc/Smartling/ApiWrapperWithRetries.php @@ -16,8 +16,8 @@ class ApiWrapperWithRetries implements ApiWrapperInterface { use LoggerSafeTrait; - public const RETRY_ATTEMPTS = 4; - private const RETRY_WAIT_SECONDS = 1; + public const int RETRY_ATTEMPTS = 4; + private const int RETRY_WAIT_SECONDS = 1; public function __construct(private ApiWrapperInterface $base, private int $retryWaitSeconds = 1) { diff --git a/inc/Smartling/Base/ExportedAPI.php b/inc/Smartling/Base/ExportedAPI.php index 61f1a2bc..98e3cde2 100755 --- a/inc/Smartling/Base/ExportedAPI.php +++ b/inc/Smartling/Base/ExportedAPI.php @@ -24,7 +24,7 @@ interface ExportedAPI * An action that is executed just after DI initialization * @param ContainerBuilder */ - public const ACTION_SMARTLING_BEFORE_INITIALIZE_EVENT = 'smartling_before_init'; + public const string ACTION_SMARTLING_BEFORE_INITIALIZE_EVENT = 'smartling_before_init'; /** * Is raised just before encoding to XML @@ -39,7 +39,7 @@ interface ExportedAPI * Only update of values is allowed. * Will be changed to ArrayAccess implementation. */ - public const EVENT_SMARTLING_BEFORE_SERIALIZE_CONTENT = 'smartling_before_serialize_content'; + public const string EVENT_SMARTLING_BEFORE_SERIALIZE_CONTENT = 'smartling_before_serialize_content'; /** * Is raised just after decoding from XML @@ -54,55 +54,55 @@ interface ExportedAPI * Only update of values is allowed. * Will be changed to ArrayAccess implementation. */ - public const EVENT_SMARTLING_AFTER_DESERIALIZE_CONTENT = 'smartling_after_deserialize_content'; + public const string EVENT_SMARTLING_AFTER_DESERIALIZE_CONTENT = 'smartling_after_deserialize_content'; /** * Action that prepares submission for upload and creates target placeholders * @param SubmissionEntity */ - public const ACTION_SMARTLING_PREPARE_SUBMISSION_UPLOAD = 'smartling_prepare_submission_upload'; + public const string ACTION_SMARTLING_PREPARE_SUBMISSION_UPLOAD = 'smartling_prepare_submission_upload'; /** * Action that sends given SubmissionEntity to smartling for translation * @param UploadQueueItem */ - public const ACTION_SMARTLING_SEND_FOR_TRANSLATION = 'smartling_send_for_translation'; + public const string ACTION_SMARTLING_SEND_FOR_TRANSLATION = 'smartling_send_for_translation'; /** * Action that clones content of given SubmissionEntity without translation * @param SubmissionEntity */ - public const ACTION_SMARTLING_CLONE_CONTENT = 'smartling_clone_content'; + public const string ACTION_SMARTLING_CLONE_CONTENT = 'smartling_clone_content'; /** * Action that downloads translation for given SubmissionEntity * @param SubmissionEntity */ - public const ACTION_SMARTLING_DOWNLOAD_TRANSLATION = 'smartling_download_translation'; + public const string ACTION_SMARTLING_DOWNLOAD_TRANSLATION = 'smartling_download_translation'; /** * Action regenerates thumbnails for translation by submission * @param SubmissionEntity */ - public const ACTION_SMARTLING_REGENERATE_THUMBNAILS = 'smartling_regenerate_thumbnails'; + public const string ACTION_SMARTLING_REGENERATE_THUMBNAILS = 'smartling_regenerate_thumbnails'; /** * Action for registration a content-type. Only one param is given: * @param ContainerBuilder */ - public const ACTION_SMARTLING_REGISTER_CONTENT_TYPE = 'smartling_register_content_type'; + public const string ACTION_SMARTLING_REGISTER_CONTENT_TYPE = 'smartling_register_content_type'; /** * Action for processing terms related to term / post-based content * @param ProcessRelatedContentParams */ - public const ACTION_SMARTLING_PROCESSOR_RELATED_CONTENT = 'smartling_processor_related_content'; + public const string ACTION_SMARTLING_PROCESSOR_RELATED_CONTENT = 'smartling_processor_related_content'; /** * Action that syncs attachment by submission * @param SubmissionEntity */ - public const ACTION_SMARTLING_SYNC_MEDIA_ATTACHMENT = 'smartling_sync_media_attachment'; + public const string ACTION_SMARTLING_SYNC_MEDIA_ATTACHMENT = 'smartling_sync_media_attachment'; /** * Filter to modify FileURI. @@ -113,21 +113,21 @@ interface ExportedAPI * Filter should return fileUri with length > 0 * otherwise generated fileURI is taken */ - public const FILTER_SMARTLING_FILE_URI = 'smartling_file_uri'; + public const string FILTER_SMARTLING_FILE_URI = 'smartling_file_uri'; /** * Filter to modify the XML node that is going to be sent to smartling. * @param TranslationStringFilterParameters * @return TranslationStringFilterParameters */ - public const FILTER_SMARTLING_TRANSLATION_STRING = 'smartling_translation_string_before_send'; + public const string FILTER_SMARTLING_TRANSLATION_STRING = 'smartling_translation_string_before_send'; /** * Filter to modify the translated XML node that is received from smartling. * @param TranslationStringFilterParameters * @return TranslationStringFilterParameters */ - public const FILTER_SMARTLING_TRANSLATION_STRING_RECEIVED = 'smartling_translation_string_received'; + public const string FILTER_SMARTLING_TRANSLATION_STRING_RECEIVED = 'smartling_translation_string_received'; /** * Filter to modify meta value on translation @@ -135,7 +135,7 @@ interface ExportedAPI * @param mixed metadata field value * @param SubmissionEntity */ - public const FILTER_SMARTLING_METADATA_FIELD_PROCESS = 'smartling_metadata_string_process'; + public const string FILTER_SMARTLING_METADATA_FIELD_PROCESS = 'smartling_metadata_string_process'; /** * Filter to modify meta value on translation @@ -144,7 +144,7 @@ interface ExportedAPI * @param mixed field value * @param array collected values */ - public const FILTER_SMARTLING_METADATA_PROCESS_BEFORE_TRANSLATION = 'smartling_metadata_process_before_translation'; + public const string FILTER_SMARTLING_METADATA_PROCESS_BEFORE_TRANSLATION = 'smartling_metadata_process_before_translation'; /** * Filter processes given SubmissionEntity and creates corresponding target entity if it does not exist. @@ -152,7 +152,7 @@ interface ExportedAPI * @param SubmissionEntity * @return SubmissionEntity */ - public const FILTER_SMARTLING_PREPARE_TARGET_CONTENT = 'smartling_prepare_target_content'; + public const string FILTER_SMARTLING_PREPARE_TARGET_CONTENT = 'smartling_prepare_target_content'; /** * Filter allows to let smartling-connector know about shortcodes that are not registered @@ -160,74 +160,74 @@ interface ExportedAPI * @param array * @return array */ - public const FILTER_SMARTLING_INJECT_SHORTCODE = 'smartling_inject_shortcode'; + public const string FILTER_SMARTLING_INJECT_SHORTCODE = 'smartling_inject_shortcode'; /** * Handler should add an array that defines a post type. * @param array * @return array */ - public const FILTER_SMARTLING_REGISTER_CUSTOM_POST_TYPE = 'smartling_register_custom_type'; + public const string FILTER_SMARTLING_REGISTER_CUSTOM_POST_TYPE = 'smartling_register_custom_type'; /** * Handler should add an array that defines a taxonomy type. * @param array * @return array */ - public const FILTER_SMARTLING_REGISTER_CUSTOM_TAXONOMY = 'smartling_register_custom_taxonomy'; + public const string FILTER_SMARTLING_REGISTER_CUSTOM_TAXONOMY = 'smartling_register_custom_taxonomy'; /** * Handler should add an array that defines a filter. * @param array * @return array */ - public const FILTER_SMARTLING_REGISTER_FIELD_FILTER = 'smartling_register_field_filter'; + public const string FILTER_SMARTLING_REGISTER_FIELD_FILTER = 'smartling_register_field_filter'; /** * Filter fires for notifications * @param NotificationParameters */ - public const ACTION_SMARTLING_PUSH_LIVE_NOTIFICATION = 'smartling_push_notification'; + public const string ACTION_SMARTLING_PUSH_LIVE_NOTIFICATION = 'smartling_push_notification'; /** * Filter prepares contentId to later use with push live notification (Firebase specific) * @param SubmissionEntity */ - public const ACTION_SMARTLING_PLACE_RECORD_ID = 'smartling_place_record_id'; + public const string ACTION_SMARTLING_PLACE_RECORD_ID = 'smartling_place_record_id'; /** * @param SubmissionEntity */ - public const ACTION_AFTER_TARGET_CONTENT_WRITTEN = 'smartling_action_after_target_content_written'; + public const string ACTION_AFTER_TARGET_CONTENT_WRITTEN = 'smartling_action_after_target_content_written'; - public const ACTION_AFTER_TARGET_METADATA_WRITTEN = 'smartling_action_after_target_metadata_written'; + public const string ACTION_AFTER_TARGET_METADATA_WRITTEN = 'smartling_action_after_target_metadata_written'; /** * @param SubmissionEntity */ - public const ACTION_AFTER_TRANSLATION_APPLIED = 'smartling_action_after_translation_applied'; + public const string ACTION_AFTER_TRANSLATION_APPLIED = 'smartling_action_after_translation_applied'; /** * @param array content * @param SubmissionEntity * @return array content */ - public const FILTER_BEFORE_CLONE_CONTENT_WRITTEN = 'smartling_filter_before_clone_content_written'; + public const string FILTER_BEFORE_CLONE_CONTENT_WRITTEN = 'smartling_filter_before_clone_content_written'; /** * @param array translation * @param array lockedData * @param SubmissionEntity * @return array translation */ - public const FILTER_BEFORE_TRANSLATION_APPLIED = 'smartling_filter_before_translation_applied'; + public const string FILTER_BEFORE_TRANSLATION_APPLIED = 'smartling_filter_before_translation_applied'; /** * @param array items */ - public const FILTER_BULK_SUBMIT_PREPARE_ITEMS = 'smartling_filter_bulk_submit_prepare_items'; + public const string FILTER_BULK_SUBMIT_PREPARE_ITEMS = 'smartling_filter_bulk_submit_prepare_items'; /** * @param ConfigurationProfileEntity[] */ - public const FILTER_ACTIVE_PROFILES = 'smartling_filter_active_profiles'; + public const string FILTER_ACTIVE_PROFILES = 'smartling_filter_active_profiles'; } diff --git a/inc/Smartling/Base/SmartlingCoreUploadTrait.php b/inc/Smartling/Base/SmartlingCoreUploadTrait.php index 75509cce..ceea1e79 100644 --- a/inc/Smartling/Base/SmartlingCoreUploadTrait.php +++ b/inc/Smartling/Base/SmartlingCoreUploadTrait.php @@ -25,6 +25,7 @@ use Smartling\Helpers\WordpressFunctionProxyHelper; use Smartling\Helpers\XmlHelper; use Smartling\Jobs\JobEntityWithBatchUid; +use Smartling\Models\IntStringPairCollection; use Smartling\Models\UploadQueueItem; use Smartling\Replacers\ContentIdReplacer; use Smartling\Settings\ConfigurationProfileEntity; @@ -418,11 +419,11 @@ public function applyXML(SubmissionEntity $submission, string $xml, XmlHelper $x */ public function bulkSubmit(UploadQueueItem $item): void { - if (count($item->getSubmissions()) === 0) { + if (count($item->submissions) === 0) { return; } - $submission = $item->getSubmissions()[0]; - $locales = $item->getSmartlingLocales()->getList(); + $submission = ($item->submissions)[0]; + $locales = $item->smartlingLocales->getList(); $profile = $this->getSettingsManager()->getSingleSettingsProfile($submission->getSourceBlogId()); try { $xml = $this->getXMLFiltered($submission); @@ -430,7 +431,7 @@ public function bulkSubmit(UploadQueueItem $item): void $this->getLogger()->debug('Skip upload of empty xml'); return; } - foreach ($item->getSubmissions() as $submission) { + foreach ($item->submissions as $submission) { $submission = $this->prepareUpload($submission); $fileUri = $this->fileUriHelper->generateFileUri($submission); $submission->setFileUri($fileUri); @@ -458,7 +459,7 @@ public function bulkSubmit(UploadQueueItem $item): void implode(',', $locales), )); - if ($this->getApiWrapper()->uploadContent($submission, $xml, $item->getBatchUid(), $locales)) { + if ($this->getApiWrapper()->uploadContent($submission, $xml, $item->batchUid, $locales)) { LiveNotificationController::pushNotification( $profile->getProjectId(), LiveNotificationController::getContentId($submission), @@ -490,11 +491,11 @@ public function bulkSubmit(UploadQueueItem $item): void } while ($e !== null); $e = $caught; $this->getLogger()->error($e->getMessage()); - foreach ($item->getSubmissions() as $submission) { + foreach ($item->submissions as $submission) { $this->getSubmissionManager() ->setErrorMessage($submission, vsprintf('Could not submit because: %s', [$e->getMessage()])); } - $submission = $item->getSubmissions()[0]; + $submission = ($item->submissions)[0]; LiveNotificationController::pushNotification( $profile->getProjectId(), @@ -509,7 +510,7 @@ public function bulkSubmit(UploadQueueItem $item): void public function sendForTranslation(UploadQueueItem $item): void { - foreach ($item->getSubmissions() as $submission) { + foreach ($item->submissions as $submission) { if (1 === $submission->getIsLocked()) { $this->getLogger() ->notice(sprintf('Requested upload of locked submissionId=%s, skipping.', $submission->getId())); @@ -524,16 +525,16 @@ public function sendForTranslation(UploadQueueItem $item): void } $submission->setStatus(SubmissionEntity::SUBMISSION_STATUS_NEW); } - if (count($item->getSubmissions()) === 0) { + if (count($item->submissions) === 0) { $this->getLogger()->debug('No items to send after removing locked submissions'); return; } - $configurationProfile = $this->getSettingsManager()->getSingleSettingsProfile($item->getSubmissions()[0]->getSourceBlogId()); + $configurationProfile = $this->getSettingsManager()->getSingleSettingsProfile(($item->submissions)[0]->getSourceBlogId()); // Mark attachment submission as "Cloned" if there is "Clone attachment" // option is enabled in configuration profile. - foreach ($item->getSubmissions() as $submission) { + foreach ($item->submissions as $submission) { if (1 === $configurationProfile->getCloneAttachment() && $submission->getContentType() === 'attachment') { $submission->setIsCloned(1); $this->getSubmissionManager()->storeEntity($submission); @@ -545,28 +546,28 @@ public function sendForTranslation(UploadQueueItem $item): void $submission->getSourceBlogId(), $submission->getSourceId(), $submission->getContentType(), - $item->getBatchUid(), + $item->batchUid, ) ); $item = $item->removeSubmission($submission); } } - if (count($item->getSubmissions()) === 0) { + if (count($item->submissions) === 0) { $this->getLogger()->debug('No items to send after removing attachments for cloning'); return; } - $submission = $item->getSubmissions()[0]; + $submission = ($item->submissions)[0]; $this->getLogger()->debug( sprintf( 'Preparing to send submissionIds="%s" (sourceBlogId="%s", sourceId="%s", contentType="%s", batchUid="%s").', implode(', ', array_map(static function (SubmissionEntity $submission) { return $submission->getId(); - }, $item->getSubmissions())), + }, $item->submissions)), $submission->getSourceBlogId(), $submission->getSourceId(), $submission->getContentType(), - $item->getBatchUid(), + $item->batchUid, ) ); diff --git a/inc/Smartling/Base/SmartlingEntityAbstract.php b/inc/Smartling/Base/SmartlingEntityAbstract.php index e517840f..1922a54b 100644 --- a/inc/Smartling/Base/SmartlingEntityAbstract.php +++ b/inc/Smartling/Base/SmartlingEntityAbstract.php @@ -8,21 +8,21 @@ abstract class SmartlingEntityAbstract implements SmartlingTableDefinitionInterface { - public const DB_TYPE_INT_MODIFIER_AUTOINCREMENT = 'AUTO_INCREMENT'; - public const DB_TYPE_DEFAULT_ZERO = 'DEFAULT \'0\''; - public const DB_TYPE_DEFAULT_EMPTYSTRING = 'DEFAULT \'\''; + public const string DB_TYPE_INT_MODIFIER_AUTOINCREMENT = 'AUTO_INCREMENT'; + public const string DB_TYPE_DEFAULT_ZERO = 'DEFAULT \'0\''; + public const string DB_TYPE_DEFAULT_EMPTYSTRING = 'DEFAULT \'\''; - public const DB_TYPE_U_BIGINT = 'INT(20) UNSIGNED NOT NULL'; // BIGINT alias of INT(20) - public const DB_TYPE_DATETIME = 'DATETIME NOT NULL DEFAULT \'0000-00-00 00:00:00\''; - public const DB_TYPE_STRING_STANDARD = 'VARCHAR(255) NOT NULL'; - public const DB_TYPE_STRING_64 = 'VARCHAR(64) NOT NULL'; - public const DB_TYPE_STRING_SMALL = 'VARCHAR(16) NOT NULL'; - public const DB_TYPE_UINT_SWITCH = 'INT(1) UNSIGNED NOT NULL DEFAULT \'0\''; - public const DB_TYPE_UINT_SWITCH_ON = 'INT(1) UNSIGNED NOT NULL DEFAULT \'1\''; + public const string DB_TYPE_U_BIGINT = 'INT(20) UNSIGNED NOT NULL'; // BIGINT alias of INT(20) + public const string DB_TYPE_DATETIME = 'DATETIME NOT NULL DEFAULT \'0000-00-00 00:00:00\''; + public const string DB_TYPE_STRING_STANDARD = 'VARCHAR(255) NOT NULL'; + public const string DB_TYPE_STRING_64 = 'VARCHAR(64) NOT NULL'; + public const string DB_TYPE_STRING_SMALL = 'VARCHAR(16) NOT NULL'; + public const string DB_TYPE_UINT_SWITCH = 'INT(1) UNSIGNED NOT NULL DEFAULT \'0\''; + public const string DB_TYPE_UINT_SWITCH_ON = 'INT(1) UNSIGNED NOT NULL DEFAULT \'1\''; - public const DB_TYPE_STRING_TEXT = 'TEXT NOT NULL'; + public const string DB_TYPE_STRING_TEXT = 'TEXT NOT NULL'; - public const DB_TYPE_HASH_MD5 = 'CHAR(32) NOT NULL'; + public const string DB_TYPE_HASH_MD5 = 'CHAR(32) NOT NULL'; /** * @var array */ @@ -187,4 +187,4 @@ static public function getFieldLabel($fieldName) return array_key_exists($fieldName, $labels) ? $labels[$fieldName] : $fieldName; } -} \ No newline at end of file +} diff --git a/inc/Smartling/Bootstrap.php b/inc/Smartling/Bootstrap.php index 1c4c5df3..c53269e1 100644 --- a/inc/Smartling/Bootstrap.php +++ b/inc/Smartling/Bootstrap.php @@ -3,7 +3,6 @@ namespace Smartling; use Exception; -use JetBrains\PhpStorm\NoReturn; use Smartling\Base\ExportedAPI; use Smartling\ContentTypes\AutoDiscover\PostTypes; use Smartling\ContentTypes\AutoDiscover\Taxonomies; @@ -37,7 +36,7 @@ class Bootstrap use DebugTrait; use DITrait; - private const WORDPRESS_ORG_PLUGIN_NAME = 'smartling-connector'; + private const string WORDPRESS_ORG_PLUGIN_NAME = 'smartling-connector'; public static LoggerInterface $loggerInstance; @@ -179,8 +178,7 @@ private function initRoles(): void } } - #[NoReturn] - public function updateGlobalExpertSettings(): void + public function updateGlobalExpertSettings(): never { $data = $_POST['params']; diff --git a/inc/Smartling/ContentProvider.php b/inc/Smartling/ContentProvider.php index 5b2ef4d6..b50185fc 100644 --- a/inc/Smartling/ContentProvider.php +++ b/inc/Smartling/ContentProvider.php @@ -29,7 +29,7 @@ public function __construct( public function getAsset(Content $content): array { - return $this->mapAssetDetails($this->wordpressProxy->get_post($content->getId())); + return $this->mapAssetDetails($this->wordpressProxy->get_post($content->contentId)); } public function getAssets( @@ -64,16 +64,16 @@ public function getContent(Content $assetUid): string { $this->addHandlersForRegisteredTypes(); return $this->core->getXMLFiltered($this->submissionManager->findOne([ - SubmissionEntity::FIELD_CONTENT_TYPE => $assetUid->getType(), + SubmissionEntity::FIELD_CONTENT_TYPE => $assetUid->contentType, SubmissionEntity::FIELD_SOURCE_BLOG_ID => $this->wordpressProxy->get_current_blog_id(), - SubmissionEntity::FIELD_SOURCE_ID => $assetUid->getId(), + SubmissionEntity::FIELD_SOURCE_ID => $assetUid->contentId, ])); } public function getRawContent(Content $assetUid): array { $this->addHandlersForRegisteredTypes(); - $entity = $this->contentHelper->getWrapper($assetUid->getType())->get($assetUid->getId()); + $entity = $this->contentHelper->getWrapper($assetUid->contentType)->get($assetUid->contentId); $result = [ 'entity' => $entity->toArray(), ]; @@ -94,7 +94,7 @@ public function getRelatedAssets( ) { $arguments = [ 'numberposts' => $limit, - 'parent_id' => $assetUid->getId(), + 'parent_id' => $assetUid->contentId, ]; $children = null; while ($childDepth > 0) { diff --git a/inc/Smartling/ContentTypes/ConfigParsers/FieldFilterConfigParser.php b/inc/Smartling/ContentTypes/ConfigParsers/FieldFilterConfigParser.php index 4164f3f1..a238e6e8 100644 --- a/inc/Smartling/ContentTypes/ConfigParsers/FieldFilterConfigParser.php +++ b/inc/Smartling/ContentTypes/ConfigParsers/FieldFilterConfigParser.php @@ -22,12 +22,12 @@ class FieldFilterConfigParser /** * Valid actions */ - private const ACTION_COPY = 'copy'; - private const ACTION_SKIP = 'skip'; - private const ACTION_LOCALIZE = 'localize'; + private const string ACTION_COPY = 'copy'; + private const string ACTION_SKIP = 'skip'; + private const string ACTION_LOCALIZE = 'localize'; - private const VALUE_TYPE_REFERENCE = 'reference'; - private const VALUE_TYPE_URL = 'url'; + private const string VALUE_TYPE_REFERENCE = 'reference'; + private const string VALUE_TYPE_URL = 'url'; private array $actions = [ self::ACTION_COPY, diff --git a/inc/Smartling/ContentTypes/ContentTypeHelper.php b/inc/Smartling/ContentTypes/ContentTypeHelper.php index d5047f12..a29a2d6c 100644 --- a/inc/Smartling/ContentTypes/ContentTypeHelper.php +++ b/inc/Smartling/ContentTypes/ContentTypeHelper.php @@ -4,18 +4,15 @@ use Smartling\Helpers\WordpressFunctionProxyHelper; -class ContentTypeHelper { - - public const POST_TYPE_ATTACHMENT = 'attachment'; - public const CONTENT_TYPE_POST = 'post'; - public const CONTENT_TYPE_TAXONOMY = 'taxonomy'; - public const CONTENT_TYPE_UNKNOWN = 'unknown'; - - private WordpressFunctionProxyHelper $wpProxy; - - public function __construct(WordpressFunctionProxyHelper $wpProxy) +class ContentTypeHelper +{ + public const string POST_TYPE_ATTACHMENT = 'attachment'; + public const string CONTENT_TYPE_POST = 'post'; + public const string CONTENT_TYPE_TAXONOMY = 'taxonomy'; + public const string CONTENT_TYPE_UNKNOWN = 'unknown'; + + public function __construct(private readonly WordpressFunctionProxyHelper $wpProxy) { - $this->wpProxy = $wpProxy; } public function getContentType(string $contentType): string diff --git a/inc/Smartling/ContentTypes/ContentTypeManager.php b/inc/Smartling/ContentTypes/ContentTypeManager.php index 7f6af89f..3832ea41 100644 --- a/inc/Smartling/ContentTypes/ContentTypeManager.php +++ b/inc/Smartling/ContentTypes/ContentTypeManager.php @@ -8,7 +8,7 @@ class ContentTypeManager extends SmartlingFactoryAbstract { - public const VIRTUAL = 'virtual'; + public const string VIRTUAL = 'virtual'; private static array $baseTypes = ['post', 'taxonomy', self::VIRTUAL]; public function __construct(bool $allowDefault = false, ?object $defaultHandler = null) diff --git a/inc/Smartling/ContentTypes/ContentTypeNavigationMenu.php b/inc/Smartling/ContentTypes/ContentTypeNavigationMenu.php index 01b51743..052113be 100644 --- a/inc/Smartling/ContentTypes/ContentTypeNavigationMenu.php +++ b/inc/Smartling/ContentTypes/ContentTypeNavigationMenu.php @@ -7,7 +7,7 @@ class ContentTypeNavigationMenu extends TermBasedContentTypeAbstract { - public const WP_CONTENT_TYPE = 'nav_menu'; + public const string WP_CONTENT_TYPE = 'nav_menu'; public function __construct(ContainerBuilder $di) { diff --git a/inc/Smartling/ContentTypes/ContentTypeNavigationMenuItem.php b/inc/Smartling/ContentTypes/ContentTypeNavigationMenuItem.php index feabae6d..60f030bd 100644 --- a/inc/Smartling/ContentTypes/ContentTypeNavigationMenuItem.php +++ b/inc/Smartling/ContentTypes/ContentTypeNavigationMenuItem.php @@ -14,7 +14,7 @@ class ContentTypeNavigationMenuItem extends PostBasedContentTypeAbstract /** * The system name of Wordpress content type to make references safe. */ - const WP_CONTENT_TYPE = 'nav_menu_item'; + const string WP_CONTENT_TYPE = 'nav_menu_item'; /** * ContentTypeNavigationMenuItem constructor. diff --git a/inc/Smartling/ContentTypes/ContentTypeWidget.php b/inc/Smartling/ContentTypes/ContentTypeWidget.php index 1b5499bc..acb0b730 100644 --- a/inc/Smartling/ContentTypes/ContentTypeWidget.php +++ b/inc/Smartling/ContentTypes/ContentTypeWidget.php @@ -29,7 +29,7 @@ public static function register(ContainerBuilder $di, string $manager = 'content /** * The system name of Wordpress content type to make references safe. */ - const WP_CONTENT_TYPE = 'theme_widget'; + const string WP_CONTENT_TYPE = 'theme_widget'; /** * Wordpress name of content-type, e.g.: post, page, post-tag diff --git a/inc/Smartling/ContentTypes/Elementor/ElementAbstract.php b/inc/Smartling/ContentTypes/Elementor/ElementAbstract.php index 313ab348..4c243f09 100644 --- a/inc/Smartling/ContentTypes/Elementor/ElementAbstract.php +++ b/inc/Smartling/ContentTypes/Elementor/ElementAbstract.php @@ -12,8 +12,8 @@ abstract class ElementAbstract implements Element { use LoggerSafeTrait; - protected const SETTING_KEY_DYNAMIC = '__dynamic__'; - protected const SETTING_KEY_POPUP = 'popup'; + protected const string SETTING_KEY_DYNAMIC = '__dynamic__'; + protected const string SETTING_KEY_POPUP = 'popup'; protected array $elements; protected string $id; @@ -94,9 +94,9 @@ public function setRelations( $result = clone $this; $targetId = $externalContentElementor->getTargetId( $submission->getSourceBlogId(), - $content->getId(), + $content->contentId, $submission->getTargetBlogId(), - $content->getType(), + $content->contentType, ); if ($targetId !== null) { $result->raw = array_replace_recursive( diff --git a/inc/Smartling/ContentTypes/Elementor/ElementFactory.php b/inc/Smartling/ContentTypes/Elementor/ElementFactory.php index 30c9cde0..dd8a251a 100644 --- a/inc/Smartling/ContentTypes/Elementor/ElementFactory.php +++ b/inc/Smartling/ContentTypes/Elementor/ElementFactory.php @@ -3,8 +3,8 @@ namespace Smartling\ContentTypes\Elementor; class ElementFactory { - public const UNKNOWN_ELEMENT = 'unknown'; - private const ELEMENTS = 'Elements'; + public const string UNKNOWN_ELEMENT = 'unknown'; + private const string ELEMENTS = 'Elements'; /** * @var Element[] */ diff --git a/inc/Smartling/ContentTypes/ExternalContentBeaverBuilder.php b/inc/Smartling/ContentTypes/ExternalContentBeaverBuilder.php index 3f3286d2..5be5c051 100644 --- a/inc/Smartling/ContentTypes/ExternalContentBeaverBuilder.php +++ b/inc/Smartling/ContentTypes/ExternalContentBeaverBuilder.php @@ -15,11 +15,11 @@ class ExternalContentBeaverBuilder extends ExternalContentAbstract implements Co { use LoggerSafeTrait; - protected const META_FIELD_NAME = '_fl_builder_data'; - private const META_NODE_PATH_NAME_REGEX = '[0-9a-f]{13}/'; - private const META_NODE_SETTINGS_CHILD_NODE_REGEX = self::META_NODE_SETTINGS_NAME_REGEX . '.+/'; - public const META_NODE_SETTINGS_NAME_REGEX = self::META_NODE_PATH_NAME_REGEX . 'settings/'; - private const META_SETTINGS_NAME = '_fl_builder_data_settings'; + protected const string META_FIELD_NAME = '_fl_builder_data'; + private const string META_NODE_PATH_NAME_REGEX = '[0-9a-f]{13}/'; + private const string META_NODE_SETTINGS_CHILD_NODE_REGEX = self::META_NODE_SETTINGS_NAME_REGEX . '.+/'; + public const string META_NODE_SETTINGS_NAME_REGEX = self::META_NODE_PATH_NAME_REGEX . 'settings/'; + private const string META_SETTINGS_NAME = '_fl_builder_data_settings'; private ContentTypeHelper $contentTypeHelper; diff --git a/inc/Smartling/ContentTypes/ExternalContentElementor.php b/inc/Smartling/ContentTypes/ExternalContentElementor.php index 1915fa54..98919abd 100644 --- a/inc/Smartling/ContentTypes/ExternalContentElementor.php +++ b/inc/Smartling/ContentTypes/ExternalContentElementor.php @@ -23,7 +23,7 @@ class ExternalContentElementor extends ExternalContentAbstract implements Conten { use LoggerSafeTrait; - protected const META_FIELD_NAME = '_elementor_data'; + protected const string META_FIELD_NAME = '_elementor_data'; private array $copyFields = [ '_elementor_controls_usage', diff --git a/inc/Smartling/ContentTypes/ExternalContentGravityForms.php b/inc/Smartling/ContentTypes/ExternalContentGravityForms.php index cfd5a530..9e478ce6 100644 --- a/inc/Smartling/ContentTypes/ExternalContentGravityForms.php +++ b/inc/Smartling/ContentTypes/ExternalContentGravityForms.php @@ -18,7 +18,7 @@ class ExternalContentGravityForms extends ExternalContentAbstract implements ContentTypeModifyingInterface { use LoggerSafeTrait; - public const CONTENT_TYPE = 'gravityforms-form'; + public const string CONTENT_TYPE = 'gravityforms-form'; private ContentTypeHelper $contentTypeHelper; private GravityFormsFormHandler $handler; private GutenbergBlockHelper $gutenbergBlockHelper; diff --git a/inc/Smartling/ContentTypes/ExternalContentYoast.php b/inc/Smartling/ContentTypes/ExternalContentYoast.php index d1757c3c..8021d9bc 100644 --- a/inc/Smartling/ContentTypes/ExternalContentYoast.php +++ b/inc/Smartling/ContentTypes/ExternalContentYoast.php @@ -13,7 +13,7 @@ class ExternalContentYoast extends ExternalContentAbstract implements ContentTypeModifyingInterface { use LoggerSafeTrait; - public const handledFields = [ + public const array handledFields = [ '_yoast_wpseo_focuskeywords', '_yoast_wpseo_keywordsynonyms', ]; diff --git a/inc/Smartling/DbAl/DB.php b/inc/Smartling/DbAl/DB.php index 750091dd..364c1cc9 100644 --- a/inc/Smartling/DbAl/DB.php +++ b/inc/Smartling/DbAl/DB.php @@ -21,7 +21,7 @@ class DB implements SmartlingToCMSDatabaseAccessWrapperInterface, WPInstallableI { use LoggerSafeTrait; - private const SMARTLING_DB_SCHEMA_VERSION = 'smartling_db_ver'; + private const string SMARTLING_DB_SCHEMA_VERSION = 'smartling_db_ver'; /** * @var \wpdb diff --git a/inc/Smartling/DbAl/MultilingualPress2Connector.php b/inc/Smartling/DbAl/MultilingualPress2Connector.php index 0369017b..31258531 100644 --- a/inc/Smartling/DbAl/MultilingualPress2Connector.php +++ b/inc/Smartling/DbAl/MultilingualPress2Connector.php @@ -17,11 +17,11 @@ class MultilingualPress2Connector extends MultilingualPressConnector implements { use LoggerSafeTrait; - public const MULTILINGUAL_PRESS_PRO_SITE_OPTION_KEY_NAME = 'inpsyde_multilingual'; + public const string MULTILINGUAL_PRESS_PRO_SITE_OPTION_KEY_NAME = 'inpsyde_multilingual'; - private const ML_SITE_LINK_TABLE_NAME = 'mlp_site_relations'; - private const ML_CONTENT_LINK_TABLE_NAME = 'multilingual_linked'; - private const UNKNOWN_LOCALE = ''; + private const string ML_SITE_LINK_TABLE_NAME = 'mlp_site_relations'; + private const string ML_CONTENT_LINK_TABLE_NAME = 'multilingual_linked'; + private const string UNKNOWN_LOCALE = ''; /** * @var wpdb diff --git a/inc/Smartling/DbAl/MultilingualPress3Connector.php b/inc/Smartling/DbAl/MultilingualPress3Connector.php index 5f74fc53..7f1ba4c7 100644 --- a/inc/Smartling/DbAl/MultilingualPress3Connector.php +++ b/inc/Smartling/DbAl/MultilingualPress3Connector.php @@ -69,7 +69,7 @@ public function linkObjects(SubmissionEntity $submission): bool public function processSubmissions(UploadQueueItem $item): void { - foreach ($item->getSubmissions() as $submission) { + foreach ($item->submissions as $submission) { $this->linkObjects($submission); } } diff --git a/inc/Smartling/DbAl/SmartlingToCMSDatabaseAccessWrapperInterface.php b/inc/Smartling/DbAl/SmartlingToCMSDatabaseAccessWrapperInterface.php index 18b1bbf9..eb11fba8 100644 --- a/inc/Smartling/DbAl/SmartlingToCMSDatabaseAccessWrapperInterface.php +++ b/inc/Smartling/DbAl/SmartlingToCMSDatabaseAccessWrapperInterface.php @@ -4,8 +4,8 @@ interface SmartlingToCMSDatabaseAccessWrapperInterface { - public const SORT_OPTION_ASC = 'ASC'; - public const SORT_OPTION_DESC = 'DESC'; + public const string SORT_OPTION_ASC = 'ASC'; + public const string SORT_OPTION_DESC = 'DESC'; /** * @return bool|int diff --git a/inc/Smartling/DbAl/UploadQueueManager.php b/inc/Smartling/DbAl/UploadQueueManager.php index 86629932..179cf9a5 100644 --- a/inc/Smartling/DbAl/UploadQueueManager.php +++ b/inc/Smartling/DbAl/UploadQueueManager.php @@ -25,10 +25,10 @@ class UploadQueueManager { use LoggerSafeTrait; private string $tableName; public function __construct( - private ApiWrapperInterface $api, - private SettingsManager $settingsManager, - private SmartlingToCMSDatabaseAccessWrapperInterface $db, - private SubmissionManager $submissionManager, + private readonly ApiWrapperInterface $api, + private readonly SettingsManager $settingsManager, + private readonly SmartlingToCMSDatabaseAccessWrapperInterface $db, + private readonly SubmissionManager $submissionManager, ) { $this->tableName = $db->completeTableName(UploadQueueEntity::TABLE_NAME); } diff --git a/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php b/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php index a976e499..e772bd1d 100644 --- a/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php +++ b/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php @@ -21,10 +21,10 @@ class AcfDynamicSupport { use LoggerSafeTrait; - public const REFERENCED_TYPE_NONE = 'none'; - public const REFERENCED_TYPE_MEDIA = 'media'; - public const REFERENCED_TYPE_POST = 'post'; - public const REFERENCED_TYPE_TAXONOMY = 'taxonomy'; + public const string REFERENCED_TYPE_NONE = 'none'; + public const string REFERENCED_TYPE_MEDIA = 'media'; + public const string REFERENCED_TYPE_POST = 'post'; + public const string REFERENCED_TYPE_TAXONOMY = 'taxonomy'; public static array $acfReverseDefinitionAction = []; diff --git a/inc/Smartling/Extensions/Acf/AcfTypeDetector.php b/inc/Smartling/Extensions/Acf/AcfTypeDetector.php index 9e93270c..6b5be7bc 100644 --- a/inc/Smartling/Extensions/Acf/AcfTypeDetector.php +++ b/inc/Smartling/Extensions/Acf/AcfTypeDetector.php @@ -12,7 +12,7 @@ class AcfTypeDetector { - public const ACF_FIELD_GROUP_REGEX = '#(field|group)_([0-9a-f]){13}#'; + public const string ACF_FIELD_GROUP_REGEX = '#(field|group)_([0-9a-f]){13}#'; /** * Default cache time (1 day) * @var int diff --git a/inc/Smartling/Extensions/AcfOptionPages/AcfOptionHelper.php b/inc/Smartling/Extensions/AcfOptionPages/AcfOptionHelper.php index 080ec980..5b7d85b3 100644 --- a/inc/Smartling/Extensions/AcfOptionPages/AcfOptionHelper.php +++ b/inc/Smartling/Extensions/AcfOptionPages/AcfOptionHelper.php @@ -9,7 +9,7 @@ */ class AcfOptionHelper { - const ACF_OPTION_KEY_MAP = 'smartling_acf_option_key_map'; + const string ACF_OPTION_KEY_MAP = 'smartling_acf_option_key_map'; /** * @var int diff --git a/inc/Smartling/Extensions/AcfOptionPages/ContentTypeAcfOption.php b/inc/Smartling/Extensions/AcfOptionPages/ContentTypeAcfOption.php index c0a04d67..3a16803c 100644 --- a/inc/Smartling/Extensions/AcfOptionPages/ContentTypeAcfOption.php +++ b/inc/Smartling/Extensions/AcfOptionPages/ContentTypeAcfOption.php @@ -9,7 +9,7 @@ class ContentTypeAcfOption extends ContentTypeAbstract { - public const WP_CONTENT_TYPE = 'acf_options'; + public const string WP_CONTENT_TYPE = 'acf_options'; public function getSystemName(): string { @@ -62,4 +62,4 @@ public function isVirtual(): bool { return true; } -} \ No newline at end of file +} diff --git a/inc/Smartling/Extensions/Pluggable.php b/inc/Smartling/Extensions/Pluggable.php index f5a14e47..59e8c529 100644 --- a/inc/Smartling/Extensions/Pluggable.php +++ b/inc/Smartling/Extensions/Pluggable.php @@ -5,9 +5,9 @@ use JetBrains\PhpStorm\ExpectedValues; interface Pluggable { - public const NOT_SUPPORTED = 'not_supported'; - public const SUPPORTED = 'supported'; - public const VERSION_NOT_SUPPORTED = 'version_not_supported'; + public const string NOT_SUPPORTED = 'not_supported'; + public const string SUPPORTED = 'supported'; + public const string VERSION_NOT_SUPPORTED = 'version_not_supported'; public function getMaxVersion(): string; diff --git a/inc/Smartling/Helpers/AbsoluteLinkedAttachmentCoreHelper.php b/inc/Smartling/Helpers/AbsoluteLinkedAttachmentCoreHelper.php index 4023b341..b92c203a 100644 --- a/inc/Smartling/Helpers/AbsoluteLinkedAttachmentCoreHelper.php +++ b/inc/Smartling/Helpers/AbsoluteLinkedAttachmentCoreHelper.php @@ -11,7 +11,7 @@ class AbsoluteLinkedAttachmentCoreHelper extends RelativeLinkedAttachmentCoreHelper { - private const PATTERN_LINK_GENERAL = ']+>'; + private const string PATTERN_LINK_GENERAL = ']+>'; private function isAbsoluteUrl(string $url): bool { diff --git a/inc/Smartling/Helpers/AdminNoticesHelper.php b/inc/Smartling/Helpers/AdminNoticesHelper.php index 95812d93..49f739db 100644 --- a/inc/Smartling/Helpers/AdminNoticesHelper.php +++ b/inc/Smartling/Helpers/AdminNoticesHelper.php @@ -6,7 +6,7 @@ class AdminNoticesHelper implements WPHookInterface { - public const OPTION_NAME = 'smartling_notices'; + public const string OPTION_NAME = 'smartling_notices'; public function register(): void { diff --git a/inc/Smartling/Helpers/ArrayHelper.php b/inc/Smartling/Helpers/ArrayHelper.php index 878543ca..ab4c41f7 100644 --- a/inc/Smartling/Helpers/ArrayHelper.php +++ b/inc/Smartling/Helpers/ArrayHelper.php @@ -6,7 +6,7 @@ class ArrayHelper { - private const NESTED_KEY_SEPARATOR = '.'; + private const string NESTED_KEY_SEPARATOR = '.'; /** * Retrieves the value of an array element or object property with the given key or property name. diff --git a/inc/Smartling/Helpers/AttachmentHelper.php b/inc/Smartling/Helpers/AttachmentHelper.php index df4f011e..3b8d06a4 100644 --- a/inc/Smartling/Helpers/AttachmentHelper.php +++ b/inc/Smartling/Helpers/AttachmentHelper.php @@ -10,10 +10,10 @@ */ class AttachmentHelper { - const FILE_NOT_COPIED = 'Cannot copy source file.'; - const CANNOT_ACCESS_SOURCE_FILE = 'Cannot access source file.'; - const CANNOT_PREPARE_TARGET_PATH = 'Cannot prepare target path.'; - const CANNOT_OVERWRITE_EXISTING_FILE = 'Cannot overwrite existing file.'; + const string FILE_NOT_COPIED = 'Cannot copy source file.'; + const string CANNOT_ACCESS_SOURCE_FILE = 'Cannot access source file.'; + const string CANNOT_PREPARE_TARGET_PATH = 'Cannot prepare target path.'; + const string CANNOT_OVERWRITE_EXISTING_FILE = 'Cannot overwrite existing file.'; public static function checkIfTargetFileExists($originalFile, $targetPath) { $targetFileName = pathinfo($originalFile, PATHINFO_BASENAME); @@ -92,4 +92,4 @@ private static function buildPath($path) return is_dir($pathDir); } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/CustomMenuContentTypeHelper.php b/inc/Smartling/Helpers/CustomMenuContentTypeHelper.php index b36865b0..53b9ea7d 100644 --- a/inc/Smartling/Helpers/CustomMenuContentTypeHelper.php +++ b/inc/Smartling/Helpers/CustomMenuContentTypeHelper.php @@ -16,7 +16,7 @@ class CustomMenuContentTypeHelper /** * Wordpress meta_key name for nav_menu_item content type. */ - public const META_KEY_MENU_ITEM_PARENT = '_menu_item_menu_item_parent'; + public const string META_KEY_MENU_ITEM_PARENT = '_menu_item_menu_item_parent'; private ContentEntitiesIOFactory $contentIoFactory; private SiteHelper $siteHelper; @@ -24,7 +24,7 @@ class CustomMenuContentTypeHelper public function __construct(ContentEntitiesIOFactory $contentIoFactory, SiteHelper $siteHelper) { $this->contentIoFactory = $contentIoFactory; - $this->siteHelper = $siteHelper; + $this->siteHelper = $siteHelper; } /** diff --git a/inc/Smartling/Helpers/DateTimeHelper.php b/inc/Smartling/Helpers/DateTimeHelper.php index c33d1be0..797da039 100644 --- a/inc/Smartling/Helpers/DateTimeHelper.php +++ b/inc/Smartling/Helpers/DateTimeHelper.php @@ -16,7 +16,7 @@ class DateTimeHelper /** * UTC Timezone */ - const TIMEZONE_UTC = 'UTC'; + const string TIMEZONE_UTC = 'UTC'; /** * @var DateTimeZone @@ -41,9 +41,9 @@ class DateTimeHelper /** * Default format string for DateTime */ - const DATE_TIME_FORMAT_STANDARD = 'Y-m-d H:i:s'; + const string DATE_TIME_FORMAT_STANDARD = 'Y-m-d H:i:s'; - const DATE_TIME_FORMAT_JOB = 'Y-m-d H:i'; + const string DATE_TIME_FORMAT_JOB = 'Y-m-d H:i'; /** * Sets default timezone for conversion operations @@ -188,4 +188,4 @@ public static function toWordpressLocalDateTime(DateTime $dateTime) return $o->format(static::getWordpressDateTimeFormat()); } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/FieldsFilterHelper.php b/inc/Smartling/Helpers/FieldsFilterHelper.php index ac8162bf..46afda5e 100644 --- a/inc/Smartling/Helpers/FieldsFilterHelper.php +++ b/inc/Smartling/Helpers/FieldsFilterHelper.php @@ -20,11 +20,11 @@ class FieldsFilterHelper { use LoggerSafeTrait; - public const ARRAY_DIVIDER = '/'; + public const string ARRAY_DIVIDER = '/'; - private const FILTER_STRATEGY_UPLOAD = 'upload'; + private const string FILTER_STRATEGY_UPLOAD = 'upload'; - private const FILTER_STRATEGY_DOWNLOAD = 'download'; + private const string FILTER_STRATEGY_DOWNLOAD = 'download'; public function __construct( private AcfDynamicSupport $acfDynamicSupport, diff --git a/inc/Smartling/Helpers/FileUriHelper.php b/inc/Smartling/Helpers/FileUriHelper.php index a07f26dc..23de7288 100644 --- a/inc/Smartling/Helpers/FileUriHelper.php +++ b/inc/Smartling/Helpers/FileUriHelper.php @@ -16,9 +16,9 @@ class FileUriHelper { use LoggerSafeTrait; - private const FILE_URI_FORMAT = '%s_%s_%s_%s.xml'; - private const MAX_PERMALINK_LENGTH = 210; - private const UNTITLED = 'UNTITLED'; + private const string FILE_URI_FORMAT = '%s_%s_%s_%s.xml'; + private const int MAX_PERMALINK_LENGTH = 210; + private const string UNTITLED = 'UNTITLED'; public function __construct( private ContentEntitiesIOFactory $ioFactory, diff --git a/inc/Smartling/Helpers/GutenbergBlockHelper.php b/inc/Smartling/Helpers/GutenbergBlockHelper.php index 8ccdd7d7..8a321493 100644 --- a/inc/Smartling/Helpers/GutenbergBlockHelper.php +++ b/inc/Smartling/Helpers/GutenbergBlockHelper.php @@ -22,11 +22,11 @@ class GutenbergBlockHelper extends SubstringProcessorHelperAbstract { - protected const BLOCK_NODE_NAME = 'gutenbergBlock'; - protected const CHUNK_NODE_NAME = 'contentChunk'; - protected const ATTRIBUTE_NODE_NAME = 'blockAttribute'; - private const CDATA_SECTION_NODE_NAME = '#cdata-section'; - private const MAX_NODE_DEPTH = 10; + protected const string BLOCK_NODE_NAME = 'gutenbergBlock'; + protected const string CHUNK_NODE_NAME = 'contentChunk'; + protected const string ATTRIBUTE_NODE_NAME = 'blockAttribute'; + private const string CDATA_SECTION_NODE_NAME = '#cdata-section'; + private const int MAX_NODE_DEPTH = 10; public function __construct( private AcfDynamicSupport $acfDynamicSupport, diff --git a/inc/Smartling/Helpers/GutenbergReplacementRule.php b/inc/Smartling/Helpers/GutenbergReplacementRule.php index 4ef8739b..ef3fed72 100644 --- a/inc/Smartling/Helpers/GutenbergReplacementRule.php +++ b/inc/Smartling/Helpers/GutenbergReplacementRule.php @@ -4,7 +4,7 @@ class GutenbergReplacementRule { - private const STRING_FORMAT = 'blockType="%s", propertyPath="%s", replacerId="%s"'; + private const string STRING_FORMAT = 'blockType="%s", propertyPath="%s", replacerId="%s"'; private string $blockType; private string $propertyPath; private string $replacerId; diff --git a/inc/Smartling/Helpers/PlaceholderHelper.php b/inc/Smartling/Helpers/PlaceholderHelper.php index 5ce8ddda..f059e34e 100755 --- a/inc/Smartling/Helpers/PlaceholderHelper.php +++ b/inc/Smartling/Helpers/PlaceholderHelper.php @@ -4,8 +4,8 @@ class PlaceholderHelper { - public const SMARTLING_PLACEHOLDER_MASK_START = '#sl-start#'; - public const SMARTLING_PLACEHOLDER_MASK_END = '#sl-end#'; + public const string SMARTLING_PLACEHOLDER_MASK_START = '#sl-start#'; + public const string SMARTLING_PLACEHOLDER_MASK_END = '#sl-end#'; public function addPlaceholders(string $string): string { diff --git a/inc/Smartling/Helpers/PostContentHelper.php b/inc/Smartling/Helpers/PostContentHelper.php index ee6e5d36..02e31490 100644 --- a/inc/Smartling/Helpers/PostContentHelper.php +++ b/inc/Smartling/Helpers/PostContentHelper.php @@ -9,9 +9,9 @@ class PostContentHelper { use LoggerSafeTrait; - public const SMARTLING_LOCK_ID = 'smartlingLockId'; - public const SMARTLING_LOCKED = 'smartlingLocked'; - public const SMARTLING_LOCKED_ATTRIBUTES = 'smartlingLockedAttributes'; + public const string SMARTLING_LOCK_ID = 'smartlingLockId'; + public const string SMARTLING_LOCKED = 'smartlingLocked'; + public const string SMARTLING_LOCKED_ATTRIBUTES = 'smartlingLockedAttributes'; public function __construct(private ArrayHelper $arrayHelper, private GutenbergBlockHelper $blockHelper) { diff --git a/inc/Smartling/Helpers/QueryBuilder/Condition/ConditionBuilder.php b/inc/Smartling/Helpers/QueryBuilder/Condition/ConditionBuilder.php index 940b9deb..421ebb5f 100644 --- a/inc/Smartling/Helpers/QueryBuilder/Condition/ConditionBuilder.php +++ b/inc/Smartling/Helpers/QueryBuilder/Condition/ConditionBuilder.php @@ -14,72 +14,72 @@ class ConditionBuilder /** * const for '=' */ - const CONDITION_SIGN_EQ = '%s = \'%s\''; + const string CONDITION_SIGN_EQ = '%s = \'%s\''; /** * const for '<>' */ - const CONDITION_SIGN_NOT_EQ = '%s <> \'%s\''; + const string CONDITION_SIGN_NOT_EQ = '%s <> \'%s\''; /** * const for '>' */ - const CONDITION_SIGN_MORE = '%s > \'%s\''; + const string CONDITION_SIGN_MORE = '%s > \'%s\''; /** * const for '>=' */ - const CONDITION_SIGN_MORE_OR_EQ = '%s >= \'%s\''; + const string CONDITION_SIGN_MORE_OR_EQ = '%s >= \'%s\''; /** * const for '<' */ - const CONDITION_SIGN_LESS = '%s < \'%s\''; + const string CONDITION_SIGN_LESS = '%s < \'%s\''; /** * const for '<=' */ - const CONDITION_SIGN_LESS_OR_EQ = '%s <= \'%s\''; + const string CONDITION_SIGN_LESS_OR_EQ = '%s <= \'%s\''; /** * const for 'BETWEEN */ - const CONDITION_SIGN_BETWEEN = '%s BETWEEN \'%s\' AND \'%s\''; + const string CONDITION_SIGN_BETWEEN = '%s BETWEEN \'%s\' AND \'%s\''; /** * const for 'LIKE' */ - const CONDITION_SIGN_LIKE = '%s LIKE \'%s\''; + const string CONDITION_SIGN_LIKE = '%s LIKE \'%s\''; /** * const for 'IN' */ - const CONDITION_SIGN_IN = '%s IN(%s)'; + const string CONDITION_SIGN_IN = '%s IN(%s)'; /** * const for 'NOT IN' */ - const CONDITION_SIGN_NOT_IN = '%s NOT IN(%s)'; + const string CONDITION_SIGN_NOT_IN = '%s NOT IN(%s)'; /** * const for 'IS NULL' */ - const CONDITION_IS_NULL = '%s IS NULL'; + const string CONDITION_IS_NULL = '%s IS NULL'; /** * const for 'NOT IS NULL' */ - const CONDITION_IS_NOT_NULL = '%s IS NOT NULL'; + const string CONDITION_IS_NOT_NULL = '%s IS NOT NULL'; /** * const for 'AND' */ - const CONDITION_BLOCK_LEVEL_OPERATOR_AND = 'AND'; + const string CONDITION_BLOCK_LEVEL_OPERATOR_AND = 'AND'; /** * const for 'OR' */ - const CONDITION_BLOCK_LEVEL_OPERATOR_OR = 'OR'; + const string CONDITION_BLOCK_LEVEL_OPERATOR_OR = 'OR'; /** * @param $condition @@ -172,4 +172,4 @@ private static function validateParametersCount($condition, $parameters) return count($parameters) === preg_match_all('|(%s)|ius', $condition, $match); } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/QueryBuilder/QueryBuilder.php b/inc/Smartling/Helpers/QueryBuilder/QueryBuilder.php index b4d605e9..9be99307 100644 --- a/inc/Smartling/Helpers/QueryBuilder/QueryBuilder.php +++ b/inc/Smartling/Helpers/QueryBuilder/QueryBuilder.php @@ -11,7 +11,7 @@ class QueryBuilder /** * Exception code for empty field list */ - const EXCEPTION_CODE_EMPTY_FIELD_LIST = 4; + const int EXCEPTION_CODE_EMPTY_FIELD_LIST = 4; /** diff --git a/inc/Smartling/Helpers/RelativeLinkedAttachmentCoreHelper.php b/inc/Smartling/Helpers/RelativeLinkedAttachmentCoreHelper.php index f32b0063..a9e415d1 100644 --- a/inc/Smartling/Helpers/RelativeLinkedAttachmentCoreHelper.php +++ b/inc/Smartling/Helpers/RelativeLinkedAttachmentCoreHelper.php @@ -17,15 +17,15 @@ class RelativeLinkedAttachmentCoreHelper implements WPHookInterface { use LoggerSafeTrait; - private const ACF_GUTENBERG_BLOCK = ''; + private const string ACF_GUTENBERG_BLOCK = ''; /** * RegEx to catch images from the string */ - protected const PATTERN_IMAGE_GENERAL = ']+>'; + protected const string PATTERN_IMAGE_GENERAL = ']+>'; private const PATTERN_LINK_GENERAL = ']+>'; - protected const PATTERN_THUMBNAIL_IDENTITY = '-\d+x\d+$'; + protected const string PATTERN_THUMBNAIL_IDENTITY = '-\d+x\d+$'; private array $acfDefinitions = []; private AfterDeserializeContentEventParameters $params; diff --git a/inc/Smartling/Helpers/RuntimeCacheHelper.php b/inc/Smartling/Helpers/RuntimeCacheHelper.php index a824a5eb..e50a3bed 100644 --- a/inc/Smartling/Helpers/RuntimeCacheHelper.php +++ b/inc/Smartling/Helpers/RuntimeCacheHelper.php @@ -9,7 +9,7 @@ */ class RuntimeCacheHelper { - const DEFAULT_SCOPE = 'default'; + const string DEFAULT_SCOPE = 'default'; /** * @var RuntimeCacheHelper @@ -54,4 +54,4 @@ public function set($key, $value, $scope = self::DEFAULT_SCOPE) { $this->storage[$scope][$key] = $value; } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/ShortcodeHelper.php b/inc/Smartling/Helpers/ShortcodeHelper.php index 592afb06..aaec7311 100755 --- a/inc/Smartling/Helpers/ShortcodeHelper.php +++ b/inc/Smartling/Helpers/ShortcodeHelper.php @@ -10,8 +10,8 @@ class ShortcodeHelper extends SubstringProcessorHelperAbstract { - private const SMARTLING_SHORTCODE_MASK_OLD = '##'; - private const SHORTCODE_SUBSTRING_NODE_NAME = 'shortcodeattribute'; + private const string SMARTLING_SHORTCODE_MASK_OLD = '##'; + private const string SHORTCODE_SUBSTRING_NODE_NAME = 'shortcodeattribute'; public function __construct( ContentSerializationHelper $contentSerializationHelper, @@ -445,4 +445,4 @@ public function renderString($string): string } return $string; } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/SmartlingUserCapabilities.php b/inc/Smartling/Helpers/SmartlingUserCapabilities.php index 3347277c..65a394eb 100644 --- a/inc/Smartling/Helpers/SmartlingUserCapabilities.php +++ b/inc/Smartling/Helpers/SmartlingUserCapabilities.php @@ -8,15 +8,15 @@ */ class SmartlingUserCapabilities { - const SMARTLING_CAPABILITY_MENU_CAP = 'smartling_connector_menu_cap'; + const string SMARTLING_CAPABILITY_MENU_CAP = 'smartling_connector_menu_cap'; - const SMARTLING_CAPABILITY_PROFILE_CAP = 'smartling_connector_profile_cap'; + const string SMARTLING_CAPABILITY_PROFILE_CAP = 'smartling_connector_profile_cap'; - const SMARTLING_CAPABILITY_WIDGET_CAP = 'smartling_connector_widget_cap'; + const string SMARTLING_CAPABILITY_WIDGET_CAP = 'smartling_connector_widget_cap'; public static $CAPABILITY = [ self::SMARTLING_CAPABILITY_WIDGET_CAP, self::SMARTLING_CAPABILITY_PROFILE_CAP, self::SMARTLING_CAPABILITY_MENU_CAP, ]; -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/StringHelper.php b/inc/Smartling/Helpers/StringHelper.php index 6a4509f7..f85d0fab 100644 --- a/inc/Smartling/Helpers/StringHelper.php +++ b/inc/Smartling/Helpers/StringHelper.php @@ -4,7 +4,7 @@ class StringHelper { - private const EMPTY_STRING = ''; + private const string EMPTY_STRING = ''; /** * @param mixed $value diff --git a/inc/Smartling/Helpers/TestRunHelper.php b/inc/Smartling/Helpers/TestRunHelper.php index 18f41229..b787d886 100644 --- a/inc/Smartling/Helpers/TestRunHelper.php +++ b/inc/Smartling/Helpers/TestRunHelper.php @@ -8,7 +8,7 @@ class TestRunHelper { - public const TEST_RUN_BLOG_ID_SETTING_NAME = 'smartling_TestRunBlogId'; + public const string TEST_RUN_BLOG_ID_SETTING_NAME = 'smartling_TestRunBlogId'; private SiteHelper $siteHelper; private GutenbergBlockHelper $gutenbergBlockHelper; diff --git a/inc/Smartling/Helpers/ThemeSidebarHelper.php b/inc/Smartling/Helpers/ThemeSidebarHelper.php index f54b084b..341039da 100644 --- a/inc/Smartling/Helpers/ThemeSidebarHelper.php +++ b/inc/Smartling/Helpers/ThemeSidebarHelper.php @@ -10,7 +10,7 @@ class ThemeSidebarHelper { - const INACTIVE_BAR_ID = 'wp_inactive_widgets'; + const string INACTIVE_BAR_ID = 'wp_inactive_widgets'; /** * @return array @@ -44,4 +44,4 @@ public static function getSideBarLabel($sideBarId, $default = '') } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/UiMessageHelper.php b/inc/Smartling/Helpers/UiMessageHelper.php index 73bde906..cedaad80 100644 --- a/inc/Smartling/Helpers/UiMessageHelper.php +++ b/inc/Smartling/Helpers/UiMessageHelper.php @@ -4,8 +4,8 @@ class UiMessageHelper { - private const CACHE_KEY_PREFIX = 'smartling.ui.message.'; - public const DISMISS_MESSAGE_ACTION = 'smartling_dismiss_message'; + private const string CACHE_KEY_PREFIX = 'smartling.ui.message.'; + public const string DISMISS_MESSAGE_ACTION = 'smartling_dismiss_message'; public static function dismissMessage(): void { diff --git a/inc/Smartling/Helpers/UserHelper.php b/inc/Smartling/Helpers/UserHelper.php index 6f850bb2..c100f48e 100644 --- a/inc/Smartling/Helpers/UserHelper.php +++ b/inc/Smartling/Helpers/UserHelper.php @@ -9,8 +9,8 @@ class UserHelper { use LoggerSafeTrait; - private const ADMINISTRATOR = 'administrator'; - private const EDITOR = 'editor'; + private const string ADMINISTRATOR = 'administrator'; + private const string EDITOR = 'editor'; public function __construct( private SmartlingToCMSDatabaseAccessWrapperInterface $db, diff --git a/inc/Smartling/Helpers/WidgetHelper.php b/inc/Smartling/Helpers/WidgetHelper.php index 5faa7304..1c411b4d 100644 --- a/inc/Smartling/Helpers/WidgetHelper.php +++ b/inc/Smartling/Helpers/WidgetHelper.php @@ -12,7 +12,7 @@ class WidgetHelper /** * key for generated IDs */ - const SMARTLING_IDENTITY_FIELD_NAME = 'smartlingId'; + const string SMARTLING_IDENTITY_FIELD_NAME = 'smartlingId'; /** * @var integer @@ -384,4 +384,4 @@ public function toArray() 'settings' => $this->getSettings(), ]; } -} \ No newline at end of file +} diff --git a/inc/Smartling/Helpers/WpObjectCache.php b/inc/Smartling/Helpers/WpObjectCache.php index ac09377e..b77d4677 100644 --- a/inc/Smartling/Helpers/WpObjectCache.php +++ b/inc/Smartling/Helpers/WpObjectCache.php @@ -3,7 +3,7 @@ namespace Smartling\Helpers; class WpObjectCache implements Cache { - private const GROUP = "smartling"; + private const string GROUP = "smartling"; public function delete(string $key): bool { diff --git a/inc/Smartling/Helpers/WpTransientCache.php b/inc/Smartling/Helpers/WpTransientCache.php index 69d337a4..7bb93c5f 100644 --- a/inc/Smartling/Helpers/WpTransientCache.php +++ b/inc/Smartling/Helpers/WpTransientCache.php @@ -3,7 +3,7 @@ namespace Smartling\Helpers; class WpTransientCache implements Cache { - private const DEFAULT_EXPIRATION = 86400; + private const int DEFAULT_EXPIRATION = 86400; public function delete(string $key): bool { diff --git a/inc/Smartling/Helpers/XmlHelper.php b/inc/Smartling/Helpers/XmlHelper.php index b6a075d6..d0ee256f 100644 --- a/inc/Smartling/Helpers/XmlHelper.php +++ b/inc/Smartling/Helpers/XmlHelper.php @@ -26,11 +26,11 @@ public function __construct( ) { } - const XML_ROOT_NODE_NAME = 'data'; + const string XML_ROOT_NODE_NAME = 'data'; - private const XML_STRING_NODE_NAME = 'string'; + private const string XML_STRING_NODE_NAME = 'string'; - private const XML_SOURCE_NODE_NAME = 'source'; + private const string XML_SOURCE_NODE_NAME = 'source'; private function initXml(): DOMDocument { diff --git a/inc/Smartling/Jobs/DownloadTranslationJob.php b/inc/Smartling/Jobs/DownloadTranslationJob.php index 8e079372..8e1b1e83 100644 --- a/inc/Smartling/Jobs/DownloadTranslationJob.php +++ b/inc/Smartling/Jobs/DownloadTranslationJob.php @@ -12,7 +12,7 @@ class DownloadTranslationJob extends JobAbstract { - public const JOB_HOOK_NAME = 'smartling-download-task'; + public const string JOB_HOOK_NAME = 'smartling-download-task'; public function __construct( ApiWrapperInterface $api, diff --git a/inc/Smartling/Jobs/JobAbstract.php b/inc/Smartling/Jobs/JobAbstract.php index f25bc4dd..b5f8e63b 100644 --- a/inc/Smartling/Jobs/JobAbstract.php +++ b/inc/Smartling/Jobs/JobAbstract.php @@ -21,9 +21,9 @@ abstract class JobAbstract implements WPHookInterface, JobInterface, WPInstallab { use LoggerSafeTrait; - public const LAST_FINISH_SUFFIX = '-last-run'; - public const SOURCE_USER = 'user'; - private const THROTTLED_MESSAGE = "Throttled"; + public const string LAST_FINISH_SUFFIX = '-last-run'; + public const string SOURCE_USER = 'user'; + private const string THROTTLED_MESSAGE = "Throttled"; public function __construct( protected ApiWrapperInterface $api, diff --git a/inc/Smartling/Jobs/JobEntity.php b/inc/Smartling/Jobs/JobEntity.php index ba2e404c..a459b229 100644 --- a/inc/Smartling/Jobs/JobEntity.php +++ b/inc/Smartling/Jobs/JobEntity.php @@ -7,12 +7,12 @@ class JobEntity implements SmartlingTableDefinitionInterface { - public const FIELD_CREATED = 'created'; - public const FIELD_ID = 'id'; - public const FIELD_JOB_NAME = 'job_name'; - public const FIELD_JOB_UID = 'job_uid'; - public const FIELD_MODIFIED = 'modified'; - public const FIELD_PROJECT_UID = 'project_uid'; + public const string FIELD_CREATED = 'created'; + public const string FIELD_ID = 'id'; + public const string FIELD_JOB_NAME = 'job_name'; + public const string FIELD_JOB_UID = 'job_uid'; + public const string FIELD_MODIFIED = 'modified'; + public const string FIELD_PROJECT_UID = 'project_uid'; private \DateTime $created; private ?int $id; diff --git a/inc/Smartling/Jobs/LastModifiedCheckJob.php b/inc/Smartling/Jobs/LastModifiedCheckJob.php index 8706d99d..a2c80f7a 100644 --- a/inc/Smartling/Jobs/LastModifiedCheckJob.php +++ b/inc/Smartling/Jobs/LastModifiedCheckJob.php @@ -15,7 +15,7 @@ class LastModifiedCheckJob extends JobAbstract { - public const JOB_HOOK_NAME = 'smartling-last-modified-check-task'; + public const string JOB_HOOK_NAME = 'smartling-last-modified-check-task'; public function __construct( ApiWrapperInterface $api, diff --git a/inc/Smartling/Jobs/SubmissionCollectorJob.php b/inc/Smartling/Jobs/SubmissionCollectorJob.php index 84f84e57..9af7f4ef 100644 --- a/inc/Smartling/Jobs/SubmissionCollectorJob.php +++ b/inc/Smartling/Jobs/SubmissionCollectorJob.php @@ -13,7 +13,7 @@ class SubmissionCollectorJob extends JobAbstract { - public const JOB_HOOK_NAME = 'smartling-submission-collector-task'; + public const string JOB_HOOK_NAME = 'smartling-submission-collector-task'; public function __construct( ApiWrapperInterface $api, diff --git a/inc/Smartling/Jobs/SubmissionJobEntity.php b/inc/Smartling/Jobs/SubmissionJobEntity.php index 36c0fc46..f0224fd7 100644 --- a/inc/Smartling/Jobs/SubmissionJobEntity.php +++ b/inc/Smartling/Jobs/SubmissionJobEntity.php @@ -7,11 +7,11 @@ class SubmissionJobEntity implements SmartlingTableDefinitionInterface { - public const FIELD_CREATED = 'created'; - public const FIELD_ID = 'id'; - public const FIELD_JOB_ID = 'job_id'; - public const FIELD_MODIFIED = 'modified'; - public const FIELD_SUBMISSION_ID = 'submission_id'; + public const string FIELD_CREATED = 'created'; + public const string FIELD_ID = 'id'; + public const string FIELD_JOB_ID = 'job_id'; + public const string FIELD_MODIFIED = 'modified'; + public const string FIELD_SUBMISSION_ID = 'submission_id'; private \DateTime $created; private ?int $id; diff --git a/inc/Smartling/Jobs/UploadJob.php b/inc/Smartling/Jobs/UploadJob.php index 196217a5..78f859c4 100644 --- a/inc/Smartling/Jobs/UploadJob.php +++ b/inc/Smartling/Jobs/UploadJob.php @@ -8,12 +8,14 @@ use Smartling\Exception\SmartlingDbException; use Smartling\Helpers\Cache; use Smartling\Helpers\FileUriHelper; +use Smartling\Models\UploadQueueItem; use Smartling\Settings\SettingsManager; +use Smartling\Submissions\SubmissionEntity; use Smartling\Submissions\SubmissionManager; class UploadJob extends JobAbstract { - public const JOB_HOOK_NAME = 'smartling-upload-task'; + public const string JOB_HOOK_NAME = 'smartling-upload-task'; public function __construct( ApiWrapperInterface $api, @@ -54,7 +56,7 @@ private function processUploadQueue(): void { $profiles = []; while (($item = $this->uploadQueueManager->dequeue()) !== null) { - $submission = $item->getSubmissions()[0]; + $submission = ($item->submissions)[0]; if ($submission->getFileUri() === '') { $submission->setFileUri($this->fileUriHelper->generateFileUri($submission)); $this->submissionManager->storeEntity($submission); @@ -68,7 +70,7 @@ private function processUploadQueue(): void } } $profile = $profiles[$submission->getSourceBlogId()]; - if ($item->getBatchUid() === '') { + if ($item->batchUid === '') { $item = $item->setBatchUid($this->api->getOrCreateJobInfoForDailyBucketJob($profile, [$submission->getFileUri()])->getBatchUid()); } @@ -81,13 +83,13 @@ private function processUploadQueue(): void $submission->getSourceId(), $submission->getTargetBlogId(), $submission->getTargetLocale(), - $item->getBatchUid(), + $item->batchUid, )); try { do_action(ExportedAPI::ACTION_SMARTLING_SEND_FOR_TRANSLATION, $item); } catch (\Exception $e) { - foreach ($item->getSubmissions() as $submission) { + foreach ($item->submissions as $submission) { $this->getLogger()->notice(sprintf('Failing submissionId=%s: %s', $submission->getId(), $e->getMessage())); $this->submissionManager->setErrorMessage($submission, $e->getMessage()); } diff --git a/inc/Smartling/Models/Content.php b/inc/Smartling/Models/Content.php index bbe4a89b..8375428e 100644 --- a/inc/Smartling/Models/Content.php +++ b/inc/Smartling/Models/Content.php @@ -2,20 +2,10 @@ namespace Smartling\Models; -class Content { +readonly class Content { public function __construct( - private int $contentId, - private string $contentType, + public int $contentId, + public string $contentType, ) { } - - public function getId(): int - { - return $this->contentId; - } - - public function getType(): string - { - return $this->contentType; - } } diff --git a/inc/Smartling/Models/DetectedRelations.php b/inc/Smartling/Models/DetectedRelations.php index bb569558..763e7141 100644 --- a/inc/Smartling/Models/DetectedRelations.php +++ b/inc/Smartling/Models/DetectedRelations.php @@ -4,14 +4,12 @@ class DetectedRelations { - public const ORIGINAL_REFERENCES_KEY = 'originalReferences'; - public const MISSING_TRANSLATED_REFERENCES_KEY = 'missingTranslatedReferences'; - private array $originalReferences; + public const string ORIGINAL_REFERENCES_KEY = 'originalReferences'; + public const string MISSING_TRANSLATED_REFERENCES_KEY = 'missingTranslatedReferences'; private array $missingReferences = []; - public function __construct(array $originalReferences) + public function __construct(private readonly array $originalReferences) { - $this->originalReferences = $originalReferences; } public function addMissingReference(int $targetBlogId, string $contentType, int $id): void diff --git a/inc/Smartling/Models/DuplicateSubmissionDetails.php b/inc/Smartling/Models/DuplicateSubmissionDetails.php index 614c7729..f13ceae4 100644 --- a/inc/Smartling/Models/DuplicateSubmissionDetails.php +++ b/inc/Smartling/Models/DuplicateSubmissionDetails.php @@ -2,33 +2,13 @@ namespace Smartling\Models; -class DuplicateSubmissionDetails +readonly class DuplicateSubmissionDetails { public function __construct( - private string $contentType, - private int $sourceBlogId, - private int $sourceId, - private int $targetBlogId, + public string $contentType, + public int $sourceBlogId, + public int $sourceId, + public int $targetBlogId, ) { } - - public function getContentType(): string - { - return $this->contentType; - } - - public function getSourceBlogId(): int - { - return $this->sourceBlogId; - } - - public function getSourceId(): int - { - return $this->sourceId; - } - - public function getTargetBlogId(): int - { - return $this->targetBlogId; - } } diff --git a/inc/Smartling/Models/ExternalData.php b/inc/Smartling/Models/ExternalData.php index e7e7343d..7cac01c0 100644 --- a/inc/Smartling/Models/ExternalData.php +++ b/inc/Smartling/Models/ExternalData.php @@ -2,19 +2,17 @@ namespace Smartling\Models; -class ExternalData { - private RelatedContentInfo $relatedContentInfo; - +class ExternalData +{ public function __construct( private array $strings = [], private array $related = [], - RelatedContentInfo $relatedContentInfo = null, + private ?RelatedContentInfo $relatedContentInfo = null, ) { if ($relatedContentInfo === null) { $this->relatedContentInfo = new RelatedContentInfo(); } else { $this->related = $relatedContentInfo->getRelatedContentList(); - $this->relatedContentInfo = $relatedContentInfo; } } diff --git a/inc/Smartling/Models/GutenbergBlock.php b/inc/Smartling/Models/GutenbergBlock.php index 10d750b0..0229e7fc 100644 --- a/inc/Smartling/Models/GutenbergBlock.php +++ b/inc/Smartling/Models/GutenbergBlock.php @@ -7,22 +7,16 @@ class GutenbergBlock { - private ?string $blockName; // null for non-Gutenberg blocks. This happens when WP serializes/unserializes content - private array $attributes; - private array $innerBlocks; - private string $innerHtml; - private array $innerContent; - /** * @param GutenbergBlock[] $innerBlocks */ - public function __construct(?string $blockName, array $attributes, array $innerBlocks, string $innerHtml, array $innerContent) - { - $this->blockName = $blockName; - $this->attributes = $attributes; - $this->innerBlocks = $innerBlocks; - $this->innerHtml = $innerHtml; - $this->innerContent = $innerContent; + public function __construct( + private ?string $blockName, // null for non-Gutenberg blocks. This happens when WP serializes/unserializes content + private array $attributes, + private array $innerBlocks, + private readonly string $innerHtml, + private array $innerContent, + ) { } public function __toString() @@ -106,10 +100,11 @@ public static function fromArray(array $array): self { $innerBlocks = []; if (array_key_exists('innerBlocks', $array)) { - $innerBlocks = array_map(static function($block) { + $innerBlocks = array_map(static function ($block) { return GutenbergBlock::fromArray($block); }, $array['innerBlocks']); } + return new GutenbergBlock( $array['blockName'], $array['attrs'] ?? [], @@ -119,7 +114,13 @@ public static function fromArray(array $array): self ); } - #[ArrayShape(['blockName' => 'string', 'attrs' => 'array', 'innerBlocks' => 'array', 'innerHTML' => 'string', 'innerContent' => 'array'])] + #[ArrayShape([ + 'blockName' => 'string', + 'attrs' => 'array', + 'innerBlocks' => 'array', + 'innerHTML' => 'string', + 'innerContent' => 'array', + ])] public function toArray(): array { return [ @@ -177,9 +178,10 @@ private function serializeBlockAttributes(array $attributes): string private function stripCoreBlockNamespace(string $name): string { $prefix = 'core/'; - if (0 === strpos($name, $prefix)) { + if (str_starts_with($name, $prefix)) { return substr($name, strlen($prefix)); } + return $name; } } diff --git a/inc/Smartling/Models/IntStringPair.php b/inc/Smartling/Models/IntStringPair.php index 690e2376..2a4b999d 100644 --- a/inc/Smartling/Models/IntStringPair.php +++ b/inc/Smartling/Models/IntStringPair.php @@ -2,18 +2,9 @@ namespace Smartling\Models; -class IntStringPair { - public function __construct(private int $key, private string $value) +readonly class IntStringPair +{ + public function __construct(public int $key, public string $value) { } - - public function getKey(): int - { - return $this->key; - } - - public function getValue(): string - { - return $this->value; - } } diff --git a/inc/Smartling/Models/IntStringPairCollection.php b/inc/Smartling/Models/IntStringPairCollection.php index 94785ea4..d71d1824 100644 --- a/inc/Smartling/Models/IntStringPairCollection.php +++ b/inc/Smartling/Models/IntStringPairCollection.php @@ -2,11 +2,13 @@ namespace Smartling\Models; -class IntStringPairCollection { +class IntStringPairCollection +{ /** * @var IntStringPair[] */ private array $array; + /** * @param IntStringPair[]|string[] $items */ @@ -35,6 +37,7 @@ public function add(array $items): self throw new \InvalidArgumentException("Items expected to be array of " . IntStringPair::class); } } + return new self(array_merge($this->array, $items)); } @@ -50,7 +53,7 @@ public function getList(): array { $result = []; foreach ($this->array as $intStringPair) { - $result[] = $intStringPair->getValue(); + $result[] = $intStringPair->value; } return $result; diff --git a/inc/Smartling/Models/IntegerIterator.php b/inc/Smartling/Models/IntegerIterator.php index 41415a00..eb9b935e 100644 --- a/inc/Smartling/Models/IntegerIterator.php +++ b/inc/Smartling/Models/IntegerIterator.php @@ -2,8 +2,9 @@ namespace Smartling\Models; -class IntegerIterator extends \ArrayIterator { - private const SEPARATOR = ','; +class IntegerIterator extends \ArrayIterator +{ + private const string SEPARATOR = ','; public function __construct(array $items = []) { diff --git a/inc/Smartling/Models/JobInformation.php b/inc/Smartling/Models/JobInformation.php index fa89ee3e..d49dacd9 100644 --- a/inc/Smartling/Models/JobInformation.php +++ b/inc/Smartling/Models/JobInformation.php @@ -2,52 +2,15 @@ namespace Smartling\Models; -class JobInformation +readonly class JobInformation { - private bool $authorize; - private string $description; - private string $dueDate; - private string $id; - private string $name; - private string $timeZone; - - public function __construct(string $id, bool $authorize, string $name, string $description, string $dueDate, string $timeZone) - { - $this->id = $id; - $this->authorize = $authorize; - $this->name = $name; - $this->description = $description; - $this->dueDate = $dueDate; - $this->timeZone = $timeZone; - } - - public function getId(): string - { - return $this->id; - } - - public function isAuthorize(): bool - { - return $this->authorize; - } - - public function getName(): string - { - return $this->name; - } - - public function getDescription(): string - { - return $this->description; - } - - public function getDueDate(): string - { - return $this->dueDate; - } - - public function getTimeZone(): string - { - return $this->timeZone; + public function __construct( + public string $id, + public bool $authorize, + public string $name, + public string $description, + public string $dueDate, + public string $timeZone, + ) { } } diff --git a/inc/Smartling/Models/LoggerWithStringContext.php b/inc/Smartling/Models/LoggerWithStringContext.php index 990debd7..9be3d6bd 100644 --- a/inc/Smartling/Models/LoggerWithStringContext.php +++ b/inc/Smartling/Models/LoggerWithStringContext.php @@ -4,7 +4,9 @@ use Smartling\Vendor\Psr\Log\LoggerInterface; -interface LoggerWithStringContext extends LoggerInterface { +interface LoggerWithStringContext extends LoggerInterface +{ public function alterContext(array $context): void; + public function withStringContext(array $context, callable $callable): mixed; } diff --git a/inc/Smartling/Models/NotificationParameters.php b/inc/Smartling/Models/NotificationParameters.php index 7fe0e299..21560b18 100644 --- a/inc/Smartling/Models/NotificationParameters.php +++ b/inc/Smartling/Models/NotificationParameters.php @@ -2,37 +2,13 @@ namespace Smartling\Models; -class NotificationParameters { - private string $contentId; - private string $message; - private string $projectId; - private string $severity; - - public function __construct(string $contentId, string $message, string $projectId, string $severity) - { - $this->contentId = $contentId; - $this->message = $message; - $this->projectId = $projectId; - $this->severity = $severity; - } - - public function getContentId(): string - { - return $this->contentId; - } - - public function getMessage(): string - { - return $this->message; - } - - public function getProjectId(): string - { - return $this->projectId; - } - - public function getSeverity(): string - { - return $this->severity; +readonly class NotificationParameters +{ + public function __construct( + public string $contentId, + public string $message, + public string $projectId, + public string $severity, + ) { } } diff --git a/inc/Smartling/Models/RelatedContentInfo.php b/inc/Smartling/Models/RelatedContentInfo.php index c5035671..2446d6eb 100644 --- a/inc/Smartling/Models/RelatedContentInfo.php +++ b/inc/Smartling/Models/RelatedContentInfo.php @@ -4,7 +4,8 @@ use Smartling\Helpers\ArrayHelper; -class RelatedContentInfo { +class RelatedContentInfo +{ private ArrayHelper $arrayHelper; private array $info; @@ -49,10 +50,10 @@ public function getRelatedContentList(): array $return = []; foreach ($flat as $item) { assert($item instanceof Content); - if (!array_key_exists($item->getType(), $return)) { - $return[$item->getType()] = []; + if (!array_key_exists($item->contentType, $return)) { + $return[($item->contentType)] = []; } - $return[$item->getType()][] = $item->getId(); + $return[($item->contentType)][] = $item->contentId; } foreach ($return as $key => $value) { $return[$key] = array_unique($value); diff --git a/inc/Smartling/Models/TestRunViewData.php b/inc/Smartling/Models/TestRunViewData.php index 39f6d735..ef8228ef 100644 --- a/inc/Smartling/Models/TestRunViewData.php +++ b/inc/Smartling/Models/TestRunViewData.php @@ -2,74 +2,17 @@ namespace Smartling\Models; -class TestRunViewData { - private array $blogs; - private int $completed; - private int $failed; - private int $inProgress; - private int $new; - private ?int $testBlogId; - private int $uploadCronLastFinishTime; - private int $uploadCronIntervalSeconds; - +readonly class TestRunViewData +{ public function __construct( - array $blogs, - ?int $testBlogId, - int $new, - int $inProgress, - int $completed, - int $failed, - int $uploadCronLastFinishTime, - int $uploadCronIntervalSeconds - ) - { - $this->blogs = $blogs; - $this->completed = $completed; - $this->failed = $failed; - $this->inProgress = $inProgress; - $this->new = $new; - $this->testBlogId = $testBlogId; - $this->uploadCronLastFinishTime = $uploadCronLastFinishTime; - $this->uploadCronIntervalSeconds = $uploadCronIntervalSeconds; - } - - public function getBlogs(): array - { - return $this->blogs; - } - - public function getCompleted(): int - { - return $this->completed; - } - - public function getFailed(): int - { - return $this->failed; - } - - public function getInProgress(): int - { - return $this->inProgress; - } - - public function getNew(): int - { - return $this->new; - } - - public function getTestBlogId(): ?int - { - return $this->testBlogId; - } - - public function getUploadCronLastFinishTime(): int - { - return $this->uploadCronLastFinishTime; - } - - public function getUploadCronIntervalSeconds(): int - { - return $this->uploadCronIntervalSeconds; + public array $blogs, + public ?int $testBlogId, + public int $new, + public int $inProgress, + public int $completed, + public int $failed, + public int $uploadCronLastFinishTime, + public int $uploadCronIntervalSeconds, + ) { } } diff --git a/inc/Smartling/Models/UploadQueueEntity.php b/inc/Smartling/Models/UploadQueueEntity.php index 4c72ac4d..6fd06e3d 100644 --- a/inc/Smartling/Models/UploadQueueEntity.php +++ b/inc/Smartling/Models/UploadQueueEntity.php @@ -7,26 +7,16 @@ class UploadQueueEntity implements SmartlingTableDefinitionInterface { - public const FIELD_ID = 'id'; - public const FIELD_BATCH_UID = 'batch_uid'; - public const FIELD_CREATED = 'created'; - public const FIELD_SUBMISSION_IDS = 'submission_ids'; - public const TABLE_NAME = 'smartling_upload_queue'; + public const string FIELD_ID = 'id'; + public const string FIELD_BATCH_UID = 'batch_uid'; + public const string FIELD_CREATED = 'created'; + public const string FIELD_SUBMISSION_IDS = 'submission_ids'; + public const string TABLE_NAME = 'smartling_upload_queue'; - public function __construct(private $submissionId, private string $batchUid) + public function __construct(public readonly int $submissionId, public readonly string $batchUid) { } - public function getBatchUid(): string - { - return $this->batchUid; - } - - public function getSubmissionId(): int - { - return $this->submissionId; - } - public static function getFieldLabels(): array { return []; diff --git a/inc/Smartling/Models/UploadQueueItem.php b/inc/Smartling/Models/UploadQueueItem.php index 2f5db01e..2e3115c1 100644 --- a/inc/Smartling/Models/UploadQueueItem.php +++ b/inc/Smartling/Models/UploadQueueItem.php @@ -2,15 +2,18 @@ namespace Smartling\Models; -use JetBrains\PhpStorm\Pure; use Smartling\Submissions\SubmissionEntity; -class UploadQueueItem { +readonly class UploadQueueItem +{ /** * @param SubmissionEntity[] $submissions */ - public function __construct(private array $submissions, private string $batchUid, private IntStringPairCollection $smartlingLocales) - { + public function __construct( + public array $submissions, + public string $batchUid, + public IntStringPairCollection $smartlingLocales, + ) { $contentTypes = []; $sourceBlogIds = []; $sourceIds = []; @@ -37,42 +40,20 @@ public function __construct(private array $submissions, private string $batchUid } } - public function getBatchUid(): string - { - return $this->batchUid; - } - - public function getSmartlingLocales(): IntStringPairCollection - { - return $this->smartlingLocales; - } - - /** - * @return SubmissionEntity[]; - */ - public function getSubmissions(): array - { - return $this->submissions; - } - public function removeSubmission(SubmissionEntity $submission): self { $submissions = array_values(array_filter($this->submissions, static function (SubmissionEntity $item) use ($submission) { return $item->getId() !== $submission->getId(); })); $locales = new IntStringPairCollection(array_values(array_filter($this->smartlingLocales->getArray(), static function (IntStringPair $item) use ($submission) { - return $item->getKey() !== $submission->getId(); + return $item->key !== $submission->getId(); }))); return new self($submissions, $this->batchUid, $locales); } - #[Pure] public function setBatchUid(string $batchUid): self { - $result = clone $this; - $result->batchUid = $batchUid; - - return $result; + return new self($this->submissions, $batchUid, $this->smartlingLocales); } } diff --git a/inc/Smartling/Models/UserCloneRequest.php b/inc/Smartling/Models/UserCloneRequest.php index 4942c1ed..9a738bce 100644 --- a/inc/Smartling/Models/UserCloneRequest.php +++ b/inc/Smartling/Models/UserCloneRequest.php @@ -7,17 +7,16 @@ class UserCloneRequest { - private int $contentId; - private string $contentType; - private string $description; private array $relations; private array $targetBlogIds; - public function __construct(int $contentId, string $contentType, array $relations, array $targetBlogIds, string $description = '') - { - $this->contentId = $contentId; - $this->contentType = $contentType; - $this->description = $description; + public function __construct( + private readonly int $contentId, + private readonly string $contentType, + array $relations, + array $targetBlogIds, + private readonly string $description = '', + ) { krsort($relations); $this->relations = $relations; $this->targetBlogIds = ArrayHelper::toArrayOfIntegers($targetBlogIds, 'Target blog id expected to be numeric'); @@ -63,6 +62,7 @@ protected static function getSourceId(array $array): int if ($id === null) { throw new SmartlingHumanReadableException('Source content id is empty, please save content prior to uploading', 'source.id.empty', 400); } + return (int)$id; } } diff --git a/inc/Smartling/Models/UserTranslationRequest.php b/inc/Smartling/Models/UserTranslationRequest.php index 081aad1c..bc659281 100644 --- a/inc/Smartling/Models/UserTranslationRequest.php +++ b/inc/Smartling/Models/UserTranslationRequest.php @@ -6,13 +6,18 @@ class UserTranslationRequest extends UserCloneRequest { - private JobInformation $jobInformation; private array $ids; - public function __construct(int $contentId, string $contentType, array $relations, array $targetBlogIds, JobInformation $jobInformation, array $ids = [], string $description = '') - { + public function __construct( + int $contentId, + string $contentType, + array $relations, + array $targetBlogIds, + private readonly JobInformation $jobInformation, + array $ids = [], + string $description = '', + ) { parent::__construct($contentId, $contentType, $relations, $targetBlogIds, $description); - $this->jobInformation = $jobInformation; $this->ids = self::toIntegerArray($ids); } @@ -47,7 +52,7 @@ public function isBulk(): bool return count($this->ids) > 0; } - private static function validate(array $array) + private static function validate(array $array): void { if (!array_key_exists('source', $array)) { throw new \InvalidArgumentException('Source array required'); diff --git a/inc/Smartling/Queue/QueueInterface.php b/inc/Smartling/Queue/QueueInterface.php index 9592ff46..fa10ec17 100644 --- a/inc/Smartling/Queue/QueueInterface.php +++ b/inc/Smartling/Queue/QueueInterface.php @@ -4,10 +4,10 @@ interface QueueInterface { - public const UPLOAD_QUEUE = 'upload-queue'; - public const QUEUE_NAME_DOWNLOAD_QUEUE = 'download-queue'; - public const QUEUE_NAME_LAST_MODIFIED_CHECK_AND_FAIL_QUEUE = 'last-modified-check-and-fail-queue'; - public const QUEUE_NAME_LAST_MODIFIED_CHECK_QUEUE = 'last-modified-check-queue'; + public const string UPLOAD_QUEUE = 'upload-queue'; + public const string QUEUE_NAME_DOWNLOAD_QUEUE = 'download-queue'; + public const string QUEUE_NAME_LAST_MODIFIED_CHECK_AND_FAIL_QUEUE = 'last-modified-check-and-fail-queue'; + public const string QUEUE_NAME_LAST_MODIFIED_CHECK_QUEUE = 'last-modified-check-queue'; public function isVirtual(string $queue): bool; diff --git a/inc/Smartling/Replacers/ReplacerFactory.php b/inc/Smartling/Replacers/ReplacerFactory.php index 40b42441..92d26e1e 100644 --- a/inc/Smartling/Replacers/ReplacerFactory.php +++ b/inc/Smartling/Replacers/ReplacerFactory.php @@ -7,10 +7,10 @@ class ReplacerFactory { - public const REPLACER_COPY = 'copy'; - private const REPLACER_EXCLUDE = 'exclude'; - public const REPLACER_RELATED = 'related'; - private const REPLACER_WP_CORE_IMAGE_INNER_HTML = 'coreImage'; + public const string REPLACER_COPY = 'copy'; + private const string REPLACER_EXCLUDE = 'exclude'; + public const string REPLACER_RELATED = 'related'; + private const string REPLACER_WP_CORE_IMAGE_INNER_HTML = 'coreImage'; /** * @var ReplacerInterface[] $replacers diff --git a/inc/Smartling/RestApi.php b/inc/Smartling/RestApi.php index f92149d5..f536b7c0 100644 --- a/inc/Smartling/RestApi.php +++ b/inc/Smartling/RestApi.php @@ -15,8 +15,8 @@ class RestApi extends \WP_REST_Controller { use DITrait; - private const ASSET_UID_REGEX = '(?P[a-z-_]+-\d+)'; - private const NAMESPACE = 'smartling-connector/v2'; + private const string ASSET_UID_REGEX = '(?P[a-z-_]+-\d+)'; + private const string NAMESPACE = 'smartling-connector/v2'; private ContentHelper $contentHelper; private FileUriHelper $fileUriHelper; diff --git a/inc/Smartling/Services/BaseAjaxServiceAbstract.php b/inc/Smartling/Services/BaseAjaxServiceAbstract.php index 62e21128..66199b97 100644 --- a/inc/Smartling/Services/BaseAjaxServiceAbstract.php +++ b/inc/Smartling/Services/BaseAjaxServiceAbstract.php @@ -12,8 +12,8 @@ abstract class BaseAjaxServiceAbstract implements WPHookInterface */ const ACTION_NAME = 'service-id'; - public const RESPONSE_FAILED = 'FAILED'; - public const RESPONSE_SUCCESS = 'SUCCESS'; + public const string RESPONSE_FAILED = 'FAILED'; + public const string RESPONSE_SUCCESS = 'SUCCESS'; protected array $requestData; diff --git a/inc/Smartling/Services/ContentRelationsDiscoveryService.php b/inc/Smartling/Services/ContentRelationsDiscoveryService.php index 4f3cc3e3..6280bd9f 100644 --- a/inc/Smartling/Services/ContentRelationsDiscoveryService.php +++ b/inc/Smartling/Services/ContentRelationsDiscoveryService.php @@ -33,6 +33,7 @@ use Smartling\Helpers\WordpressFunctionProxyHelper; use Smartling\Jobs\JobEntity; use Smartling\Models\IntegerIterator; +use Smartling\Models\JobInformation; use Smartling\Models\UserCloneRequest; use Smartling\Models\DetectedRelations; use Smartling\Models\GutenbergBlock; @@ -50,8 +51,8 @@ class ContentRelationsDiscoveryService { use LoggerSafeTrait; - public const POST_BASED_PROCESSOR = 'PostBasedProcessor'; - public const TERM_BASED_PROCESSOR = 'TermBasedProcessor'; + public const string POST_BASED_PROCESSOR = 'PostBasedProcessor'; + public const string TERM_BASED_PROCESSOR = 'TermBasedProcessor'; public function __construct( private AcfDynamicSupport $acfDynamicSupport, @@ -199,10 +200,11 @@ public function createSubmissions(UserTranslationRequest $request): void $curBlogId = $this->wordpressProxy->get_current_blog_id(); $profile = $this->settingsManager->getSingleSettingsProfile($curBlogId); $job = $request->getJobInformation(); - $jobInfo = new JobEntity($job->getName(), $job->getId(), $profile->getProjectId()); + $jobInfo = new JobEntity($job->name, $job->id, $profile->getProjectId()); if ($request->isBulk()) { - $this->bulkUpload($request->getJobInformation()->isAuthorize(), + $jobInformation = $request->getJobInformation(); + $this->bulkUpload($jobInformation->authorize, $request->getIds(), $request->getContentType(), $curBlogId, @@ -237,7 +239,7 @@ public function createSubmissions(UserTranslationRequest $request): void 'sourceBlogId' => $curBlogId, 'sourceId' => $request->getContentId(), 'targetBlogIds' => $request->getTargetBlogIds(), - ], $jobInfo, $job->isAuthorize()); + ], $jobInfo, $job->authorize); } catch (\Exception $e) { $this->getLogger()->error(sprintf( 'Failed to create audit log record actionType=%s, requestDescription="%s", sourceId=%d, sourceBlogId=%d, errorMessage="%s"', @@ -309,7 +311,7 @@ public function createSubmissions(UserTranslationRequest $request): void $profile, $jobInfo->getJobUid(), array_values(array_unique($fileUris)), - $job->isAuthorize(), + $job->authorize, )); } diff --git a/inc/Smartling/Services/ContentRelationsHandler.php b/inc/Smartling/Services/ContentRelationsHandler.php index b7da4c3a..4ef350ca 100644 --- a/inc/Smartling/Services/ContentRelationsHandler.php +++ b/inc/Smartling/Services/ContentRelationsHandler.php @@ -43,12 +43,12 @@ class ContentRelationsHandler extends BaseAjaxServiceAbstract { use LoggerSafeTrait; - public const ACTION_NAME = 'smartling-get-relations'; + public const string ACTION_NAME = 'smartling-get-relations'; - public const ACTION_NAME_CREATE_SUBMISSIONS = 'smartling-create-submissions'; + public const string ACTION_NAME_CREATE_SUBMISSIONS = 'smartling-create-submissions'; - public const FORM_ACTION_CLONE = 'clone'; - public const FORM_ACTION_UPLOAD = 'upload'; + public const string FORM_ACTION_CLONE = 'clone'; + public const string FORM_ACTION_UPLOAD = 'upload'; private ContentRelationsDiscoveryService $service; public function __construct(ContentRelationsDiscoveryService $service) diff --git a/inc/Smartling/Services/GlobalSettingsManager.php b/inc/Smartling/Services/GlobalSettingsManager.php index 45eb39b4..14d8c444 100644 --- a/inc/Smartling/Services/GlobalSettingsManager.php +++ b/inc/Smartling/Services/GlobalSettingsManager.php @@ -14,8 +14,8 @@ class GlobalSettingsManager /** * Disable on-boot self-diagnostics (not recommended) */ - private const SELF_CHECK_IDENTIFIER = 'smartling_static_check_disabled'; - private const SELF_CHECK_IDENTIFIER_DEFAULT = 0; + private const string SELF_CHECK_IDENTIFIER = 'smartling_static_check_disabled'; + private const int SELF_CHECK_IDENTIFIER_DEFAULT = 0; public static function getSkipSelfCheck() { @@ -34,8 +34,8 @@ public static function setSkipSelfCheck($value): void /** * Disable logging (not recommended) */ - private const DISABLE_LOGGING = 'smartling_disable_logging'; - private const DISABLE_LOGGING_DEFAULT = 0; + private const string DISABLE_LOGGING = 'smartling_disable_logging'; + private const int DISABLE_LOGGING_DEFAULT = 0; public static function getDisableLogging() { @@ -54,7 +54,7 @@ public static function setDisableLogging($value): void /** * Log file name customization */ - private const SMARTLING_CUSTOM_LOG_FILE = 'smartling_log_file'; + private const string SMARTLING_CUSTOM_LOG_FILE = 'smartling_log_file'; public static function getLogFileSpecDefault(): string { @@ -78,7 +78,7 @@ public static function setLogFileSpec(string $value): void /** * Logging configuration customization */ - private const LOGGING_CUSTOMIZATION = 'smartling_logging_customization'; + private const string LOGGING_CUSTOMIZATION = 'smartling_logging_customization'; public static function getLoggingCustomizationDefault() { @@ -125,7 +125,7 @@ public static function setLoggingCustomization($value): void /** * UI settings Table View Page Size, default = 20 (configured via yaml file) */ - private const SMARTLING_CUSTOM_PAGE_SIZE = 'smartling_ui_page_size'; + private const string SMARTLING_CUSTOM_PAGE_SIZE = 'smartling_ui_page_size'; public static function getPageSizeDefault() { @@ -151,8 +151,8 @@ public static function getPageSizeRuntime() return Bootstrap::getContainer()->getParameter('submission.pagesize'); } - public const SMARTLING_FRONTEND_GENERATE_LOCK_IDS = 'smartling_frontend_generate_lock_ids'; - public const SMARTLING_GENERATE_LOCK_IDS_DEFAULT = "0"; + public const string SMARTLING_FRONTEND_GENERATE_LOCK_IDS = 'smartling_frontend_generate_lock_ids'; + public const string SMARTLING_GENERATE_LOCK_IDS_DEFAULT = "0"; public static function isGenerateLockIdsEnabled(): bool { @@ -168,8 +168,8 @@ public static function setGenerateLockIdsFrontend(string $value): void } } - public const SMARTLING_RELATED_CONTENT_SELECT_STATE = 'smartling_related_content_select_state'; - public const SMARTLING_RELATED_CHECKBOX_STATE_DEFAULT = 0; + public const string SMARTLING_RELATED_CONTENT_SELECT_STATE = 'smartling_related_content_select_state'; + public const int SMARTLING_RELATED_CHECKBOX_STATE_DEFAULT = 0; public static function getRelatedContentSelectState(): int { @@ -188,8 +188,8 @@ public static function setRelatedContentSelectState(int $value): void } } - private const SMARTLING_FILTER_UI_VISIBLE = 'smartling_filter_ui_visible'; - private const SMARTLING_FILTER_UI_VISIBLE_DEFAULT = 0; + private const string SMARTLING_FILTER_UI_VISIBLE = 'smartling_filter_ui_visible'; + private const int SMARTLING_FILTER_UI_VISIBLE_DEFAULT = 0; public static function getFilterUiVisible(): int { @@ -205,8 +205,8 @@ public static function setFilterUiVisible(int $value): void } } - public const SETTING_REMOVE_ACF_PARSE_SAVE_BLOCKS_FILTER = 'smartling_remove_acf_parse_save_blocks_filter'; - public const SETTING_REMOVE_ACF_PARSE_SAVE_BLOCKS_FILTER_DEFAULT = "1"; + public const string SETTING_REMOVE_ACF_PARSE_SAVE_BLOCKS_FILTER = 'smartling_remove_acf_parse_save_blocks_filter'; + public const string SETTING_REMOVE_ACF_PARSE_SAVE_BLOCKS_FILTER_DEFAULT = "1"; public static function isRemoveAcfParseSaveBlocksFilter(): bool { @@ -222,8 +222,8 @@ public static function setRemoveAcfParseSaveBlocksFilter(string $value): void } } - public const SETTING_ADD_SLASHES_BEFORE_SAVING_CONTENT = 'smartling_add_slashes_before_saving_content'; - public const SETTING_ADD_SLASHES_BEFORE_SAVING_CONTENT_DEFAULT = "1"; + public const string SETTING_ADD_SLASHES_BEFORE_SAVING_CONTENT = 'smartling_add_slashes_before_saving_content'; + public const string SETTING_ADD_SLASHES_BEFORE_SAVING_CONTENT_DEFAULT = "1"; public static function isAddSlashesBeforeSavingPostContent(): bool { @@ -239,8 +239,8 @@ public static function setAddSlashesBeforeSavingContent(string $value): void } } - public const SETTING_ADD_SLASHES_BEFORE_SAVING_META = 'smartling_add_slashes_before_saving_meta'; - public const SETTING_ADD_SLASHES_BEFORE_SAVING_META_DEFAULT = "1"; + public const string SETTING_ADD_SLASHES_BEFORE_SAVING_META = 'smartling_add_slashes_before_saving_meta'; + public const string SETTING_ADD_SLASHES_BEFORE_SAVING_META_DEFAULT = "1"; public static function isAddSlashesBeforeSavingPostMeta(): bool { @@ -256,8 +256,8 @@ public static function setAddSlashesBeforeSavingMeta(string $value): void } } - public const SETTING_CUSTOM_DIRECTIVES = 'smartling_custom_directives'; - public const SETTING_CUSTOM_DIRECTIVES_DEFAULT = ''; + public const string SETTING_CUSTOM_DIRECTIVES = 'smartling_custom_directives'; + public const string SETTING_CUSTOM_DIRECTIVES_DEFAULT = ''; public static function getCustomDirectives(): string { diff --git a/inc/Smartling/Services/InvalidCharacterCleaner.php b/inc/Smartling/Services/InvalidCharacterCleaner.php index d7e89012..344e4d81 100644 --- a/inc/Smartling/Services/InvalidCharacterCleaner.php +++ b/inc/Smartling/Services/InvalidCharacterCleaner.php @@ -8,7 +8,7 @@ class InvalidCharacterCleaner implements WPHookInterface { - private const ILLEGAL_CHAR_REGEXP = '#[^\x{0009}\x{000A}\x{000D}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+#us'; + private const string ILLEGAL_CHAR_REGEXP = '#[^\x{0009}\x{000A}\x{000D}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+#us'; /** * Registers wp hook handlers. Invoked by wordpress. diff --git a/inc/Smartling/Settings/ConfigurationProfileEntity.php b/inc/Smartling/Settings/ConfigurationProfileEntity.php index 72e4a704..c9a1e63a 100644 --- a/inc/Smartling/Settings/ConfigurationProfileEntity.php +++ b/inc/Smartling/Settings/ConfigurationProfileEntity.php @@ -11,23 +11,23 @@ */ class ConfigurationProfileEntity extends SmartlingEntityAbstract { - private const REGEX_PROJECT_ID = '([0-9a-f]){9}'; + private const string REGEX_PROJECT_ID = '([0-9a-f]){9}'; - public const RETRIEVAL_TYPE_PSEUDO = 'pseudo'; - public const RETRIEVAL_TYPE_PUBLISHED = 'published'; + public const string RETRIEVAL_TYPE_PSEUDO = 'pseudo'; + public const string RETRIEVAL_TYPE_PUBLISHED = 'published'; - public const UPLOAD_ON_CHANGE_MANUAL = 0; + public const int UPLOAD_ON_CHANGE_MANUAL = 0; - public const UPLOAD_ON_CHANGE_AUTO = 1; + public const int UPLOAD_ON_CHANGE_AUTO = 1; - public const TRANSLATION_DOWNLOAD_MODE_TRANSLATION_COMPLETED = 0; - public const TRANSLATION_DOWNLOAD_MODE_PROGRESS_CHANGES = 1; - public const TRANSLATION_DOWNLOAD_MODE_MANUAL = 2; + public const int TRANSLATION_DOWNLOAD_MODE_TRANSLATION_COMPLETED = 0; + public const int TRANSLATION_DOWNLOAD_MODE_PROGRESS_CHANGES = 1; + public const int TRANSLATION_DOWNLOAD_MODE_MANUAL = 2; - public const TRANSLATION_PUBLISHING_MODE_NO_CHANGE = 0; - public const TRANSLATION_PUBLISHING_MODE_PUBLISH = 1; - public const TRANSLATION_PUBLISHING_MODE_DRAFT = 2; + public const int TRANSLATION_PUBLISHING_MODE_NO_CHANGE = 0; + public const int TRANSLATION_PUBLISHING_MODE_PUBLISH = 1; + public const int TRANSLATION_PUBLISHING_MODE_DRAFT = 2; protected static function getInstance(): ConfigurationProfileEntity { @@ -171,7 +171,7 @@ public function getSecretKey(): string return (string)$this->stateFields['secret_key']; } - public function setSecretKey(string $secret_key): void + public function setSecretKey(#[\SensitiveParameter] string $secret_key): void { $this->stateFields['secret_key'] = $secret_key; } diff --git a/inc/Smartling/Submissions/SubmissionEntity.php b/inc/Smartling/Submissions/SubmissionEntity.php index 7f496da0..f0b043c4 100644 --- a/inc/Smartling/Submissions/SubmissionEntity.php +++ b/inc/Smartling/Submissions/SubmissionEntity.php @@ -37,17 +37,17 @@ */ class SubmissionEntity extends SmartlingEntityAbstract implements Submission { - public const FLAG_CONTENT_IS_OUT_OF_DATE = 1; + public const int FLAG_CONTENT_IS_OUT_OF_DATE = 1; - public const FLAG_CONTENT_IS_UP_TO_DATE = 0; + public const int FLAG_CONTENT_IS_UP_TO_DATE = 0; - public const DATETIME_FORMAT = 'Y-m-d H:i:s'; + public const string DATETIME_FORMAT = 'Y-m-d H:i:s'; - public const SUBMISSION_STATUS_NEW = 'New'; - public const SUBMISSION_STATUS_IN_PROGRESS = 'In Progress'; - public const SUBMISSION_STATUS_COMPLETED = 'Completed'; - public const SUBMISSION_STATUS_FAILED = 'Failed'; - public const SUBMISSION_STATUS_CANCELLED = 'Cancelled'; + public const string SUBMISSION_STATUS_NEW = 'New'; + public const string SUBMISSION_STATUS_IN_PROGRESS = 'In Progress'; + public const string SUBMISSION_STATUS_COMPLETED = 'Completed'; + public const string SUBMISSION_STATUS_FAILED = 'Failed'; + public const string SUBMISSION_STATUS_CANCELLED = 'Cancelled'; public static array $submissionStatuses = [ self::SUBMISSION_STATUS_NEW, @@ -57,34 +57,34 @@ class SubmissionEntity extends SmartlingEntityAbstract implements Submission self::SUBMISSION_STATUS_CANCELLED, ]; - public const FIELD_ID = 'id'; - public const FIELD_SOURCE_TITLE = 'source_title'; - public const FIELD_SOURCE_BLOG_ID = 'source_blog_id'; - public const FIELD_SOURCE_CONTENT_HASH = 'source_content_hash'; - public const FIELD_CONTENT_TYPE = 'content_type'; - public const FIELD_SOURCE_ID = 'source_id'; - public const FIELD_FILE_URI = 'file_uri'; - public const FIELD_TARGET_LOCALE = 'target_locale'; - public const FIELD_TARGET_BLOG_ID = 'target_blog_id'; - public const FIELD_TARGET_ID = 'target_id'; - public const FIELD_SUBMITTER = 'submitter'; - public const FIELD_SUBMISSION_DATE = 'submission_date'; - public const FIELD_APPLIED_DATE = 'applied_date'; - public const FIELD_APPROVED_STRING_COUNT = 'approved_string_count'; - public const FIELD_COMPLETED_STRING_COUNT = 'completed_string_count'; - public const FIELD_EXCLUDED_STRING_COUNT = 'excluded_string_count'; - public const FIELD_TOTAL_STRING_COUNT = 'total_string_count'; - public const FIELD_WORD_COUNT = 'word_count'; - public const FIELD_STATUS = 'status'; - public const FIELD_IS_LOCKED = 'is_locked'; - public const FIELD_IS_CLONED = 'is_cloned'; - public const FIELD_LAST_MODIFIED = 'last_modified'; - public const FIELD_OUTDATED = 'outdated'; - public const FIELD_LAST_ERROR = 'last_error'; - public const FIELD_LOCKED_FIELDS = 'locked_fields'; - public const FIELD_CREATED_AT = 'created_at'; - - public const VIRTUAL_FIELD_JOB_LINK = 'job_link'; + public const string FIELD_ID = 'id'; + public const string FIELD_SOURCE_TITLE = 'source_title'; + public const string FIELD_SOURCE_BLOG_ID = 'source_blog_id'; + public const string FIELD_SOURCE_CONTENT_HASH = 'source_content_hash'; + public const string FIELD_CONTENT_TYPE = 'content_type'; + public const string FIELD_SOURCE_ID = 'source_id'; + public const string FIELD_FILE_URI = 'file_uri'; + public const string FIELD_TARGET_LOCALE = 'target_locale'; + public const string FIELD_TARGET_BLOG_ID = 'target_blog_id'; + public const string FIELD_TARGET_ID = 'target_id'; + public const string FIELD_SUBMITTER = 'submitter'; + public const string FIELD_SUBMISSION_DATE = 'submission_date'; + public const string FIELD_APPLIED_DATE = 'applied_date'; + public const string FIELD_APPROVED_STRING_COUNT = 'approved_string_count'; + public const string FIELD_COMPLETED_STRING_COUNT = 'completed_string_count'; + public const string FIELD_EXCLUDED_STRING_COUNT = 'excluded_string_count'; + public const string FIELD_TOTAL_STRING_COUNT = 'total_string_count'; + public const string FIELD_WORD_COUNT = 'word_count'; + public const string FIELD_STATUS = 'status'; + public const string FIELD_IS_LOCKED = 'is_locked'; + public const string FIELD_IS_CLONED = 'is_cloned'; + public const string FIELD_LAST_MODIFIED = 'last_modified'; + public const string FIELD_OUTDATED = 'outdated'; + public const string FIELD_LAST_ERROR = 'last_error'; + public const string FIELD_LOCKED_FIELDS = 'locked_fields'; + public const string FIELD_CREATED_AT = 'created_at'; + + public const string VIRTUAL_FIELD_JOB_LINK = 'job_link'; private ?JobEntity $jobInformation = null; diff --git a/inc/Smartling/Tuner/FilterManager.php b/inc/Smartling/Tuner/FilterManager.php index 1b6393cb..77bd6784 100644 --- a/inc/Smartling/Tuner/FilterManager.php +++ b/inc/Smartling/Tuner/FilterManager.php @@ -6,7 +6,7 @@ class FilterManager extends CustomizationManagerAbstract implements WPHookInterface { - private const STORAGE_KEY = 'CUSTOM_FILTERS'; + private const string STORAGE_KEY = 'CUSTOM_FILTERS'; public function __construct() { diff --git a/inc/Smartling/Tuner/MediaAttachmentRulesManager.php b/inc/Smartling/Tuner/MediaAttachmentRulesManager.php index b5a8cbb0..9a0af53b 100644 --- a/inc/Smartling/Tuner/MediaAttachmentRulesManager.php +++ b/inc/Smartling/Tuner/MediaAttachmentRulesManager.php @@ -10,7 +10,7 @@ class MediaAttachmentRulesManager extends CustomizationManagerAbstract { use LoggerSafeTrait; - private const STORAGE_KEY = 'CUSTOM_MEDIA_RULES'; + private const string STORAGE_KEY = 'CUSTOM_MEDIA_RULES'; private array $preconfiguredRules; private array $temporaryRules = []; diff --git a/inc/Smartling/Tuner/ShortcodeManager.php b/inc/Smartling/Tuner/ShortcodeManager.php index ada577f7..6843b6d8 100644 --- a/inc/Smartling/Tuner/ShortcodeManager.php +++ b/inc/Smartling/Tuner/ShortcodeManager.php @@ -6,7 +6,7 @@ class ShortcodeManager extends CustomizationManagerAbstract implements WPHookInterface { - private const STORAGE_KEY = 'CUSTOM_SHORTCODES'; + private const string STORAGE_KEY = 'CUSTOM_SHORTCODES'; public function __construct() { diff --git a/inc/Smartling/WP/Controller/AdminPage.php b/inc/Smartling/WP/Controller/AdminPage.php index 38a464e1..04daf5bb 100644 --- a/inc/Smartling/WP/Controller/AdminPage.php +++ b/inc/Smartling/WP/Controller/AdminPage.php @@ -16,9 +16,9 @@ class AdminPage extends ControllerAbstract implements WPHookInterface { - public const SLUG = 'smartling_customization_tuning'; - public const ACTION_EXPORT_GUTENBERG_RULES = 'smartling_export_gutenberg_rules'; - public const ACTION_IMPORT_GUTENBERG_RULES = 'smartling_import_gutenberg_rules'; + public const string SLUG = 'smartling_customization_tuning'; + public const string ACTION_EXPORT_GUTENBERG_RULES = 'smartling_export_gutenberg_rules'; + public const string ACTION_IMPORT_GUTENBERG_RULES = 'smartling_import_gutenberg_rules'; private MediaAttachmentRulesManager $mediaAttachmentRulesManager; private ReplacerFactory $replacerFactory; diff --git a/inc/Smartling/WP/Controller/CheckStatusController.php b/inc/Smartling/WP/Controller/CheckStatusController.php index 3afd64be..215fd242 100644 --- a/inc/Smartling/WP/Controller/CheckStatusController.php +++ b/inc/Smartling/WP/Controller/CheckStatusController.php @@ -17,9 +17,9 @@ */ class CheckStatusController extends WPAbstract implements WPHookInterface { - const SUBMISSION_CHECKED_KEY = "smartling-page-checked-items"; - const CACHE_SLIDE_EXPIRATION = "PT1H"; - const CACHE_EXPIRATION = 7200; + const string SUBMISSION_CHECKED_KEY = "smartling-page-checked-items"; + const string CACHE_SLIDE_EXPIRATION = "PT1H"; + const int CACHE_EXPIRATION = 7200; public function wp_enqueue() { @@ -107,4 +107,4 @@ public function checkItems(array $items) return $result; } -} \ No newline at end of file +} diff --git a/inc/Smartling/WP/Controller/ConfigurationProfileFormController.php b/inc/Smartling/WP/Controller/ConfigurationProfileFormController.php index d7e3440e..586064a6 100644 --- a/inc/Smartling/WP/Controller/ConfigurationProfileFormController.php +++ b/inc/Smartling/WP/Controller/ConfigurationProfileFormController.php @@ -14,8 +14,8 @@ class ConfigurationProfileFormController extends WPAbstract implements WPHookInterface { - public const FILTER_FIELD_NAME_REGEXP = 'filter_field_name_regexp'; - public const ERROR_TARGET_LOCALES = 'tl'; + public const string FILTER_FIELD_NAME_REGEXP = 'filter_field_name_regexp'; + public const string ERROR_TARGET_LOCALES = 'tl'; public function wp_enqueue(): void { diff --git a/inc/Smartling/WP/Controller/ConfigurationProfilesController.php b/inc/Smartling/WP/Controller/ConfigurationProfilesController.php index b5fdeb93..57612e6d 100644 --- a/inc/Smartling/WP/Controller/ConfigurationProfilesController.php +++ b/inc/Smartling/WP/Controller/ConfigurationProfilesController.php @@ -22,10 +22,10 @@ class ConfigurationProfilesController extends WPAbstract implements WPHookInterface { - public const ACTION_QUEUE_PURGE = 'queue_purge'; - public const ACTION_QUEUE_FORCE = 'queue_force'; + public const string ACTION_QUEUE_PURGE = 'queue_purge'; + public const string ACTION_QUEUE_FORCE = 'queue_force'; - public const MENU_SLUG = 'smartling_configuration_profile_list'; + public const string MENU_SLUG = 'smartling_configuration_profile_list'; public function __construct( LocalizationPluginProxyInterface $connector, diff --git a/inc/Smartling/WP/Controller/ContentEditJobController.php b/inc/Smartling/WP/Controller/ContentEditJobController.php index 48a09843..189a8453 100644 --- a/inc/Smartling/WP/Controller/ContentEditJobController.php +++ b/inc/Smartling/WP/Controller/ContentEditJobController.php @@ -17,7 +17,7 @@ class ContentEditJobController extends WPAbstract implements WPHookInterface { - public const SMARTLING_JOB_API_PROXY = 'smartling_job_api_proxy'; + public const string SMARTLING_JOB_API_PROXY = 'smartling_job_api_proxy'; /** * @var string */ @@ -278,4 +278,4 @@ public function box($attr) } } } -} \ No newline at end of file +} diff --git a/inc/Smartling/WP/Controller/DuplicateSubmissionsCleaner.php b/inc/Smartling/WP/Controller/DuplicateSubmissionsCleaner.php index 14ae269a..3f6f6498 100644 --- a/inc/Smartling/WP/Controller/DuplicateSubmissionsCleaner.php +++ b/inc/Smartling/WP/Controller/DuplicateSubmissionsCleaner.php @@ -12,10 +12,10 @@ use Smartling\WP\WPHookInterface; class DuplicateSubmissionsCleaner extends ControllerAbstract implements WPHookInterface { - public const SLUG = 'smartling_duplicate_submission_cleaner'; + public const string SLUG = 'smartling_duplicate_submission_cleaner'; - private const CACHE_KEY = 'submissions-has-duplicate'; - private const NONCE_ACTION = "duplicate-submission-cleaner"; + private const string CACHE_KEY = 'submissions-has-duplicate'; + private const string NONCE_ACTION = "duplicate-submission-cleaner"; public function __construct( private Cache $cache, @@ -60,10 +60,10 @@ private function processAction(): void $submission = $this->submissionManager->getEntityById((int)$_REQUEST['id']); if ($submission !== null) { foreach ($this->getDuplicatesAndCache(false) as $details) { - if ($details->getContentType() === $submission->getContentType() && - $details->getSourceBlogId() === $submission->getSourceBlogId() && - $details->getSourceId() === $submission->getSourceId() && - $details->getTargetBlogId() === $submission->getTargetBlogId() + if ($details->contentType === $submission->getContentType() && + $details->sourceBlogId === $submission->getSourceBlogId() && + $details->sourceId === $submission->getSourceId() && + $details->targetBlogId === $submission->getTargetBlogId() ) { $this->submissionManager->delete($submission); break; diff --git a/inc/Smartling/WP/Controller/FilterForm.php b/inc/Smartling/WP/Controller/FilterForm.php index 5f985fa9..35845143 100644 --- a/inc/Smartling/WP/Controller/FilterForm.php +++ b/inc/Smartling/WP/Controller/FilterForm.php @@ -8,8 +8,8 @@ class FilterForm extends ControllerAbstract implements WPHookInterface { - public const SLUG = AdminPage::SLUG . '_filter_form'; - public const ACTION_SAVE = self::SLUG . '_save'; + public const string SLUG = AdminPage::SLUG . '_filter_form'; + public const string ACTION_SAVE = self::SLUG . '_save'; public function register(): void { diff --git a/inc/Smartling/WP/Controller/LiveNotificationController.php b/inc/Smartling/WP/Controller/LiveNotificationController.php index 87eda7d6..5a460dc6 100644 --- a/inc/Smartling/WP/Controller/LiveNotificationController.php +++ b/inc/Smartling/WP/Controller/LiveNotificationController.php @@ -17,20 +17,20 @@ class LiveNotificationController implements WPHookInterface { use LoggerSafeTrait; - private const DELETE_NOTIFICATION_ACTION_NAME = 'smartling_delete_live_notification'; + private const string DELETE_NOTIFICATION_ACTION_NAME = 'smartling_delete_live_notification'; - private const FIREBASE_SPACE_ID = 'wordpress-connector'; - private const FIREBASE_OBJECT_ID = 'notifications'; + private const string FIREBASE_SPACE_ID = 'wordpress-connector'; + private const string FIREBASE_OBJECT_ID = 'notifications'; - private const CONFIG_CACHE_KEY = 'progress_tracker_config_cache_key'; - private const CONFIG_CACHE_TIME_SEC = 3600; + private const string CONFIG_CACHE_KEY = 'progress_tracker_config_cache_key'; + private const int CONFIG_CACHE_TIME_SEC = 3600; - private const UI_NOTIFICATION_IDENTIFIER_CLASS = 'smartling-notification-wrapper'; - private const UI_NOTIFICATION_IDENTIFIER_CLASS_GENERAL = 'smartling-notification-wrapper-general'; + private const string UI_NOTIFICATION_IDENTIFIER_CLASS = 'smartling-notification-wrapper'; + private const string UI_NOTIFICATION_IDENTIFIER_CLASS_GENERAL = 'smartling-notification-wrapper-general'; - public const SEVERITY_WARNING = 'notification-warning'; - public const SEVERITY_SUCCESS = 'notification-success'; - public const SEVERITY_ERROR = 'notification-error'; + public const string SEVERITY_WARNING = 'notification-warning'; + public const string SEVERITY_SUCCESS = 'notification-success'; + public const string SEVERITY_ERROR = 'notification-error'; private ApiWrapperInterface $apiWrapper; private SettingsManager $settingsManager; @@ -237,13 +237,13 @@ public function pushNotificationHandler(NotificationParameters $params): void { try { $this->apiWrapper->setNotificationRecord( - $this->settingsManager->getActiveProfileByProjectId($params->getProjectId()), + $this->settingsManager->getActiveProfileByProjectId($params->projectId), static::FIREBASE_SPACE_ID, static::FIREBASE_OBJECT_ID, - $params->getContentId(), + $params->contentId, [ - 'message' => $params->getMessage(), - 'severity' => $params->getSeverity(), + 'message' => $params->message, + 'severity' => $params->severity, ] ); } catch (\Exception $e) { diff --git a/inc/Smartling/WP/Controller/MediaRuleForm.php b/inc/Smartling/WP/Controller/MediaRuleForm.php index 16ab9731..0ae54995 100644 --- a/inc/Smartling/WP/Controller/MediaRuleForm.php +++ b/inc/Smartling/WP/Controller/MediaRuleForm.php @@ -10,8 +10,8 @@ class MediaRuleForm extends ControllerAbstract implements WPHookInterface { - public const SLUG = AdminPage::SLUG . '_media_form'; - public const ACTION_SAVE = self::SLUG . '_save'; + public const string SLUG = AdminPage::SLUG . '_media_form'; + public const string ACTION_SAVE = self::SLUG . '_save'; protected MediaAttachmentRulesManager $mediaAttachmentRulesManager; protected ReplacerFactory $replacerFactory; diff --git a/inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php b/inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php index a854d8b0..0b37409b 100644 --- a/inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php +++ b/inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php @@ -29,36 +29,36 @@ class PostBasedWidgetControllerStd extends WPAbstract implements WPHookInterface { use DetectContentChangeTrait; - private const WIDGET_NAME = 'smartling_connector_widget'; - public const WIDGET_DATA_NAME = 'smartling'; - private const CONNECTOR_NONCE = 'smartling_connector_nonce'; + private const string WIDGET_NAME = 'smartling_connector_widget'; + public const string WIDGET_DATA_NAME = 'smartling'; + private const string CONNECTOR_NONCE = 'smartling_connector_nonce'; protected string $servedContentType = 'undefined'; protected string $needSave = 'Need to have title'; protected string $noOriginalFound = 'No original post found'; protected string $abilityNeeded = 'edit_post'; - private const RESPONSE_AJAX_STATUS_FAIL = 'FAIL'; - private const RESPONSE_AJAX_STATUS_SUCCESS = 'SUCCESS'; + private const string RESPONSE_AJAX_STATUS_FAIL = 'FAIL'; + private const string RESPONSE_AJAX_STATUS_SUCCESS = 'SUCCESS'; - private const ERROR_KEY_FIELD_MISSING = 'field.missing'; - private const ERROR_MSG_FIELD_MISSING = 'Required field \'%s\' is missing.'; + private const string ERROR_KEY_FIELD_MISSING = 'field.missing'; + private const string ERROR_MSG_FIELD_MISSING = 'Required field \'%s\' is missing.'; - private const ERROR_KEY_NO_PROFILE_FOUND = 'profile.not.found'; - private const ERROR_MSG_NO_PROFILE_FOUND = 'No suitable configuration profile found.'; + private const string ERROR_KEY_NO_PROFILE_FOUND = 'profile.not.found'; + private const string ERROR_MSG_NO_PROFILE_FOUND = 'No suitable configuration profile found.'; - private const ERROR_KEY_TARGET_BLOG_EMPTY = 'no.target'; - private const ERROR_MSG_TARGET_BLOG_EMPTY = 'No target blog selected.'; + private const string ERROR_KEY_TARGET_BLOG_EMPTY = 'no.target'; + private const string ERROR_MSG_TARGET_BLOG_EMPTY = 'No target blog selected.'; - private const ERROR_KEY_NO_CONTENT = 'no.content'; - private const ERROR_MSG_NO_CONTENT = 'No source content selected.'; + private const string ERROR_KEY_NO_CONTENT = 'no.content'; + private const string ERROR_MSG_NO_CONTENT = 'No source content selected.'; - private const ERROR_KEY_INVALID_BLOG = 'invalid.blog'; - private const ERROR_MSG_INVALID_BLOG = 'Invalid blog value.'; + private const string ERROR_KEY_INVALID_BLOG = 'invalid.blog'; + private const string ERROR_MSG_INVALID_BLOG = 'Invalid blog value.'; - private const ERROR_KEY_TYPE_MISSING = 'content.type.missing'; - private const ERROR_MSG_TYPE_MISSING = 'Source content-type missing.'; + private const string ERROR_KEY_TYPE_MISSING = 'content.type.missing'; + private const string ERROR_MSG_TYPE_MISSING = 'Source content-type missing.'; private array $mutedTypes = [ 'attachment', diff --git a/inc/Smartling/WP/Controller/ShortcodeForm.php b/inc/Smartling/WP/Controller/ShortcodeForm.php index 2202a61c..c3c50126 100644 --- a/inc/Smartling/WP/Controller/ShortcodeForm.php +++ b/inc/Smartling/WP/Controller/ShortcodeForm.php @@ -8,8 +8,8 @@ class ShortcodeForm extends ControllerAbstract implements WPHookInterface { - public const SLUG = AdminPage::SLUG . '_shortcode_form'; - public const ACTION_SAVE = self::SLUG . '_save'; + public const string SLUG = AdminPage::SLUG . '_shortcode_form'; + public const string ACTION_SAVE = self::SLUG . '_save'; public function register(): void { diff --git a/inc/Smartling/WP/Controller/TaxonomyWidgetController.php b/inc/Smartling/WP/Controller/TaxonomyWidgetController.php index d4dcf799..18ca5601 100644 --- a/inc/Smartling/WP/Controller/TaxonomyWidgetController.php +++ b/inc/Smartling/WP/Controller/TaxonomyWidgetController.php @@ -18,7 +18,7 @@ class TaxonomyWidgetController extends WPAbstract implements WPHookInterface { - public const WIDGET_DATA_NAME = 'smartling'; + public const string WIDGET_DATA_NAME = 'smartling'; use CommonLogMessagesTrait; use DetectContentChangeTrait; diff --git a/inc/Smartling/WP/Controller/TestRunController.php b/inc/Smartling/WP/Controller/TestRunController.php index 1c04224b..beb0068e 100644 --- a/inc/Smartling/WP/Controller/TestRunController.php +++ b/inc/Smartling/WP/Controller/TestRunController.php @@ -33,10 +33,10 @@ class TestRunController extends WPAbstract implements WPHookInterface { - private const TEST_RUN_JOB_NAME = 'Test Run Job'; + private const string TEST_RUN_JOB_NAME = 'Test Run Job'; - public const ACTION_CLEAR_FLAG = 'clear_flag'; - public const SLUG = 'smartling_test_run'; + public const string ACTION_CLEAR_FLAG = 'clear_flag'; + public const string SLUG = 'smartling_test_run'; private ContentRelationsDiscoveryService $contentRelationDiscoveryService; private ApiWrapperInterface $apiWrapper; @@ -135,7 +135,7 @@ public function widget(): void SimpleStorageHelper::drop(TestRunHelper::TEST_RUN_BLOG_ID_SETTING_NAME); } $viewData = $this->buildViewData(); - if ($viewData->getNew() + $viewData->getInProgress() + $viewData->getCompleted() + $viewData->getFailed() === 0) { + if ($viewData->new + $viewData->inProgress + $viewData->completed + $viewData->failed === 0) { $this->getLogger()->notice('A blog was selected for test run, but no entries uploaded, clearing test run blog'); SimpleStorageHelper::drop(TestRunHelper::TEST_RUN_BLOG_ID_SETTING_NAME); $viewData = $this->buildViewData(); diff --git a/inc/Smartling/WP/Table/BulkSubmitTableWidget.php b/inc/Smartling/WP/Table/BulkSubmitTableWidget.php index 1a17273d..5827f077 100644 --- a/inc/Smartling/WP/Table/BulkSubmitTableWidget.php +++ b/inc/Smartling/WP/Table/BulkSubmitTableWidget.php @@ -33,17 +33,17 @@ class BulkSubmitTableWidget extends SmartlingListTable use CommonLogMessagesTrait; use LoggerSafeTrait; - private const CUSTOM_CONTROLS_NAMESPACE = 'smartling-bulk-submit-page'; + private const string CUSTOM_CONTROLS_NAMESPACE = 'smartling-bulk-submit-page'; /** * base name of Content-type filtering select */ - private const CONTENT_TYPE_SELECT_ELEMENT_NAME = 'content-type'; - private const SUBMISSION_STATUS_SELECT_ELEMENT_NAME = 'submission-status'; + private const string CONTENT_TYPE_SELECT_ELEMENT_NAME = 'content-type'; + private const string SUBMISSION_STATUS_SELECT_ELEMENT_NAME = 'submission-status'; /** * base name of title search textbox */ - private const TITLE_SEARCH_TEXTBOX_ELEMENT_NAME = 'title-search'; + private const string TITLE_SEARCH_TEXTBOX_ELEMENT_NAME = 'title-search'; private array $defaultValues = [ self::CONTENT_TYPE_SELECT_ELEMENT_NAME => 'post', diff --git a/inc/Smartling/WP/Table/DuplicateSubmissions.php b/inc/Smartling/WP/Table/DuplicateSubmissions.php index 1659e1cc..6feb601b 100644 --- a/inc/Smartling/WP/Table/DuplicateSubmissions.php +++ b/inc/Smartling/WP/Table/DuplicateSubmissions.php @@ -62,27 +62,33 @@ public function prepare_items(): void { $data = []; $this->_column_headers = [$this->get_columns(), [], []]; - $contentType = $this->duplicateSubmissionDetails->getContentType(); - $sourceId = $this->duplicateSubmissionDetails->getSourceId(); + $duplicateSubmissionDetails = $this->duplicateSubmissionDetails; + $contentType = $duplicateSubmissionDetails->contentType; + $duplicateSubmissionDetails1 = $this->duplicateSubmissionDetails; + $sourceId = $duplicateSubmissionDetails1->sourceId; + $duplicateSubmissionDetails2 = $this->duplicateSubmissionDetails; $data[] = $this->siteHelper->withBlog( - $this->duplicateSubmissionDetails->getTargetBlogId(), + $duplicateSubmissionDetails2->targetBlogId, function () use ($contentType, $sourceId) { $data = []; + $duplicateSubmissionDetails1 = $this->duplicateSubmissionDetails; + $duplicateSubmissionDetails2 = $this->duplicateSubmissionDetails; foreach ( $this->submissionManager->find([ SubmissionEntity::FIELD_CONTENT_TYPE => $contentType, - SubmissionEntity::FIELD_SOURCE_BLOG_ID => $this->duplicateSubmissionDetails->getSourceBlogId(), + SubmissionEntity::FIELD_SOURCE_BLOG_ID => $duplicateSubmissionDetails1->sourceBlogId, SubmissionEntity::FIELD_SOURCE_ID => $sourceId, - SubmissionEntity::FIELD_TARGET_BLOG_ID => $this->duplicateSubmissionDetails->getTargetBlogId(), + SubmissionEntity::FIELD_TARGET_BLOG_ID => $duplicateSubmissionDetails2->targetBlogId, ]) as $target ) { $editLink = $this->getEditLink($contentType, $target->getTargetId()); + $duplicateSubmissionDetails = $this->duplicateSubmissionDetails; $data[] = [ 'targetId' => $target->getTargetId(), 'targetEdit' => $editLink === null ? '' : "Edit", 'action' => 'getId()}&_wpnonce={$this->nonce}" . '">Delete' ), diff --git a/inc/Smartling/WP/Table/SubmissionTableWidget.php b/inc/Smartling/WP/Table/SubmissionTableWidget.php index 13cb87fd..f461fae7 100644 --- a/inc/Smartling/WP/Table/SubmissionTableWidget.php +++ b/inc/Smartling/WP/Table/SubmissionTableWidget.php @@ -31,26 +31,26 @@ class SubmissionTableWidget extends SmartlingListTable use CommonLogMessagesTrait; use LoggerSafeTrait; - private const ACTION_CHECK_STATUS = 'checkStatus'; - public const ACTION_DOWNLOAD = 'download'; - private const ACTION_LOCK = 'lock'; - private const ACTION_UNLOCK = 'unlock'; - private const ACTION_UPLOAD = 'upload'; + private const string ACTION_CHECK_STATUS = 'checkStatus'; + public const string ACTION_DOWNLOAD = 'download'; + private const string ACTION_LOCK = 'lock'; + private const string ACTION_UNLOCK = 'unlock'; + private const string ACTION_UPLOAD = 'upload'; /** * base name of Content-type filtering select */ - private const CONTENT_TYPE_SELECT_ELEMENT_NAME = 'content-type'; + private const string CONTENT_TYPE_SELECT_ELEMENT_NAME = 'content-type'; /** * base name of status filtering select */ - private const SUBMISSION_STATUS_SELECT_ELEMENT_NAME = 'status'; + private const string SUBMISSION_STATUS_SELECT_ELEMENT_NAME = 'status'; - private const SUBMISSION_OUTDATED_STATE = 'state_outdated'; - private const SUBMISSION_LOCKED_STATE = 'state_locked'; - private const SUBMISSION_CLONED_STATE = 'state_cloned'; - private const SUBMISSION_TARGET_LOCALE = 'target-locale'; + private const string SUBMISSION_OUTDATED_STATE = 'state_outdated'; + private const string SUBMISSION_LOCKED_STATE = 'state_locked'; + private const string SUBMISSION_CLONED_STATE = 'state_cloned'; + private const string SUBMISSION_TARGET_LOCALE = 'target-locale'; private string $_custom_controls_namespace = 'smartling-submissions-page'; diff --git a/inc/Smartling/WP/View/DuplicateSubmissionsCleaner.php b/inc/Smartling/WP/View/DuplicateSubmissionsCleaner.php index 4d986f89..86330cc4 100644 --- a/inc/Smartling/WP/View/DuplicateSubmissionsCleaner.php +++ b/inc/Smartling/WP/View/DuplicateSubmissionsCleaner.php @@ -15,16 +15,16 @@ foreach ($duplicates as $set) { assert($set instanceof DuplicateSubmissions); $details = $set->getDuplicateSubmissionDetails(); - $editLink = $set->getEditLink($details->getContentType(), $details->getSourceId()); + $editLink = $set->getEditLink($details->contentType, $details->sourceId); echo '

Duplicate submissions for '; if ($editLink !== null) { echo ""; } - echo "{$details->getContentType()} id {$details->getSourceId()}"; + echo "{$details->contentType} id {$details->sourceId}"; if ($editLink !== null) { echo ''; } - echo " in target blog {$details->getTargetBlogId()}

"; + echo " in target blog {$details->targetBlogId}"; $set->prepare_items(); $set->display(); } diff --git a/inc/Smartling/WP/View/TestRun.php b/inc/Smartling/WP/View/TestRun.php index b8ea2d33..ebc5ac1d 100644 --- a/inc/Smartling/WP/View/TestRun.php +++ b/inc/Smartling/WP/View/TestRun.php @@ -14,10 +14,10 @@

Test run

Send all posts and pages and their related content one level deep for pseudo translation, and check the result for known issues. After a test run completes you should check it too, to see any issues that were not detected. Expected result after a test run is that all text and media content gets translated.

getTestBlogId() === null && count($viewData->getBlogs()) === 0) { +if ($viewData->testBlogId === null && count($viewData->blogs) === 0) { echo '

You need to either add a new site or completely remove submissions from an existing one to start a test run.

'; } -if ($viewData->getTestBlogId() === null) { +if ($viewData->testBlogId === null) { ?>
@@ -26,7 +26,7 @@ getBlogs()), + HtmlTagGeneratorHelper::renderSelectOptions(null, $viewData->blogs), ['id' => 'targetBlogId', 'name' => 'targetBlogId'] )?> @@ -71,7 +71,7 @@ getUploadCronLastFinishTime() < time() - $viewData->getUploadCronIntervalSeconds() * 2) { + if ($viewData->uploadCronLastFinishTime < time() - $viewData->uploadCronIntervalSeconds * 2) { echo '

Warning: Please verify cron jobs are set up properly in your WordPress installation. If the cron jobs are not set up properly, automatic uploads and downloads will not work, you need to manually trigger the cron jobs from the Settings

'; } ?> @@ -82,25 +82,25 @@ Pending upload - getNew()?> + new?> Pending download - getInProgress()?> + inProgress?> Completed - getCompleted()?> + completed?> Failed - getFailed()?> + failed?> getNew() + $viewData->getInProgress() === 0) { +if ($viewData->new + $viewData->inProgress === 0) { echo '

Test run has completed. You should now review the translated blog to check if strings everywhere are replaced with pseudo translations.

'; - if ($viewData->getTestBlogId() !== null) { + if ($viewData->testBlogId !== null) { echo sprintf('
(to allow regular translations to be applied.)
', get_admin_url(null, 'admin.php?page=' . $this::SLUG), $this::ACTION_CLEAR_FLAG); } } else { diff --git a/readme.txt b/readme.txt index 665d2816..d69a14c3 100755 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: smartling Tags: translation, localization, localisation, translate, multilingual, smartling, internationalization, internationalisation, automation, international Requires at least: 5.5 Tested up to: 6.6.2 -Requires PHP: 8.0 -Stable tag: 3.10.0 +Requires PHP: 8.3 +Stable tag: 4.0.0 License: GPLv2 or later Translate content in WordPress quickly and seamlessly with Smartling, the industry-leading Translation Management System. @@ -62,6 +62,9 @@ Additional information on the Smartling Connector for WordPress can be found [he 3. Track translation status within WordPress from the Submissions Board. View overall progress of submitted translation requests as well as resend updated content. == Changelog == += 4.0.0 = +* Minimum required PHP version is now 8.3! + = 3.10.0 = * Remove a cloned status when the user requests translation of the previously cloned submission diff --git a/smartling-connector.php b/smartling-connector.php index 2b71daf7..52fc8d6f 100755 --- a/smartling-connector.php +++ b/smartling-connector.php @@ -11,7 +11,7 @@ * Plugin Name: Smartling Connector * Plugin URI: https://www.smartling.com/products/automate/integrations/wordpress/ * Description: Integrate your WordPress site with Smartling to upload your content and download translations. - * Version: 3.10.0 + * Version: 4.0.0 * Author: Smartling * Author URI: https://www.smartling.com * License: GPL-2.0+ @@ -19,7 +19,7 @@ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Text Domain: smartling-connector * Domain Path: /languages - * Requires PHP: 8.0 + * Requires PHP: 8.3 * Elementor tested up to: 3.20.2 */ diff --git a/tests/IntegrationTests/tests/SubmissionUploadTest.php b/tests/IntegrationTests/tests/SubmissionUploadTest.php index 5aa83e85..c5ddfa9b 100644 --- a/tests/IntegrationTests/tests/SubmissionUploadTest.php +++ b/tests/IntegrationTests/tests/SubmissionUploadTest.php @@ -7,6 +7,7 @@ use Smartling\DbAl\UploadQueueManager; use Smartling\Models\IntegerIterator; use Smartling\Models\JobInformation; +use Smartling\Models\UploadQueueItem; use Smartling\Models\UserTranslationRequest; use Smartling\Services\ContentRelationsDiscoveryService; use Smartling\Submissions\SubmissionEntity; @@ -101,8 +102,8 @@ public function testUploadAttachment() $submissionsToUpload = 0; do { $uploadQueueItem = $uploadQueueManager->dequeue(); - $submissionsToUpload += count($uploadQueueItem->getSubmissions()); - $batchUid = $uploadQueueItem->getBatchUid(); + $submissionsToUpload += count($uploadQueueItem->submissions); + $batchUid = $uploadQueueItem->batchUid; $this->assertNotEquals('', $batchUid); } while ($uploadQueueManager->count() > 0); $this->assertEquals(2, $submissionsToUpload); diff --git a/tests/Models/TranslationRequestTest.php b/tests/Models/TranslationRequestTest.php index 77fb47dc..78b44cc5 100644 --- a/tests/Models/TranslationRequestTest.php +++ b/tests/Models/TranslationRequestTest.php @@ -3,6 +3,7 @@ namespace Smartling\Tests\Models; use PHPUnit\Framework\TestCase; +use Smartling\Models\JobInformation; use Smartling\Models\UserTranslationRequest; use Smartling\Services\ContentRelationsHandler; @@ -39,11 +40,17 @@ public function testFromArray() $this->assertEquals($sourceId, $x->getContentId()); $this->assertEquals($sourceContentType, $x->getContentType()); $this->assertEquals([1 => [$targetBlogId => ['post' => [3]]], 2 => [$targetBlogId => ['attachment' => [5]]]], $x->getRelationsOrdered()); - $this->assertFalse($x->getJobInformation()->isAuthorize()); - $this->assertEquals($jobDescription, $x->getJobInformation()->getDescription()); - $this->assertEquals($jobDueDate, $x->getJobInformation()->getDueDate()); - $this->assertEquals($jobName, $x->getJobInformation()->getName()); - $this->assertEquals($jobTimeZone, $x->getJobInformation()->getTimeZone()); - $this->assertEquals($jobUid, $x->getJobInformation()->getId()); + $jobInformation1 = $x->getJobInformation(); + $this->assertFalse($jobInformation1->authorize); + $jobInformation3 = $x->getJobInformation(); + $this->assertEquals($jobDescription, $jobInformation3->description); + $jobInformation4 = $x->getJobInformation(); + $this->assertEquals($jobDueDate, $jobInformation4->dueDate); + $jobInformation2 = $x->getJobInformation(); + $this->assertEquals($jobName, $jobInformation2->name); + $jobInformation5 = $x->getJobInformation(); + $this->assertEquals($jobTimeZone, $jobInformation5->timeZone); + $jobInformation = $x->getJobInformation(); + $this->assertEquals($jobUid, $jobInformation->id); } } diff --git a/tests/Smartling/Models/UploadQueueItemTest.php b/tests/Smartling/Models/UploadQueueItemTest.php index fe68b3f5..a5e50d4a 100644 --- a/tests/Smartling/Models/UploadQueueItemTest.php +++ b/tests/Smartling/Models/UploadQueueItemTest.php @@ -14,15 +14,16 @@ public function testRemoveSubmission() $s2 = new SubmissionEntity(); $s2->setId(2); $x = new UploadQueueItem([$s1, $s2], '', new IntStringPairCollection([new IntStringPair(1, 'a'), new IntStringPair(2, 'b')])); - foreach ($x->getSubmissions() as $submission) { + foreach ($x->submissions as $submission) { if ($submission->getId() === 1) { $x = $x->removeSubmission($submission); } } - $this->assertCount(1, $x->getSubmissions()); - $this->assertEquals(2, $x->getSubmissions()[0]->getId()); - $this->assertCount(1, $x->getSmartlingLocales()->getArray()); - $this->assertEquals('b', $x->getSmartlingLocales()->getArray()[0]->getValue()); + $this->assertCount(1, $x->submissions); + $this->assertEquals(2, ($x->submissions)[0]->getId()); + $this->assertCount(1, $x->smartlingLocales->getArray()); + $intStringPair = $x->smartlingLocales->getArray()[0]; + $this->assertEquals('b', $intStringPair->value); } public function testSubmissionsAltered() @@ -32,10 +33,10 @@ public function testSubmissionsAltered() $s2 = new SubmissionEntity(); $s2->setId(2); $x = new UploadQueueItem([$s1, $s2], '', new IntStringPairCollection([new IntStringPair(1, 'a'), new IntStringPair(2, 'b')])); - foreach ($x->getSubmissions() as $submission) { + foreach ($x->submissions as $submission) { $submission->setStatus(SubmissionEntity::SUBMISSION_STATUS_COMPLETED); } - foreach ($x->getSubmissions() as $submission) { + foreach ($x->submissions as $submission) { $this->assertEquals(SubmissionEntity::SUBMISSION_STATUS_COMPLETED, $submission->getStatus()); } }