Skip to content

Commit

Permalink
Autocommit PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin authored and github-actions[bot] committed Sep 13, 2024
1 parent 190bcf2 commit 69168ec
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public static function onWallEntryControlsInit($event)
{
$object = $event->sender->object;

if(!$object instanceof Poll) {
if (!$object instanceof Poll) {
return;
}

if($object->content->canEdit()) {
if ($object->content->canEdit()) {
$event->sender->addWidget(CloseButton::class, [
'poll' => $object,
]);
}

if($object->isResetAllowed()) {
if ($object->isResetAllowed()) {
$event->sender->addWidget(ResetButton::class, [
'poll' => $object,
]);
Expand All @@ -54,7 +54,7 @@ public static function onWallEntryControlsInit($event)
*/
public static function onUserDelete($event)
{
foreach (PollAnswerUser::findAll(array('created_by' => $event->sender->id)) as $answer) {
foreach (PollAnswerUser::findAll(['created_by' => $event->sender->id]) as $answer) {
$answer->delete();
}

Expand Down
8 changes: 4 additions & 4 deletions controllers/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function actionReload($id)
{
$model = Poll::findOne(['id' => $id]);

if(!$model) {
if (!$model) {
throw new HttpException(404);
}

Expand Down Expand Up @@ -144,7 +144,7 @@ public function actionAnswer()
$answers = Yii::$app->request->post('answers');

// Build array of answer ids
$votes = array();
$votes = [];
if (is_array($answers)) {
foreach ($answers as $answer_id => $flag) {
$votes[] = (int) $answer_id;
Expand Down Expand Up @@ -196,7 +196,7 @@ public function actionUserListResults()
$query->andWhere(['poll_answer_user.poll_answer_id' => $answerId]);
$query->orderBy('poll_answer_user.created_at DESC');

$title = Yii::t('PollsModule.controllers_PollController', "Users voted for: <strong>{answer}</strong>", array('{answer}' => Html::encode($answer->answer)));
$title = Yii::t('PollsModule.controllers_PollController', "Users voted for: <strong>{answer}</strong>", ['{answer}' => Html::encode($answer->answer)]);

return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
}
Expand All @@ -209,7 +209,7 @@ public function actionUserListResults()
*/
private function renderPollOut($question)
{
$json = array();
$json = [];
$json['output'] = $this->renderAjaxContent($question->getWallOut());

return $this->asJson($json);
Expand Down
2 changes: 1 addition & 1 deletion controllers/rest/PollsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function actionVote(int $id): array

$answers = Yii::$app->request->post('answers');

$votes = array();
$votes = [];
if (is_array($answers)) {
foreach ($answers as $answerId) {
$votes[] = (int)$answerId;
Expand Down
12 changes: 6 additions & 6 deletions migrations/m131023_165921_initial.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ class m131023_165921_initial extends Migration
public function up()
{

$this->createTable('poll', array(
$this->createTable('poll', [
'id' => 'pk',
'question' => 'varchar(255) NOT NULL',
'allow_multiple' => 'tinyint(4) NOT NULL',
'created_at' => 'datetime NOT NULL',
'created_by' => 'int(11) NOT NULL',
'updated_at' => 'datetime NOT NULL',
'updated_by' => 'int(11) NOT NULL',
), '');
], '');

$this->createTable('poll_answer', array(
$this->createTable('poll_answer', [
'id' => 'pk',
'poll_id' => 'int(11) NOT NULL',
'answer' => 'varchar(255) NOT NULL',
'created_at' => 'datetime NOT NULL',
'created_by' => 'int(11) NOT NULL',
'updated_at' => 'datetime NOT NULL',
'updated_by' => 'int(11) NOT NULL',
), '');
], '');

$this->createTable('poll_answer_user', array(
$this->createTable('poll_answer_user', [
'id' => 'pk',
'poll_id' => 'int(11) NOT NULL',
'poll_answer_id' => 'int(11) NOT NULL',
'created_at' => 'datetime NOT NULL',
'created_by' => 'int(11) NOT NULL',
'updated_at' => 'datetime NOT NULL',
'updated_by' => 'int(11) NOT NULL',
), '');
], '');
}

public function down()
Expand Down
22 changes: 11 additions & 11 deletions models/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function scenarios()
*/
public function rules()
{
return array(
return [
[['question'], 'string', 'max' => 255],
[['question'], 'required'],
[['description'], 'string'],
Expand All @@ -87,12 +87,12 @@ public function rules()
[['question'], 'minTwoAnswers', 'on' => self::SCENARIO_EDIT],
[['allow_multiple'], 'integer'],

);
];
}

public function minTwoNewAnswers($attribute)
{
if(count($this->newAnswers) < self::MIN_REQUIRED_ANSWERS) {
if (count($this->newAnswers) < self::MIN_REQUIRED_ANSWERS) {
$this->addError($attribute, Yii::t('PollsModule.models_Poll', "Please specify at least {min} answers!", ["{min}" => self::MIN_REQUIRED_ANSWERS]));
}
}
Expand All @@ -110,7 +110,7 @@ public function minTwoAnswers($attribute)
*/
public function attributeLabels()
{
return array(
return [
'newAnswers' => Yii::t('PollsModule.models_Poll', 'Answers'),
'editAnswers' => Yii::t('PollsModule.models_Poll', 'Answers'),
'question' => Yii::t('PollsModule.models_Poll', 'Question'),
Expand All @@ -119,7 +119,7 @@ public function attributeLabels()
'is_random' => Yii::t('PollsModule.widgets_views_pollForm', 'Display answers in random order?'),
'anonymous' => Yii::t('PollsModule.widgets_views_pollForm', 'Anonymous Votes?'),
'show_result_after_close' => Yii::t('PollsModule.widgets_views_pollForm', 'Hide results until poll is closed?'),
);
];
}

public function getIcon()
Expand Down Expand Up @@ -173,7 +173,7 @@ public function afterSave($insert, $changedAttributes)

RichText::postProcess($this->description, $this);

if($this->scenario === static::SCENARIO_EDIT || $this->scenario === static::SCENARIO_CREATE) {
if ($this->scenario === static::SCENARIO_EDIT || $this->scenario === static::SCENARIO_CREATE) {
if (!$insert) {
$this->updateAnswers();
}
Expand Down Expand Up @@ -272,7 +272,7 @@ public function hasUserVoted($userId = "")
$userId = Yii::$app->user->id;
}

$answer = PollAnswerUser::findOne(array('created_by' => $userId, 'poll_id' => $this->id));
$answer = PollAnswerUser::findOne(['created_by' => $userId, 'poll_id' => $this->id]);

if ($answer == null) {
return false;
Expand All @@ -281,7 +281,7 @@ public function hasUserVoted($userId = "")
return true;
}

public function vote($votes = array())
public function vote($votes = [])
{

if ($this->hasUserVoted()) {
Expand All @@ -291,7 +291,7 @@ public function vote($votes = array())
$voted = false;

foreach ($votes as $answerId) {
$answer = PollAnswer::findOne(array('id' => $answerId, 'poll_id' => $this->id));
$answer = PollAnswer::findOne(['id' => $answerId, 'poll_id' => $this->id]);
if ($answer) {
$userVote = new PollAnswerUser();
$userVote->poll_id = $this->id;
Expand Down Expand Up @@ -321,7 +321,7 @@ public function vote($votes = array())
public function resetAnswer($userId = "")
{

if($this->closed) {
if ($this->closed) {
return;
}

Expand All @@ -331,7 +331,7 @@ public function resetAnswer($userId = "")

if ($this->hasUserVoted($userId)) {

$answers = PollAnswerUser::findAll(array('created_by' => $userId, 'poll_id' => $this->id));
$answers = PollAnswerUser::findAll(['created_by' => $userId, 'poll_id' => $this->id]);
foreach ($answers as $answer) {
$answer->delete();
}
Expand Down
16 changes: 8 additions & 8 deletions models/PollAnswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public static function tableName()
*/
public function rules()
{
return array(
array(['poll_id', 'answer'], 'required'),
array(['poll_id'], 'integer'),
array(['answer'], 'string', 'max' => 255),
);
return [
[['poll_id', 'answer'], 'required'],
[['poll_id'], 'integer'],
[['answer'], 'string', 'max' => 255],
];
}

public function getPoll()
Expand Down Expand Up @@ -74,7 +74,7 @@ public function beforeDelete()
*/
public function getPercent()
{
$total = PollAnswerUser::find()->where(array('poll_id' => $this->poll_id))->count();
$total = PollAnswerUser::find()->where(['poll_id' => $this->poll_id])->count();
if ($total == 0) {
return 0;
}
Expand All @@ -90,7 +90,7 @@ public function getPercent()
public function getTotal()
{

return PollAnswerUser::find()->where(array('poll_answer_id' => $this->id))->count();
return PollAnswerUser::find()->where(['poll_answer_id' => $this->id])->count();
}

public static function filterValidAnswers($answerArr)
Expand All @@ -101,7 +101,7 @@ public static function filterValidAnswers($answerArr)

$result = [];
foreach ($answerArr as $key => $answerText) {
if($answerText != null && $answerText !== '') {
if ($answerText != null && $answerText !== '') {
$result[$key] = $answerText;
}
}
Expand Down
8 changes: 4 additions & 4 deletions models/PollAnswerUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public static function tableName()
*/
public function rules()
{
return array(
array(['poll_answer_id', 'poll_id'], 'required'),
array(['poll_answer_id', 'poll_id'], 'integer'),
);
return [
[['poll_answer_id', 'poll_id'], 'required'],
[['poll_answer_id', 'poll_id'], 'integer'],
];
}

public function getPoll()
Expand Down

0 comments on commit 69168ec

Please sign in to comment.