Skip to content

Commit 55eaa7d

Browse files
committed
feat: php74 compat
1 parent 23d722a commit 55eaa7d

File tree

7 files changed

+32
-33
lines changed

7 files changed

+32
-33
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
MAGENTO_VERSION: 2.4.5-p10
3737
- PHP_VERSION: php81-fpm
3838
MAGENTO_VERSION: 2.4.4-p11
39-
# - PHP_VERSION: php74-fpm
40-
# MAGENTO_VERSION: 2.4.3-p2 # @TODO: -p3 missing from upstream containers
39+
- PHP_VERSION: php74-fpm
40+
MAGENTO_VERSION: 2.4.3-p2 # @TODO: -p3 missing from upstream containers
4141
runs-on: ubuntu-latest
4242
steps:
4343
- uses: actions/checkout@v1

Api/ConfigInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace SamJUK\MediaProxy\Api;
66

7-
use SamJUK\MediaProxy\Enum\Mode;
8-
97
interface ConfigInterface
108
{
119

@@ -23,9 +21,9 @@ public function getUpstreamHost(): string;
2321

2422
/**
2523
* Get the current mode the module is operating in.
26-
* @return Mode
24+
* @return string
2725
*/
28-
public function getMode(): Mode;
26+
public function getMode(): string;
2927

3028
/**
3129
* Is the module enabled & operating in proxy mode for the current store.

Enum/Mode.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

Model/Config.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SamJUK\MediaProxy\Model;
66

7-
use SamJUK\MediaProxy\Enum\Mode;
7+
use SamJUK\MediaProxy\Model\Config\Source\Mode;
88
use SamJUK\MediaProxy\Api\ConfigInterface;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
1010

@@ -14,7 +14,8 @@ class Config implements ConfigInterface
1414
private const XML_PATH_MODE = 'samjuk_media_proxy/general/mode';
1515
private const XML_PATH_UPSTREAM_HOST = 'samjuk_media_proxy/general/upstream_host';
1616

17-
private readonly ScopeConfigInterface $scopeConfig;
17+
/** @readonly */
18+
private ScopeConfigInterface $scopeConfig;
1819

1920
public function __construct(
2021
ScopeConfigInterface $scopeConfigInterface
@@ -32,19 +33,19 @@ public function getUpstreamHost(): string
3233
return rtrim($this->getValue(self::XML_PATH_UPSTREAM_HOST), '/');
3334
}
3435

35-
public function getMode(): Mode
36+
public function getMode(): string
3637
{
37-
return Mode::from($this->getValue(self::XML_PATH_MODE));
38+
return $this->getValue(self::XML_PATH_MODE);
3839
}
3940

4041
public function isProxyMode(): bool
4142
{
42-
return $this->isEnabled() && $this->getMode() === Mode::Proxy;
43+
return $this->isEnabled() && $this->getMode() === Mode::PROXY;
4344
}
4445

4546
public function isCacheMode(): bool
4647
{
47-
return $this->isEnabled() && $this->getMode() === Mode::Cache;
48+
return $this->isEnabled() && $this->getMode() === Mode::CACHE;
4849
}
4950

5051
private function getFlag($path, $scope = 'default', $scopeCode = null): bool
@@ -56,7 +57,8 @@ private function getFlag($path, $scope = 'default', $scopeCode = null): bool
5657
);
5758
}
5859

59-
private function getValue($path, $scope = 'default', $scopeCode = null): mixed
60+
/** @return mixed */
61+
private function getValue($path, $scope = 'default', $scopeCode = null)
6062
{
6163
return $this->scopeConfig->getValue(
6264
$path,

Model/Config/Source/Mode.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace SamJUK\MediaProxy\Model\Config\Source;
46

5-
use SamJUK\MediaProxy\Enum\Mode as ModeEnum;
67
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
78

89
class Mode extends AbstractSource
910
{
11+
public const PROXY = 'proxy';
12+
public const CACHE = 'cache';
13+
1014
public function getAllOptions()
1115
{
1216
$this->_options = [
13-
['label' => 'Proxy', 'value' => ModeEnum::Proxy->value],
14-
['label' => 'Cache', 'value' => ModeEnum::Cache->value]
17+
['label' => 'Proxy', 'value' => static::PROXY],
18+
['label' => 'Cache', 'value' => static::CACHE]
1519
];
1620
return $this->_options;
1721
}

Model/RequestedMedia.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010

1111
class RequestedMedia implements RequestedMediaInterface
1212
{
13-
private readonly string $relativePath;
14-
private readonly string $absolutePubPath;
15-
private readonly string $upstreamHost;
16-
private readonly FilesystemDriverInterface $filesystem;
13+
/** @readonly */
14+
private string $relativePath;
15+
/** @readonly */
16+
private string $absolutePubPath;
17+
/** @readonly */
18+
private string $upstreamHost;
19+
/** @readonly */
20+
private FilesystemDriverInterface $filesystem;
1721

1822
public function __construct(
1923
FilesystemDriverInterface $filesystem,

Plugin/Media.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
class Media
1313
{
14-
private readonly ConfigInterface $config;
15-
private readonly RequestedMediaInterface $requestedMedia;
14+
/** @readonly */
15+
private ConfigInterface $config;
16+
/** @readonly */
17+
private RequestedMediaInterface $requestedMedia;
1618

1719
public function __construct(
1820
ConfigInterface $config,

0 commit comments

Comments
 (0)