[TOOLS] Fix errors pointed out by PHPStan level 4

This commit is contained in:
2022-10-19 22:38:49 +01:00
parent 4d7742e0e1
commit edeee49af9
37 changed files with 168 additions and 198 deletions

View File

@@ -81,7 +81,7 @@ class RepeatNote extends NoteHandlerPlugin
$original_note_id = $note->getId();
// Create a new note with the same content as the original
[, $repeat, ] = Posting::storeLocalNote(
[, $repeat] = Posting::storeLocalNote(
actor: $actor = Actor::getById($actor_id),
content: $note->getContent(),
content_type: $note->getContentType(),
@@ -186,10 +186,10 @@ class RepeatNote extends NoteHandlerPlugin
} else {
// Either was undoed already
if (!\is_null($already_repeated_activity = DB::findOneBy(Activity::class, [
'actor_id' => $actor_id,
'verb' => 'repeat',
'actor_id' => $actor_id,
'verb' => 'repeat',
'object_type' => 'note',
'object_id' => $note_id,
'object_id' => $note_id,
], return_null: true))) {
return DB::findOneBy(Activity::class, [
'actor_id' => $actor_id,
@@ -209,8 +209,6 @@ class RepeatNote extends NoteHandlerPlugin
* original Note on Actor feed
*
* @param array $notes List of Notes to be filtered
*
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
*/
public function onFilterNoteList(?Actor $actor, array &$notes, Request $request): EventResult
{
@@ -234,8 +232,6 @@ class RepeatNote extends NoteHandlerPlugin
/**
* HTML rendering event that adds the repeat form as a note
* action, if a user is logged in
*
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
*/
public function onAddNoteActions(Request $request, Note $note, array &$actions): EventResult
{
@@ -278,8 +274,6 @@ class RepeatNote extends NoteHandlerPlugin
* @param array $vars Contains the Note currently being rendered
* @param array $result Rendered String containing anchors for Actors that
* repeated the Note
*
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
*/
public function onAppendCardNote(array $vars, array &$result): EventResult
{
@@ -316,8 +310,6 @@ class RepeatNote extends NoteHandlerPlugin
*
* @param Note $note Note to be deleted
* @param Actor $actor Who performed the Delete action
*
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
*/
public function onNoteDeleteRelated(Note &$note, Actor $actor): EventResult
{
@@ -338,8 +330,6 @@ class RepeatNote extends NoteHandlerPlugin
*
* - **repeat_remove**
* same as above, except that it undoes the aforementioned action
*
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
*/
public function onAddRoute(Router $r): EventResult
{
@@ -369,10 +359,8 @@ class RepeatNote extends NoteHandlerPlugin
* @throws ClientException
* @throws DuplicateFoundException
* @throws ServerException
*
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
*/
private function activitypub_handler(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, mixed $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): bool
private function activitypub_handler(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, mixed $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): EventResult
{
if (!\in_array($type_activity->get('type'), ['Announce', 'Undo']) || !$actor->isPerson()) {
return Event::next;
@@ -463,8 +451,6 @@ class RepeatNote extends NoteHandlerPlugin
* @throws ClientException
* @throws DuplicateFoundException
* @throws ServerException
*
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
*/
public function onNewActivityPubActivity(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, \ActivityPhp\Type\AbstractObject $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): EventResult
{
@@ -488,8 +474,6 @@ class RepeatNote extends NoteHandlerPlugin
* @throws ClientException
* @throws DuplicateFoundException
* @throws ServerException
*
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
*/
public function onNewActivityPubActivityWithObject(Actor $actor, \ActivityPhp\Type\AbstractObject $type_activity, mixed $type_object, ?\Plugin\ActivityPub\Entity\ActivitypubActivity &$ap_act): EventResult
{
@@ -501,8 +485,6 @@ class RepeatNote extends NoteHandlerPlugin
*
* @param string $verb GNU social's internal verb
* @param null|string $gs_verb_to_activity_stream_two_verb Resulting Activity Streams 2.0 verb
*
* @return bool Returns `Event::stop` if handled, `Event::next` otherwise
*/
public function onGSVerbToActivityStreamsTwoActivityType(string $verb, ?string &$gs_verb_to_activity_stream_two_verb): EventResult
{