Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
refactor: Enabled static analysis (refs #147)
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Apr 5, 2018
1 parent 828b481 commit 9d6c41d
Show file tree
Hide file tree
Showing 47 changed files with 636 additions and 741 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.0
- 7.1
- 7.2

Expand Down
1 change: 1 addition & 0 deletions app/components/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ abstract class BaseControl extends Control

const TEMPLATE_DIR = __DIR__ . '/../templates/components';
const TEMPLATE_EXT = 'latte';
const TEMPLATE_NAME = null;

/**
* @var integer
Expand Down
10 changes: 4 additions & 6 deletions app/components/Forms/AnnotationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class AnnotationForm extends BaseForm
const MESSAGE_MAX_LENGTH = '%label nesmí mít více jak %d znaků!';

/**
* @var Closure
* @var callable[]
*/
public $onAnnotationSave;
public $onAnnotationSave = [];

/**
* @var AnnotationService
Expand All @@ -29,9 +29,6 @@ class AnnotationForm extends BaseForm
*/
protected $meetingModel;

/**
* @param ProvinceModel $model
*/
public function __construct(
AnnotationService $annotation,
MeetingModel $meeting
Expand Down Expand Up @@ -108,7 +105,8 @@ public function processForm(Form $form)
{
$annotation = $form->getValues();

$this->onAnnotationSave($this, $annotation);
//$this->onAnnotationSave($this, $annotation);
call_user_func([$this, 'onAnnotationSave', $annotation]);
}

/**
Expand Down
23 changes: 9 additions & 14 deletions app/components/Forms/BlockForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class BlockForm extends BaseForm
const MESSAGE_MAX_LENGTH = '%label nesmí mít více jak %d znaků!';

/**
* @var Closure
* @var callable[]
*/
public $onBlockSave;
public $onBlockSave = [];

/**
* @var Closure
* @var callable[]
*/
public $onBlockReset;
public $onBlockReset = [];

/**
* @var BlockRepository
Expand Down Expand Up @@ -72,10 +72,6 @@ class BlockForm extends BaseForm
55 => "55",
];

/**
* @param BlockRepository $blockRepository
* @param CategoryRepository $categoryRepository
*/
public function __construct(
BlockRepository $blockRepository,
CategoryRepository $categoryRepository
Expand All @@ -84,10 +80,7 @@ public function __construct(
$this->setCategoryRepository($categoryRepository);
}

/**
* @return void
*/
public function render()
public function render(): void
{
$template = $this->getTemplate();
$template->setFile($this->buildTemplatePath());
Expand Down Expand Up @@ -169,7 +162,8 @@ public function processForm(SubmitButton $button)
{
$block = $button->getForm()->getValues();

$this->onBlockSave($this, $block);
//$this->onBlockSave($this, $block);
call_user_func([$this, 'onBlockSave', $block]);
}

/**
Expand All @@ -180,7 +174,8 @@ public function processReset(SubmitButton $button)
{
$block = $button->getForm()->getValues();

$this->onBlockReset($this, $block);
//$this->onBlockReset($this, $block);
call_user_func([$this, 'onBlockReset', $block]);
}

/**
Expand Down
14 changes: 5 additions & 9 deletions app/components/Forms/LoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class LoginForm extends BaseForm
{

const TEMPLATE_NAME = 'LoginForm';
const MESSAGE_REQUIRED = '';
const MESSAGE_MAX_LENGTH = '';

/**
* @var Closure
* @var callable
*/
public $onAnnotationSave;

Expand All @@ -26,9 +28,6 @@ class LoginForm extends BaseForm
*/
protected $meetingModel;

/**
* @param ProvinceModel $model
*/
public function __construct(
AnnotationService $annotation,
MeetingModel $meeting
Expand All @@ -37,10 +36,7 @@ public function __construct(
$this->setMeetingModel($meeting);
}

/**
* @return void
*/
public function render()
public function render(): void
{
$template = $this->getTemplate();
$template->setFile($this->buildTemplatePath());
Expand Down Expand Up @@ -105,7 +101,7 @@ public function processForm(Form $form)
{
$annotation = $form->getValues();

$this->onAnnotationSave($this, $annotation);
//$this->onAnnotationSave($this, $annotation);
}

/**
Expand Down
23 changes: 8 additions & 15 deletions app/components/Forms/ProgramForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Components\Forms;

use App\Models\MeetingModel;
use App\Repositories\BlockRepository;
use App\Repositories\CategoryRepository;
use Nette\Application\UI\Form;
Expand All @@ -18,14 +17,14 @@ class ProgramForm extends BaseForm
const MESSAGE_MAX_LENGTH = '%label nesmí mít více jak %d znaků!';

/**
* @var Closure
* @var callable[]
*/
public $onProgramSave;
public $onProgramSave = [];

/**
* @var Closure
* @var callable[]
*/
public $onProgramReset;
public $onProgramReset = [];

/**
* @var BlockRepository
Expand All @@ -37,10 +36,6 @@ class ProgramForm extends BaseForm
*/
protected $categoryRepository;

/**
* @param BlockRepository $blockRepository
* @param CategoryRepository $categoryRepository
*/
public function __construct(
BlockRepository $blockRepository,
CategoryRepository $categoryRepository
Expand All @@ -60,10 +55,6 @@ public function render()
$template->render();
}

/**
* @param array $defaults
* @return AnnotationForm
*/
public function setDefaults(ActiveRow $defaults): ProgramForm
{
$this['programForm']->setDefaults($defaults);
Expand Down Expand Up @@ -128,7 +119,8 @@ public function processForm(SubmitButton $button)
{
$program = $button->getForm()->getValues();

$this->onProgramSave($this, $program);
//$this->onProgramSave($this, $program);
call_user_func([$this, 'onProgramSave', $program]);
}

/**
Expand All @@ -139,7 +131,8 @@ public function processReset(SubmitButton $button)
{
$program = $button->getForm()->getValues();

$this->onProgramReset($this, $program);
//$this->onProgramReset($this, $program);
call_user_func([$this, 'onProgramReset', $program]);
}

/**
Expand Down
35 changes: 9 additions & 26 deletions app/components/Forms/RegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
use App\Models\BlockModel;
use App\Models\MeetingModel;
use Nette\Application\UI\Form;
use App\Services\SkautIS\UserService;
use App\Services\Skautis\UserService;

class RegistrationForm extends VisitorForm
{

const TEMPLATE_NAME = 'RegistrationForm';

/**
* @var Closure
* @var callable[]
*/
public $onRegistrationSave;
public $onRegistrationSave = [];

/**
* @var UserService
Expand All @@ -38,20 +38,13 @@ public function __construct(
$this->setUserService($user);
}

/**
* @param array $defaults
* @return self
*/
public function setDefaults($defaults): BaseForm
public function setDefaults(array $defaults): BaseForm
{
$this['registrationForm']->setDefaults($defaults);

return $this;
}

/**
* @return Form
*/
public function createComponentRegistrationForm(): Form
{
$provinces = $this->getProvinceModel()->all();
Expand Down Expand Up @@ -152,31 +145,21 @@ public function createComponentRegistrationForm(): Form
return $form;
}

/**
* @param Form $form
* @return void
*/
public function processForm(Form $form)
public function processForm(Form $form): void
{
$registration = $form->getValues();
$registration['meeting'] = $this->getMeetingId();

$this->onRegistrationSave($this, $registration);
//$this->onRegistrationSave($this, $registration);
call_user_func([$this, 'onRegistrationSave', $registration]);
}

/**
* @return UserService
*/
protected function getUserService()
protected function getUserService(): UserService
{
return $this->userService;
}

/**
* @param UserService $service
* @return $this
*/
protected function setUserService(UserService $service)
protected function setUserService(UserService $service): self
{
$this->userService = $service;

Expand Down
33 changes: 16 additions & 17 deletions app/components/Forms/VisitorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
use App\Models\MealModel;
use App\Models\MeetingModel;
use Nette\Application\UI\Form;
use App\Services\SkautIS\UserService;
use App\Services\Skautis\UserService;
use Nette\Forms\Controls\SubmitButton;
use Nette\Utils\ArrayHash;

class VisitorForm extends BaseForm
{
Expand All @@ -21,14 +20,14 @@ class VisitorForm extends BaseForm
const MESSAGE_MAX_LENGTH = '%label nesmí mít více jak %d znaků!';

/**
* @var Closure
* @var callable[]
*/
public $onVisitorSave;
public $onVisitorSave = [];

/**
* @var Closure
* @var callable[]
*/
public $onVisitorReset;
public $onVisitorReset = [];

/**
* @var ProvinceModel
Expand Down Expand Up @@ -60,6 +59,11 @@ class VisitorForm extends BaseForm
*/
protected $programFields = [];

/**
* @var UserService
*/
private $userService;

/**
* VisitorForm constructor.
* @param ProvinceModel $province
Expand Down Expand Up @@ -94,11 +98,7 @@ public function render()
$template->render();
}

/**
* @param array|ArrayHash $defaults
* @return self
*/
public function setDefaults($defaults): BaseForm
public function setDefaults(array $defaults): BaseForm
{
$this['visitorForm']->setDefaults($defaults);

Expand Down Expand Up @@ -225,7 +225,8 @@ public function processSave(SubmitButton $button)
{
$visitor = $button->getForm()->getValues();

$this->onVisitorSave($this, $visitor);
//$this->onVisitorSave($this, $visitor);
call_user_func([$this, 'onVisitorSave', $visitor]);
}

/**
Expand All @@ -236,7 +237,8 @@ public function processReset(SubmitButton $button)
{
$visitor = $button->getForm()->getValues();

$this->onVisitorReset($this, $visitor);
//$this->onVisitorReset($this, $visitor);
call_user_func([$this, 'onVisitorSave', $visitor]);
}

/**
Expand Down Expand Up @@ -434,10 +436,7 @@ protected function setMealFields(): self
return $this;
}

/**
* @return Row
*/
protected function fetchProgramBlocks()
protected function fetchProgramBlocks(): array
{
return $this->getBlockModel()->getProgramBlocks($this->getMeetingId());
}
Expand Down
2 changes: 1 addition & 1 deletion app/entities/UserEntity.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
`<?php
<?php

namespace App\Entities;

Expand Down
Loading

0 comments on commit 9d6c41d

Please sign in to comment.