diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-06-20 18:30:37 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-06-20 18:30:37 +0200 |
commit | 5ff23f02b80ec6ddee28dee869171ee8e3656b7c (patch) | |
tree | af02ad6c9f0f2956854f2330126c341a2896f558 /application/config/ConfigJson.php | |
parent | b302c77c74a09cb271b711248b8f433555524ef0 (diff) | |
download | Shaarli-5ff23f02b80ec6ddee28dee869171ee8e3656b7c.tar.gz Shaarli-5ff23f02b80ec6ddee28dee869171ee8e3656b7c.tar.zst Shaarli-5ff23f02b80ec6ddee28dee869171ee8e3656b7c.zip |
Add closing PHP tags to JSON config files
Diffstat (limited to 'application/config/ConfigJson.php')
-rw-r--r-- | application/config/ConfigJson.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php index 94693c86..d07fefee 100644 --- a/application/config/ConfigJson.php +++ b/application/config/ConfigJson.php | |||
@@ -17,6 +17,7 @@ class ConfigJson implements ConfigIO | |||
17 | } | 17 | } |
18 | $data = file_get_contents($filepath); | 18 | $data = file_get_contents($filepath); |
19 | $data = str_replace(self::getPhpHeaders(), '', $data); | 19 | $data = str_replace(self::getPhpHeaders(), '', $data); |
20 | $data = str_replace(self::getPhpSuffix(), '', $data); | ||
20 | $data = json_decode($data, true); | 21 | $data = json_decode($data, true); |
21 | if ($data === null) { | 22 | if ($data === null) { |
22 | $error = json_last_error(); | 23 | $error = json_last_error(); |
@@ -32,7 +33,7 @@ class ConfigJson implements ConfigIO | |||
32 | { | 33 | { |
33 | // JSON_PRETTY_PRINT is available from PHP 5.4. | 34 | // JSON_PRETTY_PRINT is available from PHP 5.4. |
34 | $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; | 35 | $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; |
35 | $data = self::getPhpHeaders() . json_encode($conf, $print); | 36 | $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix(); |
36 | if (!file_put_contents($filepath, $data)) { | 37 | if (!file_put_contents($filepath, $data)) { |
37 | throw new IOException( | 38 | throw new IOException( |
38 | $filepath, | 39 | $filepath, |
@@ -62,4 +63,16 @@ class ConfigJson implements ConfigIO | |||
62 | { | 63 | { |
63 | return '<?php /*'. PHP_EOL; | 64 | return '<?php /*'. PHP_EOL; |
64 | } | 65 | } |
66 | |||
67 | /** | ||
68 | * Get PHP comment closing tags. | ||
69 | * | ||
70 | * Static method for consistency with getPhpHeaders. | ||
71 | * | ||
72 | * @return string PHP comment closing. | ||
73 | */ | ||
74 | public static function getPhpSuffix() | ||
75 | { | ||
76 | return PHP_EOL . '*/ ?>'; | ||
77 | } | ||
65 | } | 78 | } |