[TOOLS] Fix all errors found by PHPStan level 1
This commit is contained in:
@@ -12,7 +12,7 @@ class TypeResponse extends JsonResponse
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function __construct($data = null, int $status = 202, array $headers = [], bool $json = false)
|
||||
public function __construct($data = null, int $status = 202)
|
||||
{
|
||||
parent::__construct(
|
||||
data: !is_null($data) ? $data->toJson() : null,
|
||||
|
@@ -31,6 +31,8 @@ abstract class AbstractObject
|
||||
*/
|
||||
private array $_props = [];
|
||||
|
||||
protected string $type = 'AbstractObject';
|
||||
|
||||
/**
|
||||
* Standard setter method
|
||||
* - Perform content validation if a validator exists
|
||||
|
@@ -77,28 +77,32 @@ class Favourite extends NoteHandlerPlugin
|
||||
|
||||
// Form handler
|
||||
$ret = self::noteActionHandle(
|
||||
$request, $form_fav, $note, "favourite-{$note->getId()}", /**
|
||||
* Called from form handler
|
||||
*
|
||||
* @param $note Note to be favourited
|
||||
* @param $data Form input
|
||||
*
|
||||
* @throws RedirectException Always thrown in order to prevent accidental form re-submit from browser
|
||||
*/ function ($note, $data) use ($opts, $request) {
|
||||
$favourite_note = DB::find('favourite', $opts);
|
||||
if ($data["favourite-{$note->getId()}"] === '0' && $favourite_note === null) {
|
||||
DB::persist(Entity\Favourite::create($opts));
|
||||
DB::flush();
|
||||
} else if ($data["favourite-{$note->getId()}"] === '1' && $favourite_note !== null) {
|
||||
DB::remove($favourite_note);
|
||||
DB::flush();
|
||||
}
|
||||
$request, $form_fav, $note, "favourite-{$note->getId()}",
|
||||
/**
|
||||
* Called from form handler
|
||||
*
|
||||
* @param $note Note to be favourited
|
||||
* @param $data Form input
|
||||
*
|
||||
* @throws RedirectException Always thrown in order to prevent accidental form re-submit from browser
|
||||
*/
|
||||
function ($note, $data) use ($opts) {
|
||||
$favourite_note = DB::find('favourite', $opts);
|
||||
if ($data["favourite-{$note->getId()}"] === '0' && $favourite_note === null) {
|
||||
DB::persist(Entity\Favourite::create($opts));
|
||||
DB::flush();
|
||||
} else {
|
||||
if ($data["favourite-{$note->getId()}"] === '1' && $favourite_note !== null) {
|
||||
DB::remove($favourite_note);
|
||||
DB::flush();
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent accidental refreshes from resubmitting the form
|
||||
throw new RedirectException();
|
||||
// Prevent accidental refreshes from resubmitting the form
|
||||
throw new RedirectException();
|
||||
|
||||
return Event::stop;
|
||||
});
|
||||
return Event::stop;
|
||||
});
|
||||
|
||||
if ($ret !== null) {
|
||||
return $ret;
|
||||
|
@@ -61,7 +61,7 @@ class Repeat extends NoteHandlerPlugin
|
||||
|
||||
// Handle form
|
||||
$ret = self::noteActionHandle(
|
||||
$request, $form_repeat, $note, "repeat-{$note->getId()}", function ($note, $data, $user) use ($opts) {
|
||||
$request, $form_repeat, $note, "repeat-{$note->getId()}", function ($note, $data, $user) {
|
||||
if ($data["repeat-{$note->getId()}"] === '0') {
|
||||
DB::persist(Note::create([
|
||||
'gsactor_id' => $user->getId(),
|
||||
|
Reference in New Issue
Block a user