Skip to content

Commit

Permalink
Merge pull request #14208 from jeabakker/features
Browse files Browse the repository at this point in the history
chore(core): scrutinizer issues
  • Loading branch information
jeabakker committed Nov 7, 2022
2 parents ddce45c + 3d11203 commit 0b8d2a8
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion engine/classes/Elgg/Email/DelayedQueue/CronHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CronHandler {
* @return void
*/
public function __invoke(\Elgg\Event $event): void {
$time = $event->getParam('time');
$time = (int) $event->getParam('time');
$interval = $event->getType();

_elgg_services()->delayedEmailService->processQueuedNotifications($interval, $time);
Expand Down
13 changes: 6 additions & 7 deletions engine/classes/Elgg/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,16 @@ public function trigger(string $name, string $type, $object = null, array $optio
/**
* Triggers a event that is allowed to return a mixed result
*
* @param string $name The name of the event
* @param string $type The type of the event
* @param mixed $params Supplied params for the event
* @param mixed $value The value of the event, this can be altered by registered callbacks
* @param array $options (internal) options for triggering the event
* @param string $name The name of the event
* @param string $type The type of the event
* @param mixed $params Supplied params for the event
* @param mixed $value The value of the event, this can be altered by registered callbacks
*
* @return mixed
*
* @see elgg_trigger_event_results()
*/
public function triggerResults(string $name, string $type, array $params = [], $value = null, array $options = []) {
public function triggerResults(string $name, string $type, array $params = [], $value = null) {
// This starts as a string, but if a handler type-hints an object we convert it on-demand inside
// \Elgg\HandlersService::call and keep it alive during all handler calls. We do this because
// creating objects for every triggering is expensive.
Expand Down Expand Up @@ -240,7 +239,7 @@ public function triggerResultsSequence(string $name, string $type, array $params
return false;
}

$result = $this->triggerResults($name, $type, $params, $value, $options);
$result = $this->triggerResults($name, $type, $params, $value);
if ($result === false) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion engine/classes/Elgg/Views/MinifyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MinifyHandler {
* @return string|null View content minified (if css/js type)
*/
public function __invoke(\Elgg\Event $event) {
if (preg_match('~[\.-]min\.~', $event->getParam('view'))) {
if (preg_match('~[\.-]min\.~', (string) $event->getParam('view'))) {
// bypass minification
return;
}
Expand Down
6 changes: 3 additions & 3 deletions engine/lib/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function elgg_trigger_after_event(string $event, string $type, $object = null):
*
* @see elgg_trigger_event()
*/
function elgg_trigger_deprecated_event(string $event, string $type, $object = null, string $message = null, string $version = null) {
function elgg_trigger_deprecated_event(string $event, string $type, $object = null, string $message = '', string $version = '') {
return _elgg_services()->events->triggerDeprecated($event, $type, $object, $message, $version);
}

Expand All @@ -189,6 +189,6 @@ function elgg_trigger_deprecated_event(string $event, string $type, $object = nu
*
* @since 5.0
*/
function elgg_trigger_deprecated_event_results(string $event, string $type, $params = null, $returnvalue = null, string $message = null, string $version = null) {
return _elgg_services()->events->triggerDeprecated($event, $type, $params, $returnvalue, $message, $version);
function elgg_trigger_deprecated_event_results(string $event, string $type, $params = null, $returnvalue = null, string $message = '', string $version = '') {
return _elgg_services()->events->triggerDeprecatedResults($event, $type, $params, $returnvalue, $message, $version);
}
10 changes: 6 additions & 4 deletions mod/developers/classes/Elgg/Developers/HandlerLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ public static function trackEvent(\Elgg\Event $event) : void {
/**
* Track the actual event / plugin hook
*
* @param string $name name of the event / hook
* @param string $type type of the event / hook
* @param mixed $source source event / hook
* @param string $name name of the event / hook
* @param string $type type of the event / hook
*
* @return void
*/
protected static function track(string $name, string $type, $source) : void {
protected static function track(string $name, string $type) : void {
// filter out some very common events
$filter = [
'classes',
Expand All @@ -63,7 +62,10 @@ protected static function track(string $name, string $type, $source) : void {
$trigger_functions = [
'elgg_trigger_event',
'elgg_trigger_event_results',
'elgg_trigger_after_event',
'elgg_trigger_before_event',
'triggerResults',
'triggerResultsSequence',
'triggerSequence',
'triggerBefore',
'triggerAfter',
Expand Down
2 changes: 1 addition & 1 deletion mod/developers/lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function developers_wrap_views(\Elgg\Event $event) {
'page/elements/html',
];

$view = $event->getParam('view');
$view = (string) $event->getParam('view');
if (in_array($view, $excluded_views)) {
return;
}
Expand Down
18 changes: 9 additions & 9 deletions mod/discussions/classes/Elgg/Discussions/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class Notifications {
/**
* Prepare a notification message about a new comment on a discussion
*
* @param \Elgg\Event $event 'prepare', 'notification:create:object:comment'
* @param \Elgg\Event $elgg_event 'prepare', 'notification:create:object:comment'
*
* @return void|\Elgg\Notifications\Notification
*/
public static function prepareCommentOnDiscussionNotification(\Elgg\Event $event) {
public static function prepareCommentOnDiscussionNotification(\Elgg\Event $elgg_event) {

$event = $event->getParam('event');
$event = $elgg_event->getParam('event');
if (!$event instanceof \Elgg\Notifications\NotificationEvent) {
return;
}
Expand All @@ -35,11 +35,11 @@ public static function prepareCommentOnDiscussionNotification(\Elgg\Event $event
return;
}

$language = $event->getParam('language');
$language = $elgg_event->getParam('language');

$poster = $comment->getOwnerEntity();

$notification = $event->getValue();
$notification = $elgg_event->getValue();
$notification->subject = elgg_echo('discussion:comment:notify:subject', [$discussion->getDisplayName()], $language);
$notification->summary = elgg_echo('discussion:comment:notify:summary', [$discussion->getDisplayName()], $language);
$notification->body = elgg_echo('discussion:comment:notify:body', [
Expand All @@ -56,13 +56,13 @@ public static function prepareCommentOnDiscussionNotification(\Elgg\Event $event
/**
* Add group members to the comment subscriber on a discussion
*
* @param \Elgg\Event $event 'get', 'subscriptions'
* @param \Elgg\Event $elgg_event 'get', 'subscriptions'
*
* @return void|array
*/
public static function addGroupSubscribersToCommentOnDiscussionSubscriptions(\Elgg\Event $event) {
public static function addGroupSubscribersToCommentOnDiscussionSubscriptions(\Elgg\Event $elgg_event) {

$event = $event->getParam('event');
$event = $elgg_event->getParam('event');
if (!$event instanceof \Elgg\Notifications\SubscriptionNotificationEvent) {
return;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public static function addGroupSubscribersToCommentOnDiscussionSubscriptions(\El
return;
}

$subscriptions = $event->getValue();
$subscriptions = $elgg_event->getValue();

// get subscribers on the group (using the discussion create preference for detailed subscriptions)
$methods = elgg_get_notification_methods();
Expand Down
2 changes: 1 addition & 1 deletion mod/invitefriends/classes/Elgg/InviteFriends/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function addFriendsOnRegister(\Elgg\Event $event) {
return;
}

if (!elgg_validate_invite_code($friend_user->username, $event->getParam('invitecode'))) {
if (!elgg_validate_invite_code($friend_user->username, (string) $event->getParam('invitecode'))) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class Notifications {
/**
* Create a site notification
*
* @param \Elgg\Event $event 'send', 'notification:site'
* @param \Elgg\Event $elgg_event 'send', 'notification:site'
*
* @return void|true
*/
public static function createSiteNotifications(\Elgg\Event $event) {
public static function createSiteNotifications(\Elgg\Event $elgg_event) {
/* @var $notification \Elgg\Notifications\Notification */
$notification = $event->getParam('notification');
$notification = $elgg_event->getParam('notification');
/* @var $event \Elgg\Notifications\NotificationEvent */
$event = $event->getParam('event');
$event = $elgg_event->getParam('event');

$note = elgg_call(ELGG_IGNORE_ACCESS | ELGG_DISABLE_SYSTEM_LOG, function() use ($notification, $event) {
return \SiteNotification::factory($notification, $event);
Expand Down
1 change: 1 addition & 0 deletions views/default/widgets/elgg_blog/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$data = $response->getBody()->getContents();
$blogs = @json_decode($data);
} catch (\Exception $e) {
// catch any issue and ignore it until later
}

if (empty($blogs) || !is_array($blogs)) {
Expand Down

0 comments on commit 0b8d2a8

Please sign in to comment.