Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PHP CS Fixer #137

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: PHP CS Fixer

on: push

jobs:
tests:
uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main
6 changes: 3 additions & 3 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public static function onWallEntryControlsInit($event)

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

if($object->isResetAllowed()) {
$event->sender->addWidget(ResetButton::class, [
'poll' => $object
'poll' => $object,
]);
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public static function onSampleDataInstall($event)
$poll->newAnswers = [
Yii::t('PollsModule.events', "To Daniel"),
Yii::t('PollsModule.events', "Club A Steakhouse"),
Yii::t('PollsModule.events', "Pisillo Italian Panini")
Yii::t('PollsModule.events', "Pisillo Italian Panini"),
];
$poll->content->container = $space;
$poll->allow_multiple = Yii::$app->request->post('allowMultiple', 0);
Expand Down
5 changes: 2 additions & 3 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class Module extends ContentContainerModule
{

/**
* @inheritdoc
*/
Expand All @@ -42,7 +41,7 @@ public function getContentContainerTypes()
{
return [
Space::class,
User::class
User::class,
];
}

Expand Down Expand Up @@ -77,7 +76,7 @@ public function getPermissions($contentContainer = null)
{
if ($contentContainer) {
return [
new permissions\CreatePoll()
new permissions\CreatePoll(),
];
}

Expand Down
3 changes: 1 addition & 2 deletions activities/NewVote.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

class NewVote extends BaseActivity implements ConfigurableActivityInterface
{

/**
* @inheritdoc
*/
public $moduleId = 'polls';

/**
* @inheritdoc
*/
Expand Down
7 changes: 3 additions & 4 deletions assets/PollsAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

class PollsAsset extends AssetBundle
{

public $jsOptions = ['position' => \yii\web\View::POS_END];
public $sourcePath = '@polls/resources';
public $css = [];
public $js = [
'js/humhub.polls.js'
'js/humhub.polls.js',
];

/**
Expand All @@ -30,8 +29,8 @@ public static function register($view)
{
$view->registerJsConfig('polls', [
'text' => [
'warn.answer_required' => Yii::t('PollsModule.base', 'At least one answer is required')
]
'warn.answer_required' => Yii::t('PollsModule.base', 'At least one answer is required'),
],
]);
return parent::register($view);
}
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
['class' => IntegrityController::class, 'event' => IntegrityController::EVENT_ON_RUN, 'callback' => ['humhub\modules\polls\Events', 'onIntegrityCheck']],
['class' => 'humhub\modules\installer\controllers\ConfigController', 'event' => 'install_sample_data', 'callback' => ['humhub\modules\polls\Events', 'onSampleDataInstall']],
['class' => 'humhub\modules\rest\Module', 'event' => 'restApiAddRules', 'callback' => ['humhub\modules\polls\Events', 'onRestApiAddRules']],
]
],
];
9 changes: 4 additions & 5 deletions controllers/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class PollController extends ContentContainerController
{

public function actionCreateForm()
{
if (!(new Poll($this->contentContainer))->content->canEdit()) {
Expand All @@ -47,7 +46,7 @@ public function actionCreate()
if (!$this->contentContainer->permissionManager->can(new CreatePoll())) {
throw new HttpException(400, 'Access denied!');
}

$poll = new Poll(['scenario' => Poll::SCENARIO_CREATE]);
$poll->load(Yii::$app->request->post());
return WallCreateForm::create($poll, $this->contentContainer);
Expand Down Expand Up @@ -108,12 +107,12 @@ public function actionEdit()

public function actionOpen()
{
return $this->asJson($this->setClosed(Yii::$app->request->get('id'), false));
return $this->asJson($this->setClosed(Yii::$app->request->get('id'), false));
}

public function actionClose()
{
return $this->asJson($this->setClosed(Yii::$app->request->get('id'), true));
return $this->asJson($this->setClosed(Yii::$app->request->get('id'), true));
}

public function setClosed($id, $closed)
Expand All @@ -131,7 +130,7 @@ public function setClosed($id, $closed)
$model->save();
// Refresh updated_at
$model->content->refresh();

return Stream::getContentResultEntry($model->content);
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/rest/PollsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ public function actionVotes(int $id): array
->andWhere(['poll_id' => $id])
->column();
}
}
}
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.3.6 (Unreleased)
----------------------
- Enh #137: Use PHP CS Fixer

1.3.5 (June 18, 2024)
----------------------
- Fix #129: Fix memory usage on integrity check
Expand Down
2 changes: 1 addition & 1 deletion helpers/RestDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ public static function getAnswer(PollAnswer $pollAnswer): array
'updated_by' => UserDefinitions::getUserShort($pollAnswer->updatedBy),
];
}
}
}
7 changes: 3 additions & 4 deletions migrations/m131023_165921_initial.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class m131023_165921_initial extends Migration
{

public function up()
{

Expand All @@ -16,7 +15,7 @@ public function up()
'created_by' => 'int(11) NOT NULL',
'updated_at' => 'datetime NOT NULL',
'updated_by' => 'int(11) NOT NULL',
), '');
), '');

$this->createTable('poll_answer', array(
'id' => 'pk',
Expand All @@ -26,7 +25,7 @@ public function up()
'created_by' => 'int(11) NOT NULL',
'updated_at' => 'datetime NOT NULL',
'updated_by' => 'int(11) NOT NULL',
), '');
), '');

$this->createTable('poll_answer_user', array(
'id' => 'pk',
Expand All @@ -36,7 +35,7 @@ public function up()
'created_by' => 'int(11) NOT NULL',
'updated_at' => 'datetime NOT NULL',
'updated_by' => 'int(11) NOT NULL',
), '');
), '');
}

public function down()
Expand Down
1 change: 0 additions & 1 deletion migrations/m131030_122743_longer_questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class m131030_122743_longer_questions extends Migration
{

public function up()
{
$this->alterColumn('poll', 'question', 'TEXT NOT NULL');
Expand Down
1 change: 0 additions & 1 deletion migrations/m141002_093710_fix_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class m141002_093710_fix_default extends Migration
{

public function up()
{
$this->alterColumn('poll', 'allow_multiple', "smallint(6) NOT NULL DEFAULT 0");
Expand Down
1 change: 0 additions & 1 deletion migrations/m150709_151858_namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

class m150709_151858_namespace extends Migration
{

public function up()
{
$this->renameClass('Poll', humhub\modules\polls\models\Poll::className());
Expand Down
6 changes: 3 additions & 3 deletions migrations/m160218_132531_close_and_anonymous_poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class m160218_132531_close_and_anonymous_poll extends Migration
{
public function up()
{
$this->addColumn('poll', 'is_random', Schema::TYPE_BOOLEAN. ' DEFAULT 0');
$this->addColumn('poll', 'closed', Schema::TYPE_BOOLEAN. ' DEFAULT 0');
$this->addColumn('poll', 'anonymous', Schema::TYPE_BOOLEAN. ' DEFAULT 0');
$this->addColumn('poll', 'is_random', Schema::TYPE_BOOLEAN . ' DEFAULT 0');
$this->addColumn('poll', 'closed', Schema::TYPE_BOOLEAN . ' DEFAULT 0');
$this->addColumn('poll', 'anonymous', Schema::TYPE_BOOLEAN . ' DEFAULT 0');
}

public function down()
Expand Down
2 changes: 1 addition & 1 deletion migrations/m180327_125017_show_result_after_close.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class m180327_125017_show_result_after_close extends Migration
{
public function safeUp()
{
$this->addColumn('poll', 'show_result_after_close', Schema::TYPE_BOOLEAN. ' DEFAULT 0');
$this->addColumn('poll', 'show_result_after_close', Schema::TYPE_BOOLEAN . ' DEFAULT 0');
}

public function safeDown()
Expand Down
2 changes: 1 addition & 1 deletion migrations/m201020_125649_question_description.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public function safeUp()
public function safeDown()
{
$this->dropColumn('poll', 'question');
$this->renameColumn('poll', 'description','question');
$this->renameColumn('poll', 'description', 'question');
}
}
1 change: 0 additions & 1 deletion migrations/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class uninstall extends Migration
{

public function up()
{

Expand Down
Loading