From: ArthurHoaro Date: Tue, 29 Sep 2020 13:00:11 +0000 (+0200) Subject: Compatibility with PHP 8 X-Git-Tag: v0.12.0-beta-2~7^2~4 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=ab58f2542072e6bf34acd862f6cfed84b33feb29 Compatibility with PHP 8 --- diff --git a/.travis.yml b/.travis.yml index 5f86d338..25304120 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ matrix: install: - composer self-update --2 - composer update --ignore-platform-req=php + - composer remove phpunit/phpunit + - composer require --dev --ignore-platform-req=php phpunit/php-text-template ^2.0 + - composer require --dev --ignore-platform-req=php phpunit/phpunit ^9.0 - language: php php: 7.4 - language: php diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php index 4509357c..c0c0dab9 100644 --- a/application/config/ConfigJson.php +++ b/application/config/ConfigJson.php @@ -46,7 +46,7 @@ class ConfigJson implements ConfigIO // JSON_PRETTY_PRINT is available from PHP 5.4. $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix(); - if (!file_put_contents($filepath, $data)) { + if (empty($filepath) || !file_put_contents($filepath, $data)) { throw new \Shaarli\Exceptions\IOException( $filepath, t('Shaarli could not create the config file. '. diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 38cd5eba..bbd2e142 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -81,8 +81,8 @@ class PluginManagerTest extends \Shaarli\TestCase $data = []; $this->pluginManager->executeHooks('error', $data); - $this->assertSame( - 'test [plugin incompatibility]: Class \'Unknown\' not found', + $this->assertMatchesRegularExpression( + '/test \[plugin incompatibility\]: Class [\'"]Unknown[\'"] not found/', $this->pluginManager->getErrors()[0] ); } diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php index 4f508925..c0ba5b8f 100644 --- a/tests/config/ConfigJsonTest.php +++ b/tests/config/ConfigJsonTest.php @@ -42,7 +42,7 @@ class ConfigJsonTest extends \Shaarli\TestCase public function testReadInvalidJson() { $this->expectException(\Exception::class); - $this->expectExceptionMessageRegExp(' /An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/'); + $this->expectExceptionMessageRegExp('/An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/'); $this->configIO->read('tests/utils/config/configInvalid.json.php'); } @@ -108,17 +108,6 @@ class ConfigJsonTest extends \Shaarli\TestCase unlink($dest); } - /** - * Write to invalid path. - */ - public function testWriteInvalidArray() - { - $this->expectException(\Shaarli\Exceptions\IOException::class); - - $conf = array('conf' => 'value'); - @$this->configIO->write(array(), $conf); - } - /** * Write to invalid path. */ diff --git a/tests/updater/DummyUpdater.php b/tests/updater/DummyUpdater.php index 07c7f5c4..3403233f 100644 --- a/tests/updater/DummyUpdater.php +++ b/tests/updater/DummyUpdater.php @@ -37,7 +37,7 @@ class DummyUpdater extends Updater * * @return bool true. */ - final private function updateMethodDummy1() + final protected function updateMethodDummy1() { return true; } @@ -47,7 +47,7 @@ class DummyUpdater extends Updater * * @return bool true. */ - final private function updateMethodDummy2() + final protected function updateMethodDummy2() { return true; } @@ -57,7 +57,7 @@ class DummyUpdater extends Updater * * @return bool true. */ - final private function updateMethodDummy3() + final protected function updateMethodDummy3() { return true; } @@ -67,7 +67,7 @@ class DummyUpdater extends Updater * * @throws Exception error. */ - final private function updateMethodException() + final protected function updateMethodException() { throw new Exception('whatever'); }