From 27a01275569ea5c59888c8d3a3f56b85f64646fa Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 7 Jan 2024 15:41:20 +0200 Subject: [PATCH] cs --- application/Espo/Core/Job/JobFactory.php | 6 ++---- application/Espo/Core/Job/JobManager.php | 1 - application/Espo/Core/Job/JobRunner.php | 10 +++++----- application/Espo/Core/Job/JobScheduler.php | 5 +++-- application/Espo/Core/Job/JobTask.php | 2 +- application/Espo/Core/Job/PreparatorFactory.php | 2 +- application/Espo/Core/Job/ScheduleProcessor.php | 6 +++--- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/application/Espo/Core/Job/JobFactory.php b/application/Espo/Core/Job/JobFactory.php index db7e34d4c5..96e453bca6 100644 --- a/application/Espo/Core/Job/JobFactory.php +++ b/application/Espo/Core/Job/JobFactory.php @@ -52,7 +52,7 @@ class JobFactory $className = $this->getClassName($name); if (!$className) { - throw new Error("Job '{$name}' not found."); + throw new Error("Job '$name' not found."); } return $this->createByClassName($className); @@ -66,9 +66,7 @@ class JobFactory */ public function createByClassName(string $className): object { - $job = $this->injectableFactory->create($className); - - return $job; + return $this->injectableFactory->create($className); } /** diff --git a/application/Espo/Core/Job/JobManager.php b/application/Espo/Core/Job/JobManager.php index 4906c5ba00..e12826c789 100644 --- a/application/Espo/Core/Job/JobManager.php +++ b/application/Espo/Core/Job/JobManager.php @@ -29,7 +29,6 @@ namespace Espo\Core\Job; -use Espo\Core\Exceptions\Error; use Espo\Core\Job\QueueProcessor\Params; use Espo\Core\Utils\File\Manager as FileManager; use Espo\Core\Utils\Log; diff --git a/application/Espo/Core/Job/JobRunner.php b/application/Espo/Core/Job/JobRunner.php index 3c22777579..3f3642725a 100644 --- a/application/Espo/Core/Job/JobRunner.php +++ b/application/Espo/Core/Job/JobRunner.php @@ -91,11 +91,11 @@ class JobRunner $jobEntity = $this->entityManager->getEntityById(JobEntity::ENTITY_TYPE, $id); if (!$jobEntity) { - throw new RuntimeException("Job '{$id}' not found."); + throw new RuntimeException("Job '$id' not found."); } if ($jobEntity->getStatus() !== Status::READY) { - throw new RuntimeException("Can't run job '{$id}' with not Ready status."); + throw new RuntimeException("Can't run job '$id' with not Ready status."); } $this->setJobRunning($jobEntity); @@ -131,7 +131,7 @@ class JobRunner else { $id = $jobEntity->getId(); - throw new Error("Not runnable job '{$id}'."); + throw new Error("Not runnable job '$id'."); } } catch (Throwable $e) { @@ -139,7 +139,7 @@ class JobRunner $jobId = $jobEntity->hasId() ? $jobEntity->getId() : null; - $msg = "JobManager: Failed job running, job '{$jobId}'. " . + $msg = "JobManager: Failed job running, job '$jobId'. " . $e->getMessage() . "; at " . $e->getFile() . ":" . $e->getLine() . "."; if ($this->config->get('logger.printTrace')) { @@ -266,7 +266,7 @@ class JobRunner } if (!method_exists($service, $methodName)) { - throw new Error("No method '{$methodName}' in service '{$serviceName}'."); + throw new Error("No method '$methodName' in service '$serviceName'."); } $service->$methodName( diff --git a/application/Espo/Core/Job/JobScheduler.php b/application/Espo/Core/Job/JobScheduler.php index fa72b8ce0b..34010324d1 100644 --- a/application/Espo/Core/Job/JobScheduler.php +++ b/application/Espo/Core/Job/JobScheduler.php @@ -65,7 +65,7 @@ class JobScheduler public function setClassName(string $className): self { if (!class_exists($className)) { - throw new RuntimeException("Class '{$className}' does not exist."); + throw new RuntimeException("Class '$className' does not exist."); } $class = new ReflectionClass($className); @@ -74,7 +74,7 @@ class JobScheduler !$class->implementsInterface(Job::class) && !$class->implementsInterface(JobDataLess::class) ) { - throw new RuntimeException("Class '{$className}' does not implement 'Job' or 'JobDataLess' interface."); + throw new RuntimeException("Class '$className' does not implement 'Job' or 'JobDataLess' interface."); } $this->className = $className; @@ -115,6 +115,7 @@ class JobScheduler $timeCopy = $time; if (!is_null($time) && !$time instanceof DateTimeImmutable) { + /** @noinspection PhpParamsInspection */ $timeCopy = DateTimeImmutable::createFromMutable($time); } diff --git a/application/Espo/Core/Job/JobTask.php b/application/Espo/Core/Job/JobTask.php index 071114a1cb..8ddcae1897 100644 --- a/application/Espo/Core/Job/JobTask.php +++ b/application/Espo/Core/Job/JobTask.php @@ -68,7 +68,7 @@ class JobTask extends AsyncTask catch (Throwable $e) { $log = $app->getContainer()->getByClass(Log::class); - $log->error("JobTask: Failed to run job '{$this->jobId}'. Error: " . $e->getMessage()); + $log->error("JobTask: Failed to run job '$this->jobId'. Error: " . $e->getMessage()); } } } diff --git a/application/Espo/Core/Job/PreparatorFactory.php b/application/Espo/Core/Job/PreparatorFactory.php index 54757dcc33..d4a2f8598b 100644 --- a/application/Espo/Core/Job/PreparatorFactory.php +++ b/application/Espo/Core/Job/PreparatorFactory.php @@ -49,7 +49,7 @@ class PreparatorFactory $className = $this->metadataProvider->getPreparatorClassName($name); if (!$className) { - throw new RuntimeException("Preparator for job '{$name}' not found."); + throw new RuntimeException("Preparator for job '$name' not found."); } return $this->injectableFactory->create($className); diff --git a/application/Espo/Core/Job/ScheduleProcessor.php b/application/Espo/Core/Job/ScheduleProcessor.php index ca26b4f08d..3fd1b3e67b 100644 --- a/application/Espo/Core/Job/ScheduleProcessor.php +++ b/application/Espo/Core/Job/ScheduleProcessor.php @@ -81,7 +81,7 @@ class ScheduleProcessor catch (Throwable $e) { $id = $scheduledJob->getId(); - $this->log->error("Scheduled Job '{$id}': " . $e->getMessage()); + $this->log->error("Scheduled Job '$id': " . $e->getMessage()); } } } @@ -166,7 +166,7 @@ class ScheduleProcessor } catch (Exception $e) { $this->log->error( - "Scheduled Job '{$id}': Scheduling expression error: " . + "Scheduled Job '$id': Scheduling expression error: " . $e->getMessage() . '.'); return null; @@ -176,7 +176,7 @@ class ScheduleProcessor return $cronExpression->getNextRunDate()->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT); } catch (Exception) { - $this->log->error("Scheduled Job '{$id}': Unsupported scheduling expression '{$scheduling}'."); + $this->log->error("Scheduled Job '$id': Unsupported scheduling expression '$scheduling'."); return null; }