diff --git a/application/Espo/Core/Templates/Repositories/Base.php b/application/Espo/Core/Templates/Repositories/Base.php index d58d7ae664..09d980f99c 100644 --- a/application/Espo/Core/Templates/Repositories/Base.php +++ b/application/Espo/Core/Templates/Repositories/Base.php @@ -29,6 +29,11 @@ namespace Espo\Core\Templates\Repositories; -class Base extends \Espo\Core\Repositories\Database -{ -} +use Espo\Core\ORM\Entity; +use Espo\Core\Repositories\Database; + +/** + * @extends Database + */ +class Base extends Database +{} diff --git a/application/Espo/Core/Templates/Repositories/BasePlus.php b/application/Espo/Core/Templates/Repositories/BasePlus.php index 5b10f00847..cb7357a56c 100644 --- a/application/Espo/Core/Templates/Repositories/BasePlus.php +++ b/application/Espo/Core/Templates/Repositories/BasePlus.php @@ -29,6 +29,11 @@ namespace Espo\Core\Templates\Repositories; -class BasePlus extends \Espo\Core\Repositories\Database -{ -} +use Espo\Core\ORM\Entity; +use Espo\Core\Repositories\Database; + +/** + * @extends Database + */ +class BasePlus extends Database +{} diff --git a/application/Espo/Core/Templates/Repositories/Company.php b/application/Espo/Core/Templates/Repositories/Company.php index 6ff7821a56..f045737af9 100644 --- a/application/Espo/Core/Templates/Repositories/Company.php +++ b/application/Espo/Core/Templates/Repositories/Company.php @@ -29,6 +29,11 @@ namespace Espo\Core\Templates\Repositories; -class Company extends \Espo\Core\Repositories\Database -{ -} +use Espo\Core\ORM\Entity; +use Espo\Core\Repositories\Database; + +/** + * @extends Database + */ +class Company extends Database +{} diff --git a/application/Espo/Core/Templates/Repositories/Person.php b/application/Espo/Core/Templates/Repositories/Person.php index 81b8bf08e4..c52246681a 100644 --- a/application/Espo/Core/Templates/Repositories/Person.php +++ b/application/Espo/Core/Templates/Repositories/Person.php @@ -29,5 +29,11 @@ namespace Espo\Core\Templates\Repositories; -class Person extends \Espo\Core\Repositories\Database +use Espo\Core\ORM\Entity; +use Espo\Core\Repositories\Database; + +/** + * @extends Database + */ +class Person extends Database {} diff --git a/application/Espo/Core/WebSocket/Pusher.php b/application/Espo/Core/WebSocket/Pusher.php index 1797e84031..d92fd340ee 100644 --- a/application/Espo/Core/WebSocket/Pusher.php +++ b/application/Espo/Core/WebSocket/Pusher.php @@ -30,6 +30,7 @@ namespace Espo\Core\WebSocket; use Ratchet\ConnectionInterface; +use Ratchet\Wamp\Topic; use Ratchet\Wamp\WampServerInterface; use Symfony\Component\Process\PhpExecutableFinder; @@ -39,47 +40,25 @@ use RuntimeException; class Pusher implements WampServerInterface { - /** - * @var string[] - */ + /** @var string[] */ private $categoryList; - - /** - * @var array> - */ + /** @var array> */ protected $categoriesData; - protected bool $isDebugMode = false; - - /** - * @var array - */ + /** @var array */ protected $connectionIdUserIdMap = []; - - /** - * @var array - */ + /** @var array */ protected $userIdConnectionIdListMap = []; - - /** - * @var array - */ + /** @var array */ protected $connectionIdTopicIdListMap = []; - - /** - * @var array - */ + /** @var array */ protected $connections = []; - - /** - * @var array> - */ + /** @var array> */ protected $topicHash = []; - private string $phpExecutablePath; /** - * @param array> $categoriesData + * @param array> $categoriesData */ public function __construct( array $categoriesData = [], @@ -106,7 +85,7 @@ class Pusher implements WampServerInterface } /** - * @param \Ratchet\Wamp\Topic $topic + * @param Topic $topic * @return void */ public function onSubscribe(ConnectionInterface $connection, $topic) @@ -165,7 +144,7 @@ class Pusher implements WampServerInterface } /** - * @param \Ratchet\Wamp\Topic $topic + * @param Topic $topic * @return void */ public function onUnSubscribe(ConnectionInterface $connection, $topic) @@ -208,7 +187,7 @@ class Pusher implements WampServerInterface } /** - * @return array + * @return array */ protected function getCategoryData(string $topicId): array { @@ -230,7 +209,7 @@ class Pusher implements WampServerInterface } /** - * @return array + * @return array */ protected function getParamsFromTopicId(string $topicId): array { @@ -256,7 +235,7 @@ class Pusher implements WampServerInterface } /** - * @param \Ratchet\Wamp\Topic $topic + * @param Topic $topic */ protected function getAccessCheckCommandForTopic(ConnectionInterface $connection, $topic): ?string { @@ -291,7 +270,7 @@ class Pusher implements WampServerInterface } /** - * @param \Ratchet\Wamp\Topic $topic + * @param Topic $topic * @return string */ protected function getTopicCategory($topic) @@ -486,8 +465,8 @@ class Pusher implements WampServerInterface /** * @param string $id - * @param \Ratchet\Wamp\Topic $topic - * @param array $params + * @param Topic $topic + * @param array $params * @return void */ public function onCall(ConnectionInterface $connection, $id, $topic, array $params) @@ -502,10 +481,10 @@ class Pusher implements WampServerInterface } /** - * @param \Ratchet\Wamp\Topic $topic + * @param Topic $topic * @param string $event - * @param array $exclude - * @param array $eligible + * @param array $exclude + * @param array $eligible * @return void */ public function onPublish(ConnectionInterface $connection, $topic, $event, array $exclude, array $eligible) diff --git a/application/Espo/Core/WebSocket/SenderFactory.php b/application/Espo/Core/WebSocket/SenderFactory.php index a79c1058a2..7f2d8ddaf6 100644 --- a/application/Espo/Core/WebSocket/SenderFactory.php +++ b/application/Espo/Core/WebSocket/SenderFactory.php @@ -41,18 +41,13 @@ use RuntimeException; */ class SenderFactory implements Factory { - private $injectableFactory; - private $config; - private $metadata; - private const DEFAULT_MESSAGER = 'ZeroMQ'; - public function __construct(InjectableFactory $injectableFactory, Config $config, Metadata $metadata) - { - $this->injectableFactory = $injectableFactory; - $this->config = $config; - $this->metadata = $metadata; - } + public function __construct( + private InjectableFactory $injectableFactory, + private Config $config, + private Metadata $metadata + ) {} public function create(): Sender { diff --git a/application/Espo/Core/WebSocket/ServerStarter.php b/application/Espo/Core/WebSocket/ServerStarter.php index e123247d6f..0f696c6602 100644 --- a/application/Espo/Core/WebSocket/ServerStarter.php +++ b/application/Espo/Core/WebSocket/ServerStarter.php @@ -46,39 +46,30 @@ use Ratchet\Wamp\WampServer; */ class ServerStarter { - private $subscriber; - - private $categoriesData; - - private $phpExecutablePath; - + /** @var array> */ + private array $categoriesData; + private ?string $phpExecutablePath; private bool $isDebugMode; - private bool $useSecureServer; + private string $port; - /** - * @var string - */ - private $port; - - private $config; - - public function __construct(Subscriber $subscriber, Config $config, Metadata $metadata) - { - $this->subscriber = $subscriber; - $this->config = $config; - + public function __construct( + private Subscriber $subscriber, + private Config $config, + Metadata $metadata + ) { $this->categoriesData = $metadata->get(['app', 'webSocket', 'categories'], []); - $this->phpExecutablePath = $config->get('phpExecutablePath'); $this->isDebugMode = (bool) $config->get('webSocketDebugMode'); $this->useSecureServer = (bool) $config->get('webSocketUseSecureServer'); - $this->port = $this->config->get('webSocketPort'); + $port = $this->config->get('webSocketPort'); - if (!$this->port) { - $this->port = $this->useSecureServer ? '8443' : '8080'; + if (!$port) { + $port = $this->useSecureServer ? '8443' : '8080'; } + + $this->port = $port; } /** @@ -113,7 +104,7 @@ class ServerStarter } /** - * @return array + * @return array */ protected function getSslParams(): array { diff --git a/application/Espo/Core/WebSocket/Submission.php b/application/Espo/Core/WebSocket/Submission.php index a5cb216b4f..bb1e634624 100644 --- a/application/Espo/Core/WebSocket/Submission.php +++ b/application/Espo/Core/WebSocket/Submission.php @@ -37,15 +37,10 @@ use Throwable; class Submission { - private $sender; - - private $log; - - public function __construct(Sender $sender, Log $log) - { - $this->sender = $sender; - $this->log = $log; - } + public function __construct( + private Sender $sender, + private Log $log + ) {} /** * Submit to a web-socket server. diff --git a/application/Espo/Core/WebSocket/SubscriberFactory.php b/application/Espo/Core/WebSocket/SubscriberFactory.php index f2cdcc3483..cc98591073 100644 --- a/application/Espo/Core/WebSocket/SubscriberFactory.php +++ b/application/Espo/Core/WebSocket/SubscriberFactory.php @@ -33,6 +33,7 @@ use Espo\Core\InjectableFactory; use Espo\Core\Utils\Config; use Espo\Core\Utils\Metadata; use Espo\Core\Binding\Factory; + use RuntimeException; /** diff --git a/application/Espo/Core/WebSocket/ZeroMQSender.php b/application/Espo/Core/WebSocket/ZeroMQSender.php index 5f6715ff3c..f691ce0afb 100644 --- a/application/Espo/Core/WebSocket/ZeroMQSender.php +++ b/application/Espo/Core/WebSocket/ZeroMQSender.php @@ -36,14 +36,10 @@ use ZMQ; class ZeroMQSender implements Sender { - private $config; - private const DSN = 'tcp://localhost:5555'; - public function __construct(Config $config) - { - $this->config = $config; - } + public function __construct(private Config $config) + {} public function send(string $message): void { diff --git a/application/Espo/Core/WebSocket/ZeroMQSubscriber.php b/application/Espo/Core/WebSocket/ZeroMQSubscriber.php index af8238e127..8f0bc425da 100644 --- a/application/Espo/Core/WebSocket/ZeroMQSubscriber.php +++ b/application/Espo/Core/WebSocket/ZeroMQSubscriber.php @@ -40,14 +40,10 @@ use ZMQ; class ZeroMQSubscriber implements Subscriber { - private $config; - private const DSN = 'tcp://127.0.0.1:5555'; - public function __construct(Config $config) - { - $this->config = $config; - } + public function __construct(private Config $config) + {} public function subscribe(Pusher $pusher, LoopInterface $loop): void { diff --git a/application/Espo/Core/Webhook/Manager.php b/application/Espo/Core/Webhook/Manager.php index 13da61f11d..f71e8f417f 100644 --- a/application/Espo/Core/Webhook/Manager.php +++ b/application/Espo/Core/Webhook/Manager.php @@ -29,19 +29,15 @@ namespace Espo\Core\Webhook; -use Espo\Core\{ - Utils\Config, - Utils\DataCache, - Utils\FieldUtil, - ORM\EntityManager, - ORM\Entity, - Utils\Log, -}; +use Espo\Core\ORM\Entity; +use Espo\Core\ORM\EntityManager; +use Espo\Core\Utils\Config; +use Espo\Core\Utils\DataCache; +use Espo\Core\Utils\FieldUtil; +use Espo\Core\Utils\Log; -use Espo\Entities\{ - WebhookEventQueueItem, - Webhook, -}; +use Espo\Entities\Webhook; +use Espo\Entities\WebhookEventQueueItem; use RuntimeException; @@ -52,38 +48,23 @@ class Manager { private string $cacheKey = 'webhooks'; - /** - * @var string[] - */ - protected $skipAttributeList = ['isFollowed', 'modifiedAt', 'modifiedBy']; + /** @var string[] */ + protected $skipAttributeList = [ + 'isFollowed', + 'modifiedAt', + 'modifiedBy' + ]; - /** - * @var ?array - */ + /** @var ?array */ private $data = null; - private Config $config; - - private DataCache $dataCache; - - private EntityManager $entityManager; - - private FieldUtil $fieldUtil; - - private Log $log; - public function __construct( - Config $config, - DataCache $dataCache, - EntityManager $entityManager, - FieldUtil $fieldUtil, - Log $log + private Config $config, + private DataCache $dataCache, + private EntityManager $entityManager, + private FieldUtil $fieldUtil, + private Log $log ) { - $this->config = $config; - $this->dataCache = $dataCache; - $this->entityManager = $entityManager; - $this->fieldUtil = $fieldUtil; - $this->log = $log; $this->loadData(); } @@ -91,7 +72,7 @@ class Manager private function loadData(): void { if ($this->config->get('useCache') && $this->dataCache->has($this->cacheKey)) { - /** @var array $data */ + /** @var array $data */ $data = $this->dataCache->get($this->cacheKey); $this->data = $data; @@ -116,7 +97,7 @@ class Manager } /** - * @return array + * @return array */ private function buildData(): array { diff --git a/application/Espo/Core/Webhook/Queue.php b/application/Espo/Core/Webhook/Queue.php index b6b0ee346f..d98b7cb9c2 100644 --- a/application/Espo/Core/Webhook/Queue.php +++ b/application/Espo/Core/Webhook/Queue.php @@ -29,24 +29,18 @@ namespace Espo\Core\Webhook; -use Espo\Entities\{ - Webhook, - WebhookQueueItem, - WebhookEventQueueItem, - User, -}; +use Espo\Entities\User; +use Espo\Entities\Webhook; +use Espo\Entities\WebhookEventQueueItem; +use Espo\Entities\WebhookQueueItem; -use Espo\Core\{ - AclManager, - Utils\Config, - Utils\DateTime as DateTimeUtil, - Utils\Log, -}; +use Espo\Core\AclManager; +use Espo\Core\Utils\Config; +use Espo\Core\Utils\DateTime as DateTimeUtil; +use Espo\Core\Utils\Log; -use Espo\ORM\{ - EntityManager, - Query\Part\Condition as Cond, -}; +use Espo\ORM\EntityManager; +use Espo\ORM\Query\Part\Condition as Cond; use Exception; use DateTime; @@ -59,38 +53,18 @@ use stdClass; class Queue { private const EVENT_PORTION_SIZE = 20; - private const PORTION_SIZE = 20; - private const BATCH_SIZE = 50; - private const MAX_ATTEMPT_NUMBER = 4; - private const FAIL_ATTEMPT_PERIOD = '10 minutes'; - private $sender; - - private $config; - - private $entityManager; - - private $aclManager; - - private $log; - public function __construct( - Sender $sender, - Config $config, - EntityManager $entityManager, - AclManager $aclManager, - Log $log - ) { - $this->sender = $sender; - $this->config = $config; - $this->entityManager = $entityManager; - $this->aclManager = $aclManager; - $this->log = $log; - } + private Sender $sender, + private Config $config, + private EntityManager $entityManager, + private AclManager $aclManager, + private Log $log + ) {} public function process(): void { diff --git a/application/Espo/Core/Webhook/Sender.php b/application/Espo/Core/Webhook/Sender.php index 28d231cedb..03848317f1 100644 --- a/application/Espo/Core/Webhook/Sender.php +++ b/application/Espo/Core/Webhook/Sender.php @@ -30,11 +30,9 @@ namespace Espo\Core\Webhook; use Espo\Core\Exceptions\Error; - -use Espo\Entities\Webhook; - use Espo\Core\Utils\Config; use Espo\Core\Utils\Json; +use Espo\Entities\Webhook; /** * Sends a portion. @@ -42,18 +40,13 @@ use Espo\Core\Utils\Json; class Sender { private const CONNECT_TIMEOUT = 5; - private const TIMEOUT = 10; - private Config $config; - - public function __construct(Config $config) - { - $this->config = $config; - } + public function __construct(private Config $config) + {} /** - * @param array $dataList + * @param array $dataList * @throws Error */ public function send(Webhook $webhook, array $dataList): int