/**
* @var string Action key: a new link has been created.
*/
- const CREATED = 'CREATED';
+ public const CREATED = 'CREATED';
/**
* @var string Action key: a link has been updated.
*/
- const UPDATED = 'UPDATED';
+ public const UPDATED = 'UPDATED';
/**
* @var string Action key: a link has been deleted.
*/
- const DELETED = 'DELETED';
+ public const DELETED = 'DELETED';
/**
* @var string Action key: settings have been updated.
*/
- const SETTINGS = 'SETTINGS';
+ public const SETTINGS = 'SETTINGS';
/**
* @var string Action key: a bulk import has been processed.
*/
- const IMPORT = 'IMPORT';
+ public const IMPORT = 'IMPORT';
/**
* @var string History file path.
/**
* Core translations domain
*/
- const DEFAULT_DOMAIN = 'shaarli';
+ public const DEFAULT_DOMAIN = 'shaarli';
/**
* @var TranslatorInterface
$translations = new Translations();
// Core translations
try {
- $translations = $translations->addFromPoFile('inc/languages/' . $this->language . '/LC_MESSAGES/shaarli.po');
+ $translations = $translations->addFromPoFile(
+ 'inc/languages/' . $this->language . '/LC_MESSAGES/shaarli.po'
+ );
$translations->setDomain('shaarli');
$this->translator->loadTranslations($translations);
} catch (\InvalidArgumentException $e) {
*/
class Thumbnailer
{
- const COMMON_MEDIA_DOMAINS = [
+ protected const COMMON_MEDIA_DOMAINS = [
'imgur.com',
'flickr.com',
'youtube.com',
'deviantart.com',
];
- const MODE_ALL = 'all';
- const MODE_COMMON = 'common';
- const MODE_NONE = 'none';
+ public const MODE_ALL = 'all';
+ public const MODE_COMMON = 'common';
+ public const MODE_NONE = 'none';
/**
* @var WebThumbnailer instance.
switch ($last) {
case 'g':
$val *= 1024;
+ // do no break in order 1024^2 for each unit
case 'm':
$val *= 1024;
+ // do no break in order 1024^2 for each unit
case 'k':
$val *= 1024;
}
class Bookmark
{
/** @var string Date format used in string (former ID format) */
- const LINK_DATE_FORMAT = 'Ymd_His';
+ public const LINK_DATE_FORMAT = 'Ymd_His';
/** @var int Bookmark ID */
protected $id;
false
);
$updater = new LegacyUpdater(
- UpdaterUtils::read_updates_file($this->conf->get('resource.updates')),
+ UpdaterUtils::readUpdatesFile($this->conf->get('resource.updates')),
$bookmarkDb,
$this->conf,
true
);
$newUpdates = $updater->update();
if (! empty($newUpdates)) {
- UpdaterUtils::write_updates_file(
+ UpdaterUtils::writeUpdatesFile(
$this->conf->get('resource.updates'),
$updater->getDoneUpdates()
);
* To prevent data corruption, it does not overwrite existing bookmarks,
* even though there should not be any.
*
+ * We disable this because otherwise it creates indentation issues, and heredoc is not supported by PHP gettext.
+ * @phpcs:disable Generic.Files.LineLength.TooLong
+ *
* @package Shaarli\Bookmark
*/
class BookmarkInitializer
$container['updater'] = function (ShaarliContainer $container): Updater {
return new Updater(
- UpdaterUtils::read_updates_file($container->conf->get('resource.updates')),
+ UpdaterUtils::readUpdatesFile($container->conf->get('resource.updates')),
$container->bookmarkService,
$container->conf,
$container->loginManager->isLoggedIn()
*/
class BookmarkDefaultFormatter extends BookmarkFormatter
{
- const SEARCH_HIGHLIGHT_OPEN = '|@@HIGHLIGHT';
- const SEARCH_HIGHLIGHT_CLOSE = 'HIGHLIGHT@@|';
+ protected const SEARCH_HIGHLIGHT_OPEN = '|@@HIGHLIGHT';
+ protected const SEARCH_HIGHLIGHT_CLOSE = 'HIGHLIGHT@@|';
/**
* @inheritdoc
/**
* When this tag is present in a bookmark, its description should not be processed with Markdown
*/
- const NO_MD_TAG = 'nomarkdown';
+ public const NO_MD_TAG = 'nomarkdown';
/** @var \Parsedown instance */
protected $parsedown;
$this->assignView('languages', Languages::getAvailableLanguages());
$this->assignView('gd_enabled', extension_loaded('gd'));
$this->assignView('thumbnails_mode', $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE));
- $this->assignView('pagetitle', t('Configure') . ' - ' . $this->container->conf->get('general.title', 'Shaarli'));
+ $this->assignView(
+ 'pagetitle',
+ t('Configure') . ' - ' . $this->container->conf->get('general.title', 'Shaarli')
+ );
return $response->write($this->render(TemplatePage::CONFIGURE));
}
) {
$this->saveWarningMessage(
t('You have enabled or changed thumbnails mode.') .
- '<a href="' . $this->container->basePath . '/admin/thumbnails">' . t('Please synchronize them.') . '</a>'
+ '<a href="' . $this->container->basePath . '/admin/thumbnails">' .
+ t('Please synchronize them.') .
+ '</a>'
);
}
$this->container->conf->set('thumbnails.mode', $thumbnailsMode);
$this->saveWarningMessage(
t('Thumbnails cache has been cleared.') . ' ' .
- '<a href="' . $this->container->basePath . '/admin/thumbnails">' . t('Please synchronize them.') . '</a>'
+ '<a href="' . $this->container->basePath . '/admin/thumbnails">' .
+ t('Please synchronize them.') .
+ '</a>'
);
} else {
$folders = [
private $datastore;
// Link date storage format
- const LINK_DATE_FORMAT = 'Ymd_His';
+ public const LINK_DATE_FORMAT = 'Ymd_His';
// List of bookmarks (associative array)
// - key: link date (e.g. "20110823_124546"),
public function readUpdates(string $updatesFilepath): array
{
- return UpdaterUtils::read_updates_file($updatesFilepath);
+ return UpdaterUtils::readUpdatesFile($updatesFilepath);
}
public function writeUpdates(string $updatesFilepath, array $updates): void
{
- UpdaterUtils::write_updates_file($updatesFilepath, $updates);
+ UpdaterUtils::writeUpdatesFile($updatesFilepath, $updates);
}
/**
*
* @return array Already done update methods.
*/
- public static function read_updates_file($updatesFilepath)
+ public static function readUpdatesFile($updatesFilepath)
{
if (! empty($updatesFilepath) && is_file($updatesFilepath)) {
$content = file_get_contents($updatesFilepath);
*
* @throws \Exception Couldn't write version number.
*/
- public static function write_updates_file($updatesFilepath, $updates)
+ public static function writeUpdatesFile($updatesFilepath, $updates)
{
if (empty($updatesFilepath)) {
throw new \Exception('Updates file path is not set, can\'t write updates.');
<rule ref="PSR12"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
+
+ <rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
+ <!-- index.php bootstraps everything, so yes mixed symbols with side effects -->
+ <exclude-pattern>index.php</exclude-pattern>
+ </rule>
</ruleset>
*/
public function testReadEmptyUpdatesFile()
{
- $this->assertEquals(array(), UpdaterUtils::read_updates_file(''));
+ $this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
- $this->assertEquals(array(), UpdaterUtils::read_updates_file($updatesFile));
+ $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
unlink($updatesFile);
}
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
$updatesMethods = array('m1', 'm2', 'm3');
- UpdaterUtils::write_updates_file($updatesFile, $updatesMethods);
- $readMethods = UpdaterUtils::read_updates_file($updatesFile);
+ UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
+ $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
$this->assertEquals($readMethods, $updatesMethods);
// Update
$updatesMethods[] = 'm4';
- UpdaterUtils::write_updates_file($updatesFile, $updatesMethods);
- $readMethods = UpdaterUtils::read_updates_file($updatesFile);
+ UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
+ $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
$this->assertEquals($readMethods, $updatesMethods);
unlink($updatesFile);
}
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
- UpdaterUtils::write_updates_file('', array('test'));
+ UpdaterUtils::writeUpdatesFile('', array('test'));
}
/**
touch($updatesFile);
chmod($updatesFile, 0444);
try {
- @UpdaterUtils::write_updates_file($updatesFile, array('test'));
+ @UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
} catch (Exception $e) {
unlink($updatesFile);
throw $e;
*/
public function testReadEmptyUpdatesFile()
{
- $this->assertEquals(array(), UpdaterUtils::read_updates_file(''));
+ $this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
- $this->assertEquals(array(), UpdaterUtils::read_updates_file($updatesFile));
+ $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
unlink($updatesFile);
}
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
$updatesMethods = array('m1', 'm2', 'm3');
- UpdaterUtils::write_updates_file($updatesFile, $updatesMethods);
- $readMethods = UpdaterUtils::read_updates_file($updatesFile);
+ UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
+ $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
$this->assertEquals($readMethods, $updatesMethods);
// Update
$updatesMethods[] = 'm4';
- UpdaterUtils::write_updates_file($updatesFile, $updatesMethods);
- $readMethods = UpdaterUtils::read_updates_file($updatesFile);
+ UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
+ $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
$this->assertEquals($readMethods, $updatesMethods);
unlink($updatesFile);
}
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
- UpdaterUtils::write_updates_file('', array('test'));
+ UpdaterUtils::writeUpdatesFile('', array('test'));
}
/**
touch($updatesFile);
chmod($updatesFile, 0444);
try {
- @UpdaterUtils::write_updates_file($updatesFile, array('test'));
+ @UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
} catch (Exception $e) {
unlink($updatesFile);
throw $e;