Skip to content

Commit

Permalink
Merge pull request opencfp#820 from localheinz/feature/binary-operato…
Browse files Browse the repository at this point in the history
…rs-spaces

Enhancement: Configure binary_operator_spaces fixer to align with minimal space
  • Loading branch information
Dustin Wheeler authored Dec 5, 2017
2 parents 2bf073d + ab2ea61 commit 93844aa
Show file tree
Hide file tree
Showing 33 changed files with 140 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ return PhpCsFixer\Config::create()
'syntax' => 'short'
],
'binary_operator_spaces' => [
'default' => 'align',
'default' => 'align_single_space_minimal',
],
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
Expand Down
6 changes: 3 additions & 3 deletions classes/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function __construct(string $basePath, Environment $environment)
$this->register(new LocaleServiceProvider());
$this->register(new TranslationServiceProvider());
$this->register(new MonologServiceProvider(), [
'monolog.logfile' => $this->config('log.path') ?: "{$basePath}/log/app.log",
'monolog.name' => 'opencfp',
'monolog.level' => \strtoupper(
'monolog.logfile' => $this->config('log.path') ?: "{$basePath}/log/app.log",
'monolog.name' => 'opencfp',
'monolog.level' => \strtoupper(
$this->config('log.level') ?: 'debug'
),
]);
Expand Down
8 changes: 4 additions & 4 deletions classes/Domain/Services/ResetEmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class ResetEmailer
*/
public function __construct(\Swift_Mailer $swiftMailer, \Twig_Template $template, $configEmail, $configTitle)
{
$this->swiftMailer = $swiftMailer;
$this->template = $template;
$this->configEmail = $configEmail;
$this->configTitle = $configTitle;
$this->swiftMailer = $swiftMailer;
$this->template = $template;
$this->configEmail = $configEmail;
$this->configTitle = $configTitle;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions classes/Domain/Talk/TalkProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ public function isDesired(): bool

public function isSponsor(): bool
{
return $this->talk->sponsor ==1;
return $this->talk->sponsor == 1;
}

public function isSpeakerFavorite(): bool
{
return $this->talk->favorite ==1;
return $this->talk->favorite == 1;
}

public function isSelected(): bool
{
return $this->talk->selected ==1;
return $this->talk->selected == 1;
}

public function getComments(): Collection
Expand Down
6 changes: 3 additions & 3 deletions classes/Http/Controller/Admin/ExportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function emailExportAction()

private function talksExportAction(bool $attributed, $where = null)
{
$talks = Talk::orderBy('created_at', 'DESC');
$talks = $where == null ? $talks : $talks->where($where);
$talks = $talks->get()->toArray();
$talks = Talk::orderBy('created_at', 'DESC');
$talks = $where == null ? $talks : $talks->where($where);
$talks = $talks->get()->toArray();

foreach ($talks as $talk => $info) {
$talks[$talk]['created_at'] = $info['created_at'];
Expand Down
10 changes: 5 additions & 5 deletions classes/Http/Controller/Admin/SpeakersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function indexAction(Request $request)
$search = $request->get('search');

/** @var AccountManagement $accounts */
$accounts = $this->service(AccountManagement::class);
$accounts = $this->service(AccountManagement::class);

$adminUsers = $accounts->findByRole('Admin');
$adminUserIds = \array_column($adminUsers, 'id');
Expand Down Expand Up @@ -168,8 +168,8 @@ public function demoteAction(Request $request)
/** @var AccountManagement $accounts */
$accounts = $this->service(AccountManagement::class);

$role = $request->get('role');
$id = (int) $request->get('id');
$role = $request->get('role');
$id = (int) $request->get('id');

/** @var Authentication $authentication */
$authentication = $this->service(Authentication::class);
Expand Down Expand Up @@ -212,8 +212,8 @@ public function promoteAction(Request $request)
/* @var AccountManagement $accounts */
$accounts = $this->service(AccountManagement::class);

$role = $request->get('role');
$id = (int) $request->get('id');
$role = $request->get('role');
$id = (int) $request->get('id');

/** @var Session\Session $session */
$session = $this->service('session');
Expand Down
4 changes: 2 additions & 2 deletions classes/Http/Controller/Admin/TalksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function indexAction(Request $request)
/* @var Authentication $auth */
$auth = $this->service(Authentication::class);

$adminUserId = $auth->userId();
$options = [
$adminUserId = $auth->userId();
$options = [
'order_by' => $request->get('order_by'),
'sort' => $request->get('sort'),
];
Expand Down
8 changes: 4 additions & 4 deletions classes/Http/Controller/ForgotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ public function updatePasswordAction(Request $request)
return $this->render('user/reset_password.twig', ['form' => $form->createView()]);
}

$data = $form->getData();
$userId = $data['user_id'];
$resetCode = $data['reset_code'];
$password = $data['password'];
$data = $form->getData();
$userId = $data['user_id'];
$resetCode = $data['reset_code'];
$password = $data['password'];

if (empty($resetCode)) {
throw new \Exception();
Expand Down
16 changes: 8 additions & 8 deletions classes/Http/Controller/TalkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TalkController extends BaseController
private function getTalkForm($requestData): TalkForm
{
/** @var TalkHelper $helper */
$helper = $this->service(TalkHelper::class);
$helper = $this->service(TalkHelper::class);

$options = [
'categories' => $helper->getTalkCategories(),
Expand All @@ -62,8 +62,8 @@ public function viewAction(Request $request)
$speakers = $this->service('application.speakers');

try {
$talkId = (int) $request->get('id');
$talk = $speakers->getTalk($talkId);
$talkId = (int) $request->get('id');
$talk = $speakers->getTalk($talkId);
} catch (NotAuthorizedException $e) {
return $this->redirectTo('dashboard');
}
Expand All @@ -73,7 +73,7 @@ public function viewAction(Request $request)

public function editAction(Request $request)
{
$talkId = (int) $request->get('id');
$talkId = (int) $request->get('id');

/** @var CallForPapers $callForPapers */
$callForPapers = $this->service(CallForPapers::class);
Expand Down Expand Up @@ -216,7 +216,7 @@ public function processCreateAction(Request $request)

if ($form->validateAll()) {
$sanitizedData = $form->getCleanData();
$sanitizedData['user_id'] = (int) $user->getId();
$sanitizedData['user_id'] = (int) $user->getId();
$talk = Talk::create($sanitizedData);

$session->set('flash', [
Expand Down Expand Up @@ -304,7 +304,7 @@ public function updateAction(Request $request)

if ($form->validateAll()) {
$sanitizedData = $form->getCleanData();
$sanitizedData['user_id'] =(int) $user->getId();
$sanitizedData['user_id'] = (int) $user->getId();

if (Talk::find((int) $sanitizedData['id'])->update($sanitizedData)) {
$session->set('flash', [
Expand Down Expand Up @@ -368,7 +368,7 @@ public function deleteAction(Request $request)
$userId = $authentication->userId();
$talk = Talk::find($request->get('tid'), ['id', 'user_id']);

if ((int) $talk->user_id !== $userId) {
if ((int) $talk->user_id !== $userId) {
return $this->app->json(['delete' => 'no']);
}

Expand Down Expand Up @@ -403,7 +403,7 @@ protected function sendSubmitEmail(string $email, int $talkId)

try {
/** @var \Swift_Mailer $mailer */
$mailer = $this->service('mailer');
$mailer = $this->service('mailer');

$message = new Swift_Message();

Expand Down
4 changes: 2 additions & 2 deletions classes/Http/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public function sanitize()
*/
protected function internalSanitize(array $taintedData): array
{
$purifier = $this->purifier;
$filtered = \array_map(
$purifier = $this->purifier;
$filtered = \array_map(
function ($field) use ($purifier) {
return $purifier->purify($field);
},
Expand Down
36 changes: 13 additions & 23 deletions classes/Http/Form/SignupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public function validateAll($action = 'create')
$agreeCoc = $this->validateAgreeCoc();
}

$validEmail = $this->validateEmail();
$validFirstName = $this->validateFirstName();
$validLastName = $this->validateLastName();
$validCompany = $this->validateCompany();
$validTwitter = $this->validateTwitter();
$validUrl = $this->validateUrl();
$validSpeakerPhoto = $this->validateSpeakerPhoto();
$validSpeakerInfo = true;
$validSpeakerBio = true;
$validEmail = $this->validateEmail();
$validFirstName = $this->validateFirstName();
$validLastName = $this->validateLastName();
$validCompany = $this->validateCompany();
$validTwitter = $this->validateTwitter();
$validUrl = $this->validateUrl();
$validSpeakerPhoto = $this->validateSpeakerPhoto();
$validSpeakerInfo = true;
$validSpeakerBio = true;

if (!empty($this->taintedData['speaker_info'])) {
$validSpeakerInfo = $this->validateSpeakerInfo();
Expand All @@ -72,17 +72,7 @@ public function validateAll($action = 'create')
}

return
$validEmail &&
$validPasswords &&
$validFirstName &&
$validLastName &&
$validCompany &&
$validTwitter &&
$validUrl &&
$validSpeakerInfo &&
$validSpeakerBio &&
$validSpeakerPhoto &&
$agreeCoc;
$validEmail && $validPasswords && $validFirstName && $validLastName && $validCompany && $validTwitter && $validUrl && $validSpeakerInfo && $validSpeakerBio && $validSpeakerPhoto && $agreeCoc;
}

public function validateSpeakerPhoto(): bool
Expand Down Expand Up @@ -277,9 +267,9 @@ public function validateSpeakerInfo(): bool
$this->cleanData['speaker_info'],
FILTER_SANITIZE_STRING
);
$validationResponse = true;
$speakerInfo = \strip_tags($speakerInfo);
$speakerInfo = $this->purifier->purify($speakerInfo);
$validationResponse = true;
$speakerInfo = \strip_tags($speakerInfo);
$speakerInfo = $this->purifier->purify($speakerInfo);

if (empty($speakerInfo)) {
$this->addErrorMessage('You submitted speaker info but it was empty after sanitizing');
Expand Down
9 changes: 1 addition & 8 deletions classes/Http/Form/TalkForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ public function sanitize()
public function validateAll($action = 'create')
{
return
$this->validateTitle() &&
$this->validateDescription() &&
$this->validateLevel() &&
$this->validateCategory() &&
$this->validateDesired() &&
$this->validateSlides() &&
$this->validateOther() &&
$this->validateSponsor();
$this->validateTitle() && $this->validateDescription() && $this->validateLevel() && $this->validateCategory() && $this->validateDesired() && $this->validateSlides() && $this->validateOther() && $this->validateSponsor();
}

/**
Expand Down
24 changes: 12 additions & 12 deletions classes/Http/View/TalkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ public function getTalkCategories()

if ($categories === null) {
$categories = [
'api' => 'APIs (REST, SOAP, etc.)',
'continuousdelivery'=> 'Continuous Delivery',
'database' => 'Database',
'development' => 'Development',
'devops' => 'Devops',
'framework' => 'Framework',
'ibmi' => 'IBMi',
'javascript' => 'JavaScript',
'security' => 'Security',
'testing' => 'Testing',
'uiux' => 'UI/UX',
'other' => 'Other',
'api' => 'APIs (REST, SOAP, etc.)',
'continuousdelivery' => 'Continuous Delivery',
'database' => 'Database',
'development' => 'Development',
'devops' => 'Devops',
'framework' => 'Framework',
'ibmi' => 'IBMi',
'javascript' => 'JavaScript',
'security' => 'Security',
'testing' => 'Testing',
'uiux' => 'UI/UX',
'other' => 'Other',
];
}

Expand Down
2 changes: 1 addition & 1 deletion classes/Provider/TalkHelperProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TalkHelperProvider implements ServiceProviderInterface
{
public function register(Container $app)
{
$app[TalkHelper::class] = function ($app) {
$app[TalkHelper::class] = function ($app) {
return new TalkHelper(
$app->config('talk.categories'),
$app->config('talk.levels'),
Expand Down
16 changes: 8 additions & 8 deletions migrations/20140902174929_remove_speaker_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function change()
$rows = $this->fetchAll('SELECT * FROM speakers');

foreach ($rows as $row) {
$info = \filter_var($row['info'], FILTER_SANITIZE_MAGIC_QUOTES);
$bio = \filter_var($row['bio'], FILTER_SANITIZE_MAGIC_QUOTES);
$photoPath = \filter_var($row['photo_path'], FILTER_SANITIZE_MAGIC_QUOTES);
$sql = "UPDATE users SET info = '{$info}', bio = '{$bio}', photo_path = '{$photoPath}' WHERE id = {$row['user_id']}";
$info = \filter_var($row['info'], FILTER_SANITIZE_MAGIC_QUOTES);
$bio = \filter_var($row['bio'], FILTER_SANITIZE_MAGIC_QUOTES);
$photoPath = \filter_var($row['photo_path'], FILTER_SANITIZE_MAGIC_QUOTES);
$sql = "UPDATE users SET info = '{$info}', bio = '{$bio}', photo_path = '{$photoPath}' WHERE id = {$row['user_id']}";
$this->execute($sql);
}

Expand Down Expand Up @@ -63,10 +63,10 @@ public function down()
$rows = $this->fetchAll('SELECT id, info, bio, photo_path FROM users');

foreach ($rows as $row) {
$info = \filter_var($row['info'], FILTER_SANITIZE_MAGIC_QUOTES);
$bio = \filter_var($row['bio'], FILTER_SANITIZE_MAGIC_QUOTES);
$photoPath = \filter_var($row['photo_path'], FILTER_SANITIZE_MAGIC_QUOTES);
$sql = "INSERT INTO speakers (user_id, info, bio, photo_path)
$info = \filter_var($row['info'], FILTER_SANITIZE_MAGIC_QUOTES);
$bio = \filter_var($row['bio'], FILTER_SANITIZE_MAGIC_QUOTES);
$photoPath = \filter_var($row['photo_path'], FILTER_SANITIZE_MAGIC_QUOTES);
$sql = "INSERT INTO speakers (user_id, info, bio, photo_path)
VALUES ({$row['user_id']}, '{$info}', '{$bio}', '{$photoPath}')";
$this->execute($sql);
}
Expand Down
4 changes: 2 additions & 2 deletions migrations/20171120112704_activate_user_migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function bootEloquent()
$options = $adapter->getOptions();
$this->capsule = new Capsule();
$this->capsule->addConnection([
'driver' => 'mysql',
'database' => $options['name'],
'driver' => 'mysql',
'database' => $options['name'],
]);
$this->capsule->getConnection()->setPdo($adapter->getConnection());
$this->capsule->bootEloquent();
Expand Down
4 changes: 2 additions & 2 deletions migrations/20171120123411_user_roles_migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function bootEloquent()
$options = $adapter->getOptions();
$this->capsule = new Capsule();
$this->capsule->addConnection([
'driver' => 'mysql',
'database' => $options['name'],
'driver' => 'mysql',
'database' => $options['name'],
]);
$this->capsule->getConnection()->setPdo($adapter->getConnection());
$this->capsule->bootEloquent();
Expand Down
Loading

0 comments on commit 93844aa

Please sign in to comment.