Compatibility with PHP 8

This commit is contained in:
ArthurHoaro 2020-09-29 15:00:11 +02:00
parent a5a9cf23ac
commit ab58f25420
5 changed files with 11 additions and 19 deletions

View file

@ -8,6 +8,9 @@ matrix:
install: install:
- composer self-update --2 - composer self-update --2
- composer update --ignore-platform-req=php - 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 - language: php
php: 7.4 php: 7.4
- language: php - language: php

View file

@ -46,7 +46,7 @@ class ConfigJson implements ConfigIO
// JSON_PRETTY_PRINT is available from PHP 5.4. // JSON_PRETTY_PRINT is available from PHP 5.4.
$print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
$data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix(); $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( throw new \Shaarli\Exceptions\IOException(
$filepath, $filepath,
t('Shaarli could not create the config file. '. t('Shaarli could not create the config file. '.

View file

@ -81,8 +81,8 @@ class PluginManagerTest extends \Shaarli\TestCase
$data = []; $data = [];
$this->pluginManager->executeHooks('error', $data); $this->pluginManager->executeHooks('error', $data);
$this->assertSame( $this->assertMatchesRegularExpression(
'test [plugin incompatibility]: Class \'Unknown\' not found', '/test \[plugin incompatibility\]: Class [\'"]Unknown[\'"] not found/',
$this->pluginManager->getErrors()[0] $this->pluginManager->getErrors()[0]
); );
} }

View file

@ -42,7 +42,7 @@ class ConfigJsonTest extends \Shaarli\TestCase
public function testReadInvalidJson() public function testReadInvalidJson()
{ {
$this->expectException(\Exception::class); $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'); $this->configIO->read('tests/utils/config/configInvalid.json.php');
} }
@ -108,17 +108,6 @@ class ConfigJsonTest extends \Shaarli\TestCase
unlink($dest); 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. * Write to invalid path.
*/ */

View file

@ -37,7 +37,7 @@ class DummyUpdater extends Updater
* *
* @return bool true. * @return bool true.
*/ */
final private function updateMethodDummy1() final protected function updateMethodDummy1()
{ {
return true; return true;
} }
@ -47,7 +47,7 @@ class DummyUpdater extends Updater
* *
* @return bool true. * @return bool true.
*/ */
final private function updateMethodDummy2() final protected function updateMethodDummy2()
{ {
return true; return true;
} }
@ -57,7 +57,7 @@ class DummyUpdater extends Updater
* *
* @return bool true. * @return bool true.
*/ */
final private function updateMethodDummy3() final protected function updateMethodDummy3()
{ {
return true; return true;
} }
@ -67,7 +67,7 @@ class DummyUpdater extends Updater
* *
* @throws Exception error. * @throws Exception error.
*/ */
final private function updateMethodException() final protected function updateMethodException()
{ {
throw new Exception('whatever'); throw new Exception('whatever');
} }