Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Controllers/categoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function createAction() :void {
$url_redirect = array('c' => 'subscription', 'a' => 'add');

$limits = FreshRSS_Context::$system_conf->limits;
$this->view->categories = $catDAO->listCategories(false);
$this->view->categories = $catDAO->listCategories(false) ?: [];

if (count($this->view->categories) >= $limits['max_categories']) {
Minz_Request::bad(_t('feedback.sub.category.over_max', $limits['max_categories']), $url_redirect);
Expand Down Expand Up @@ -231,7 +231,7 @@ public function refreshOpmlAction(): void {

if (Minz_Request::paramBoolean('ajax')) {
Minz_Request::setGoodNotification(_t('feedback.sub.category.updated'));
$this->view->_layout(false);
$this->view->_layout(null);
} else {
if ($ok) {
Minz_Request::good(_t('feedback.sub.category.updated'), $url_redirect);
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/configureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public function archivingAction(): void {
FreshRSS_Context::$user_conf->volatile = $volatile;

$entryDAO = FreshRSS_Factory::createEntryDao();
$this->view->nb_total = $entryDAO->count();
$this->view->nb_total = $entryDAO->count() ?: 0;

$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
$this->view->size_user = $databaseDAO->size();
Expand Down Expand Up @@ -338,7 +338,7 @@ public function queriesAction(): void {
* applied to the selected query.
*/
public function queryAction(): void {
$this->view->_layout(false);
$this->view->_layout(null);

$id = Minz_Request::paramInt('id');
if ($id !== 0 || !isset(FreshRSS_Context::$user_conf->queries[$id])) {
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/entryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function firstAction(): void {
// If ajax request, we do not print layout
$this->ajax = Minz_Request::paramBoolean('ajax');
if ($this->ajax) {
$this->view->_layout(false);
$this->view->_layout(null);
Minz_Request::_param('ajax');
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public function readAction(): void {
$ids = is_array($id) ? $id : array($id);
$entryDAO->markRead($ids, $is_read);
$tagDAO = FreshRSS_Factory::createTagDao();
$tagsForEntries = $tagDAO->getTagsForEntries($ids);
$tagsForEntries = $tagDAO->getTagsForEntries($ids) ?: [];
$tags = array();
foreach ($tagsForEntries as $line) {
$tags['t_' . $line['id_tag']][] = $line['id_entry'];
Expand Down
6 changes: 3 additions & 3 deletions app/Controllers/extensionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function getAvailableExtensionList(): array {
*/
public function configureAction(): void {
if (Minz_Request::paramBoolean('ajax')) {
$this->view->_layout(false);
$this->view->_layout(null);
} else {
$this->indexAction();
$this->view->_path('extension/index.phtml');
Expand Down Expand Up @@ -143,7 +143,7 @@ public function enableAction(): void {

if ($conf !== null && $res === true) {
$ext_list = $conf->extensions_enabled;
$ext_list = array_filter($ext_list, function($key) use($type) {
$ext_list = array_filter($ext_list, static function(string $key) use($type) {
// Remove from list the extensions that have disappeared or changed type
$extension = Minz_ExtensionManager::findExtension($key);
return $extension !== null && $extension->getType() === $type;
Expand Down Expand Up @@ -205,7 +205,7 @@ public function disableAction(): void {

if ($conf !== null && $res === true) {
$ext_list = $conf->extensions_enabled;
$ext_list = array_filter($ext_list, function($key) use($type) {
$ext_list = array_filter($ext_list, static function(string $key) use($type) {
// Remove from list the extensions that have disappeared or changed type
$extension = Minz_ExtensionManager::findExtension($key);
return $extension !== null && $extension->getType() === $type;
Expand Down
9 changes: 5 additions & 4 deletions app/Controllers/feedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function addAction(): void {
FreshRSS_View::prependTitle(_t('sub.feed.title_add') . ' · ');

$catDAO = FreshRSS_Factory::createCategoryDao();
$this->view->categories = $catDAO->listCategories(false);
$this->view->categories = $catDAO->listCategories(false) ?: [];
$this->view->feed = new FreshRSS_Feed($url);
try {
// We try to get more information about the feed.
Expand Down Expand Up @@ -316,7 +316,8 @@ public function truncateAction(): void {
/**
* @return array{0:int,1:FreshRSS_Feed|false,2:int}
*/
public static function actualizeFeed(int $feed_id, string $feed_url, bool $force, ?SimplePie $simplePiePush = null, bool $noCommit = false, int $maxFeeds = 10) {
public static function actualizeFeed(int $feed_id, string $feed_url, bool $force, ?SimplePie $simplePiePush = null,
bool $noCommit = false, int $maxFeeds = 10): array {
@set_time_limit(300);

$feedDAO = FreshRSS_Factory::createFeedDao();
Expand Down Expand Up @@ -666,7 +667,7 @@ public function actualizeAction(): int {
// are several updated feeds.
Minz_Request::setGoodNotification(_t('feedback.sub.feed.actualizeds'));
// No layout in ajax request.
$this->view->_layout(false);
$this->view->_layout(null);
} else {
// Redirect to the main page with correct notification.
if ($updated_feeds === 1) {
Expand Down Expand Up @@ -903,7 +904,7 @@ public function contentSelectorPreviewAction(): void {
$this->view->selectorSuccess = false;
$this->view->htmlContent = '';

$this->view->_layout(false);
$this->view->_layout(null);

$this->_csp([
'default-src' => "'self'",
Expand Down
10 changes: 4 additions & 6 deletions app/Controllers/importExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private function ttrssXmlToJson(string $xml) {
unset($table['article']);
for ($i = count($table['items']) - 1; $i >= 0; $i--) {
$item = (array)($table['items'][$i]);
$item = array_filter($item, function ($v) {
$item = array_filter($item, static function ($v) {
// Filter out empty properties, potentially reported as empty objects
return (is_string($v) && trim($v) !== '') || !empty($v);
});
Expand Down Expand Up @@ -267,7 +267,7 @@ private function ttrssXmlToJson(string $xml) {
*
* $article_file the JSON file content.
* true if articles from the file must be starred.
* @return boolean false if an error occurred, true otherwise.
* @return bool false if an error occurred, true otherwise.
*/
private function importJson(string $article_file, bool $starred = false): bool {
$article_object = json_decode($article_file, true);
Expand Down Expand Up @@ -575,10 +575,8 @@ private function addFeedJson(array $origin): ?FreshRSS_Feed {
* - export_starred (default: false)
* - export_labelled (default: false)
* - export_feeds (default: array()) a list of feed ids
*
* @return void|null
*/
public function exportAction() {
public function exportAction(): void {
if (!Minz_Request::isPost()) {
Minz_Request::forward(['c' => 'importExport', 'a' => 'index'], true);
return;
Expand Down Expand Up @@ -654,7 +652,7 @@ public function exportAction() {
header('Content-Type: ' . $content_type);
header('Content-disposition: attachment; filename="' . $filename . '"');

$this->view->_layout(false);
$this->view->_layout(null);
$this->view->content = $content;
}

Expand Down
12 changes: 6 additions & 6 deletions app/Controllers/indexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public function normalAction(): void {

FreshRSS_Context::$id_max = time() . '000000';

$this->view->callbackBeforeFeeds = function ($view) {
$this->view->callbackBeforeFeeds = function (FreshRSS_View $view) {
try {
$tagDAO = FreshRSS_Factory::createTagDao();
$view->tags = $tagDAO->listTags(true);
$view->tags = $tagDAO->listTags(true) ?: [];
$view->nbUnreadTags = 0;
foreach ($view->tags as $tag) {
$view->nbUnreadTags += $tag->nbUnread();
Expand All @@ -71,7 +71,7 @@ public function normalAction(): void {
}
};

$this->view->callbackBeforeEntries = function ($view) {
$this->view->callbackBeforeEntries = function (FreshRSS_View $view) {
try {
FreshRSS_Context::$number++; //+1 for articles' page
$view->entries = FreshRSS_index_Controller::listEntriesByContext();
Expand All @@ -83,7 +83,7 @@ public function normalAction(): void {
}
};

$this->view->callbackBeforePagination = function ($view, $nbEntries, $lastEntry) {
$this->view->callbackBeforePagination = function (?FreshRSS_View $view, int $nbEntries, FreshRSS_Entry $lastEntry) {
if ($nbEntries >= FreshRSS_Context::$number) {
//We have enough entries: we discard the last one to use it for the next articles' page
ob_clean();
Expand Down Expand Up @@ -170,7 +170,7 @@ public function rssAction(): void {
// No layout for RSS output.
$this->view->rss_url = PUBLIC_TO_INDEX_PATH . '/' . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']);
$this->view->rss_title = FreshRSS_Context::$name . ' | ' . FreshRSS_View::title();
$this->view->_layout(false);
$this->view->_layout(null);
header('Content-Type: application/rss+xml; charset=utf-8');
}

Expand Down Expand Up @@ -238,7 +238,7 @@ public function opmlAction(): void {
}

// No layout for OPML output.
$this->view->_layout(false);
$this->view->_layout(null);
header('Content-Type: application/xml; charset=utf-8');
}

Expand Down
6 changes: 3 additions & 3 deletions app/Controllers/javascriptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class FreshRSS_javascript_Controller extends FreshRSS_ActionController {

public function firstAction(): void {
$this->view->_layout(false);
$this->view->_layout(null);
}

public function actualizeAction(): void {
Expand All @@ -20,9 +20,9 @@ public function actualizeAction(): void {
public function nbUnreadsPerFeedAction(): void {
header('Content-Type: application/json; charset=UTF-8');
$catDAO = FreshRSS_Factory::createCategoryDao();
$this->view->categories = $catDAO->listCategories(true, false);
$this->view->categories = $catDAO->listCategories(true, false) ?: [];
$tagDAO = FreshRSS_Factory::createTagDao();
$this->view->tags = $tagDAO->listTags(true);
$this->view->tags = $tagDAO->listTags(true) ?: [];
}

//For Web-form login
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/statsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function firstAction(): void {

$catDAO->checkDefault();
$feedDAO->updateTTL();
$this->view->categories = $catDAO->listSortedCategories(false);
$this->view->categories = $catDAO->listSortedCategories(false) ?: [];
$this->view->default_category = $catDAO->getDefault();

FreshRSS_View::prependTitle(_t('admin.stats.title') . ' · ');
Expand Down Expand Up @@ -207,7 +207,7 @@ public function repartitionAction(): void {
$id = null;
}

$this->view->categories = $categoryDAO->listCategories();
$this->view->categories = $categoryDAO->listCategories() ?: [];
$this->view->feed = $id === null ? null : $feedDAO->searchById($id);
$this->view->days = $statsDAO->getDays();
$this->view->months = $statsDAO->getMonths();
Expand Down
12 changes: 6 additions & 6 deletions app/Controllers/subscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function firstAction(): void {

$catDAO->checkDefault();
$feedDAO->updateTTL();
$this->view->categories = $catDAO->listSortedCategories(false, true);
$this->view->categories = $catDAO->listSortedCategories(false, true) ?: [];
$this->view->default_category = $catDAO->getDefault();

$signalError = false;
Expand Down Expand Up @@ -90,7 +90,7 @@ public function indexAction(): void {
*/
public function feedAction(): void {
if (Minz_Request::paramBoolean('ajax')) {
$this->view->_layout(false);
$this->view->_layout(null);
} else {
FreshRSS_View::appendScript(Minz_Url::display('/scripts/feed.js?' . @filemtime(PUBLIC_PATH . '/scripts/feed.js')));
}
Expand Down Expand Up @@ -200,7 +200,7 @@ public function feedAction(): void {
]);
}

$feed->_filtersAction('read', preg_split('/[\n\r]+/', Minz_Request::paramString('filteractions_read')));
$feed->_filtersAction('read', preg_split('/[\n\r]+/', Minz_Request::paramString('filteractions_read')) ?: []);

$feed->_kind(Minz_Request::paramInt('feed_kind') ?: FreshRSS_Feed::KIND_RSS);
if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH || $feed->kind() === FreshRSS_Feed::KIND_XML_XPATH) {
Expand Down Expand Up @@ -235,8 +235,8 @@ public function feedAction(): void {
'name' => Minz_Request::paramString('name'),
'kind' => $feed->kind(),
'description' => sanitizeHTML(Minz_Request::paramString('description', true)),
'website' => checkUrl(Minz_Request::paramString('website')),
'url' => checkUrl(Minz_Request::paramString('url')),
'website' => checkUrl(Minz_Request::paramString('website')) ?: '',
'url' => checkUrl(Minz_Request::paramString('url')) ?: '',
'category' => Minz_Request::paramInt('category'),
'pathEntries' => Minz_Request::paramString('path_entries'),
'priority' => Minz_Request::paramTernary('priority') === null ? FreshRSS_Feed::PRIORITY_MAIN_STREAM : Minz_Request::paramInt('priority'),
Expand Down Expand Up @@ -283,7 +283,7 @@ public function feedAction(): void {
}

public function categoryAction(): void {
$this->view->_layout(false);
$this->view->_layout(null);

$categoryDAO = FreshRSS_Factory::createCategoryDao();

Expand Down
15 changes: 7 additions & 8 deletions app/Controllers/tagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function firstAction(): void {
// If ajax request, we do not print layout
$this->ajax = Minz_Request::paramBoolean('ajax');
if ($this->ajax) {
$this->view->_layout(false);
$this->view->_layout(null);
Minz_Request::_param('ajax');
}
}
Expand All @@ -39,7 +39,7 @@ public function tagEntryAction(): void {
$checked = Minz_Request::paramTernary('checked');
if ($id_entry != '') {
$tagDAO = FreshRSS_Factory::createTagDao();
if ($id_tag === 0 && $name_tag !== '' && $checked) {
if ($id_tag == 0 && $name_tag !== '' && $checked) {
if ($existing_tag = $tagDAO->searchByName($name_tag)) {
// Use existing tag
$tagDAO->tagEntry($existing_tag->id(), $id_entry, $checked);
Expand All @@ -48,7 +48,7 @@ public function tagEntryAction(): void {
$id_tag = $tagDAO->addTag(array('name' => $name_tag));
}
}
if ($id_tag !== 0) {
if ($id_tag != false) {
$tagDAO->tagEntry($id_tag, $id_entry, $checked);
}
}
Expand Down Expand Up @@ -82,12 +82,12 @@ public function deleteAction(): void {
}

public function getTagsForEntryAction(): void {
$this->view->_layout(false);
$this->view->_layout(null);
header('Content-Type: application/json; charset=UTF-8');
header('Cache-Control: private, no-cache, no-store, must-revalidate');
$id_entry = Minz_Request::paramString('id_entry');
$tagDAO = FreshRSS_Factory::createTagDao();
$this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry);
$this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry) ?: [];
}

public function addAction(): void {
Expand All @@ -110,11 +110,10 @@ public function addAction(): void {
}

/**
* @return void|null
* @throws Minz_ConfigurationNamespaceException
* @throws Minz_PDOConnectionException
*/
public function renameAction() {
public function renameAction(): void {
if (!Minz_Request::isPost()) {
Minz_Error::error(405);
}
Expand Down Expand Up @@ -145,6 +144,6 @@ public function renameAction() {

public function indexAction(): void {
$tagDAO = FreshRSS_Factory::createTagDao();
$this->view->tags = $tagDAO->listTags();
$this->view->tags = $tagDAO->listTags() ?: [];
}
}
6 changes: 3 additions & 3 deletions app/Models/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public static function giveAccess(): bool {
* Returns if current user has access to the given scope.
*
* @param string $scope general (default) or admin
* @return boolean true if user has corresponding access, false else.
* @return bool true if user has corresponding access, false else.
*/
public static function hasAccess($scope = 'general'): bool {
public static function hasAccess(string $scope = 'general'): bool {
if (FreshRSS_Context::$user_conf == null) {
return false;
}
Expand All @@ -154,7 +154,7 @@ public static function hasAccess($scope = 'general'): bool {
default:
$ok = false;
}
return $ok;
return (bool)$ok;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Models/BooleanSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private function parseOrSegments(string $input): void {
if ($input == '') {
return;
}
$splits = preg_split('/\b(OR)\b/i', $input, -1, PREG_SPLIT_DELIM_CAPTURE);
$splits = preg_split('/\b(OR)\b/i', $input, -1, PREG_SPLIT_DELIM_CAPTURE) ?: [];

$segment = '';
$ns = count($splits);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function refreshDynamicOpml(): bool {
$catDAO = FreshRSS_Factory::createCategoryDao();
$catDAO->updateLastUpdate($this->id(), !$ok);

return $ok;
return (bool)$ok;
}

private function sortFeeds(): void {
Expand Down
Loading