Skip to content
This repository was archived by the owner on Apr 11, 2022. It is now read-only.

Commit 034e106

Browse files
committed
PHP 7.4 support
1 parent 899020b commit 034e106

File tree

3 files changed

+7
-38
lines changed

3 files changed

+7
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ Minimal template configuration:
6262
</mj-section>
6363
</mj-body>
6464
</mjml>
65-
```
65+
```

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=7.1.0"
12+
"php": ">=7.4.0"
1313
},
1414
"require-dev": {
1515
"phpstan/phpstan": "^0.12.18",
1616
"tracy/tracy": "^2.7",
17-
"phpstan/phpstan-nette": "^0.12.6"
17+
"phpstan/phpstan-nette": "^0.12.6",
18+
"symplify/easy-coding-standard": "^7.2"
1819
},
1920
"autoload": {
2021
"classmap": [

src/MjmlServer.php

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
final class MjmlServer
99
{
10-
11-
/** @var string */
12-
private $cacheDir;
10+
private string $cacheDir;
1311

1412

1513
public function __construct(?string $cacheDir = null)
@@ -39,10 +37,6 @@ public function run(): void
3937
}
4038

4139

42-
/**
43-
* @param string $template
44-
* @return string
45-
*/
4640
public function process(string $template): string
4741
{
4842
$templateContentHash = md5($template);
@@ -65,14 +59,9 @@ public function process(string $template): string
6559
}
6660

6761

68-
/**
69-
* @param string $file
70-
* @return string
71-
*/
7262
private function processReturn(string $file): string
7363
{
7464
$return = str_replace(["\r\n", "\r"], "\n", $this->read($file));
75-
7665
if (preg_match('/Error: ([^\n]+)/', $return, $parser)) {
7766
throw new \RuntimeException($parser[1]);
7867
}
@@ -81,10 +70,6 @@ private function processReturn(string $file): string
8170
}
8271

8372

84-
/**
85-
* @param string $dir
86-
* @param int $mode
87-
*/
8873
private function createDir(string $dir, int $mode = 0777): void
8974
{
9075
if (!is_dir($dir) && !@mkdir($dir, $mode, true) && !is_dir($dir)) { // @ - dir may already exist
@@ -93,10 +78,6 @@ private function createDir(string $dir, int $mode = 0777): void
9378
}
9479

9580

96-
/**
97-
* @param string $file
98-
* @return string
99-
*/
10081
private function read(string $file): string
10182
{
10283
$content = @file_get_contents($file); // @ is escalated to exception
@@ -108,11 +89,6 @@ private function read(string $file): string
10889
}
10990

11091

111-
/**
112-
* @param string $file
113-
* @param string $content
114-
* @param int|null $mode
115-
*/
11692
private function write(string $file, string $content, ?int $mode = 0666): void
11793
{
11894
$this->createDir(dirname($file));
@@ -125,31 +101,23 @@ private function write(string $file, string $content, ?int $mode = 0666): void
125101
}
126102

127103

128-
/**
129-
* @return string
130-
*/
131104
private function getLastError(): string
132105
{
133106
return preg_replace('#^\w+\(.*?\): #', '', error_get_last()['message']);
134107
}
135108

136109

137-
/**
138-
* @param string $functionName
139-
* @return bool
140-
*/
141110
private function functionIsAvailable(string $functionName): bool
142111
{
143112
static $disabled;
144-
145113
if (\function_exists($functionName)) {
146114
if ($disabled === null && \is_string($disableFunctions = ini_get('disable_functions'))) {
147-
$disabled = explode(',', $disableFunctions) ?: [];
115+
$disabled = explode(',', $disableFunctions);
148116
}
149117

150118
return \in_array($functionName, $disabled, true) === false;
151119
}
152120

153121
return false;
154122
}
155-
}
123+
}

0 commit comments

Comments
 (0)