Skip to content

Commit

Permalink
fix: phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Sep 16, 2024
1 parent c43b3d5 commit 588f48a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
9 changes: 2 additions & 7 deletions src/Access/PollPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Flarum\User\Access\AbstractPolicy;
use Flarum\User\User;
use FoF\Polls\Poll;
use Illuminate\Support\Arr;

class PollPolicy extends AbstractPolicy
{
Expand Down Expand Up @@ -62,13 +63,7 @@ public function changeVote(User $actor, Poll $poll)
return $this->allow();
}

if (!$poll->allow_change_vote) {
return $this->deny();
}

if ($poll->allow_change_vote) {
return $this->allow();
}
return (bool) Arr::get($poll->settings, 'allow_change_vote', false);
}

public function edit(User $actor, Poll $poll)
Expand Down
3 changes: 1 addition & 2 deletions src/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* @property-read bool $allow_multiple_votes
* @property-read int $max_votes
* @property-read bool $hide_votes
* @property-read bool $allow_change_vote
* @property int $vote_count
* @property Post $post
* @property User $user
Expand All @@ -45,7 +44,7 @@
* @property string|null $image
* @property string|null $image_alt
*
* @phpstan-type PollSettings array{'public_poll': bool, 'allow_multiple_votes': bool, 'max_votes': int}
* @phpstan-type PollSettings array{'public_poll': bool, 'allow_multiple_votes': bool, 'max_votes': int, 'allow_change_vote' : bool}
*/
class Poll extends AbstractModel
{
Expand Down

0 comments on commit 588f48a

Please sign in to comment.