Skip to content
This repository was archived by the owner on Nov 2, 2025. It is now read-only.

Commit b418e2d

Browse files
Merge branch 'main' into phan
2 parents b4a1929 + 74dc835 commit b418e2d

File tree

4 files changed

+21
-52
lines changed

4 files changed

+21
-52
lines changed

includes/HookHandlers/Main.php

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,18 @@
2121

2222
class Main implements ArticleViewHeaderHook {
2323

24-
private Config $config;
25-
private JobQueueGroupFactory $jobQueueGroupFactory;
26-
private LanguageNameUtils $languageNameUtils;
27-
private MachineTranslationLanguageFetcher $machineTranslationLanguageFetcher;
28-
private MachineTranslationUtils $machineTranslationUtils;
29-
private MessageLocalizer $messageLocalizer;
30-
private TitleFactory $titleFactory;
31-
private WikiPageFactory $wikiPageFactory;
24+
private readonly Config $config;
25+
private readonly MessageLocalizer $messageLocalizer;
3226

3327
public function __construct(
3428
ConfigFactory $configFactory,
35-
JobQueueGroupFactory $jobQueueGroupFactory,
36-
LanguageNameUtils $languageNameUtils,
37-
MachineTranslationLanguageFetcher $machineTranslationLanguageFetcher,
38-
MachineTranslationUtils $machineTranslationUtils,
39-
TitleFactory $titleFactory,
40-
WikiPageFactory $wikiPageFactory
29+
private readonly JobQueueGroupFactory $jobQueueGroupFactory,
30+
private readonly LanguageNameUtils $languageNameUtils,
31+
private readonly MachineTranslationLanguageFetcher $machineTranslationLanguageFetcher,
32+
private readonly MachineTranslationUtils $machineTranslationUtils,
33+
private readonly TitleFactory $titleFactory,
34+
private readonly WikiPageFactory $wikiPageFactory
4135
) {
42-
$this->jobQueueGroupFactory = $jobQueueGroupFactory;
43-
$this->languageNameUtils = $languageNameUtils;
44-
$this->machineTranslationLanguageFetcher = $machineTranslationLanguageFetcher;
45-
$this->machineTranslationUtils = $machineTranslationUtils;
46-
$this->titleFactory = $titleFactory;
47-
$this->wikiPageFactory = $wikiPageFactory;
48-
4936
$this->config = $configFactory->makeConfig( 'MachineTranslation' );
5037
$this->messageLocalizer = RequestContext::getMain();
5138
}

includes/Jobs/MachineTranslationJob.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ class MachineTranslationJob extends Job {
1212

1313
public const JOB_NAME = 'MachineTranslationJob';
1414

15-
private Config $config;
16-
private MachineTranslationUtils $machineTranslationUtils;
15+
private readonly Config $config;
1716

18-
private string $cacheKey;
19-
private string $content;
20-
private string $source;
21-
private string $target;
22-
private string $titleText;
17+
private readonly string $cacheKey;
18+
private readonly string $content;
19+
private readonly string $source;
20+
private readonly string $target;
21+
private readonly string $titleText;
2322

2423
public function __construct(
2524
array $params,
2625
ConfigFactory $configFactory,
27-
MachineTranslationUtils $machineTranslationUtils
26+
private readonly MachineTranslationUtils $machineTranslationUtils
2827
) {
2928
parent::__construct( self::JOB_NAME, $params );
3029

3130
$this->config = $configFactory->makeConfig( 'MachineTranslation' );
32-
$this->machineTranslationUtils = $machineTranslationUtils;
3331

3432
$this->cacheKey = $params['cachekey'];
3533
$this->content = $params['content'];

includes/Services/MachineTranslationLanguageFetcher.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@ class MachineTranslationLanguageFetcher {
1717
MainConfigNames::HTTPProxy,
1818
];
1919

20-
private HttpRequestFactory $httpRequestFactory;
21-
private MachineTranslationUtils $machineTranslationUtils;
22-
private ServiceOptions $options;
23-
2420
public function __construct(
25-
HttpRequestFactory $httpRequestFactory,
26-
MachineTranslationUtils $machineTranslationUtils,
27-
ServiceOptions $options
21+
private readonly HttpRequestFactory $httpRequestFactory,
22+
private readonly MachineTranslationUtils $machineTranslationUtils,
23+
private readonly ServiceOptions $options
2824
) {
2925
$options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
30-
31-
$this->httpRequestFactory = $httpRequestFactory;
32-
$this->machineTranslationUtils = $machineTranslationUtils;
33-
$this->options = $options;
3426
}
3527

3628
public function getSupportedLanguages(): array {

includes/Services/MachineTranslationUtils.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,12 @@ class MachineTranslationUtils {
2323
public const USER_AGENT = 'MachineTranslation, MediaWiki extension ' .
2424
'(https://github.com/miraheze/MachineTranslation)';
2525

26-
private HttpRequestFactory $httpRequestFactory;
27-
private ObjectCacheFactory $objectCacheFactory;
28-
private ServiceOptions $options;
29-
3026
public function __construct(
31-
HttpRequestFactory $httpRequestFactory,
32-
ObjectCacheFactory $objectCacheFactory,
33-
ServiceOptions $options
27+
private readonly HttpRequestFactory $httpRequestFactory,
28+
private readonly ObjectCacheFactory $objectCacheFactory,
29+
private readonly ServiceOptions $options
3430
) {
3531
$options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
36-
37-
$this->httpRequestFactory = $httpRequestFactory;
38-
$this->objectCacheFactory = $objectCacheFactory;
39-
$this->options = $options;
4032
}
4133

4234
public function callTranslation(

0 commit comments

Comments
 (0)