Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
- Upgrading to PHP7.1
Browse files Browse the repository at this point in the history
- Code cleaning
  • Loading branch information
akadlec committed Jan 14, 2018
1 parent d5481ce commit 523f57c
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 59 deletions.
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@
},

"require": {
"php" : ">=7.0.0",
"php" : ">=7.1.0",

"nette/application" : "~2.3",
"nette/di" : "~2.3",
"nette/forms" : "~2.3",
"nette/http" : "~2.3",
"nette/utils" : "~2.3",
"nette/application" : "~2.4",
"nette/di" : "~2.4",
"nette/forms" : "~2.4",
"nette/http" : "~2.4",
"nette/utils" : "~2.4",

"latte/latte" : "~2.3",

"pds/skeleton" : "@dev"
"latte/latte" : "~2.3"
},

"require-dev": {
"nette/bootstrap" : "~2.3",
"nette/mail" : "~2.3",
"nette/robot-loader" : "~2.3",
"nette/safe-stream" : "~2.3",
"nette/bootstrap" : "~2.4",
"nette/mail" : "~2.4",
"nette/robot-loader" : "~2.4",
"nette/safe-stream" : "~2.4",
"nette/tester" : "@dev",

"tracy/tracy" : "@dev"
"tracy/tracy" : "@dev",

"pds/skeleton" : "~1.0"
},

"suggest": {
Expand Down
10 changes: 6 additions & 4 deletions src/IPub/ConfirmationDialog/Components/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ abstract class BaseControl extends Application\UI\Control

/**
* @param Localization\ITranslator $translator
*
* @return void
*/
public function injectTranslator(Localization\ITranslator $translator = NULL)
public function injectTranslator(Localization\ITranslator $translator = NULL) : void
{
$this->translator = $translator;
}
Expand All @@ -66,15 +68,15 @@ public function injectTranslator(Localization\ITranslator $translator = NULL)
*
* @return void
*/
public function setTranslator(Localization\ITranslator $translator)
public function setTranslator(Localization\ITranslator $translator) : void
{
$this->translator = $translator;
}

/**
* @return Localization\ITranslator|NULL
*/
public function getTranslator()
public function getTranslator() : ?Localization\ITranslator
{
if ($this->translator instanceof Localization\ITranslator) {
return $this->translator;
Expand Down Expand Up @@ -117,7 +119,7 @@ public function render()
* @throws Exceptions\FileNotFoundException
* @throws Exceptions\InvalidArgumentException
*/
protected function setTemplateFilePath(string $templateFile, string $type)
protected function setTemplateFilePath(string $templateFile, string $type) : void
{
if (!in_array($type, [self::TEMPLATE_CONFIRMER, self::TEMPLATE_LAYOUT])) {
throw new Exceptions\InvalidArgumentException('Wrong template type');
Expand Down
12 changes: 6 additions & 6 deletions src/IPub/ConfirmationDialog/Components/Confirmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
*
* @return void
*/
public function showConfirm(array $params = [])
public function showConfirm(array $params = []) : void
{
// Generate protection token
$token = $this->generateToken();
Expand All @@ -83,7 +83,7 @@ public function showConfirm(array $params = [])
'params' => $params,
]);

if ($this->getQuestion() !== FALSE) {
if ($this->getQuestion() !== NULL) {
// Invalidate confirmer snippets
$this->redrawControl();
// Invalidate dialog snippets
Expand All @@ -101,7 +101,7 @@ public function showConfirm(array $params = [])
* @throws Exceptions\HandlerNotCallableException
* @throws Exceptions\InvalidStateException
*/
public function confirmClicked(Forms\Controls\SubmitButton $button)
public function confirmClicked(Forms\Controls\SubmitButton $button) : void
{
// Get submitted values from form
$values = $button->getForm(TRUE)->getValues();
Expand Down Expand Up @@ -144,7 +144,7 @@ public function confirmClicked(Forms\Controls\SubmitButton $button)
*
* @param Forms\Controls\SubmitButton $button
*/
public function cancelClicked(Forms\Controls\SubmitButton $button)
public function cancelClicked(Forms\Controls\SubmitButton $button) : void
{
// Get submitted values from form
$values = $button->getForm(TRUE)->getValues();
Expand Down Expand Up @@ -222,7 +222,7 @@ public function render()
*
* @return void
*/
public function setTemplateFile(string $layoutFile)
public function setTemplateFile(string $layoutFile) : void
{
$this->setTemplateFilePath($layoutFile, self::TEMPLATE_CONFIRMER);
}
Expand Down Expand Up @@ -271,7 +271,7 @@ private function generateToken() : string
/**
* @return void
*/
private function refreshPage()
private function refreshPage() : void
{
// Check if request is done via ajax...
if ($this->getPresenter() instanceof Application\UI\Presenter && !$this->getPresenter()->isAjax()) {
Expand Down
36 changes: 16 additions & 20 deletions src/IPub/ConfirmationDialog/Components/ConfirmerAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct(Storage\IStorage $storage)
*
* @throws Exceptions\InvalidArgumentException
*/
public function setHeading($heading)
public function setHeading($heading) : void
{
// Check variable type
if ($this->checkCallableOrString($heading)) {
Expand All @@ -118,7 +118,7 @@ public function setHeading($heading)
*
* @throws Exceptions\InvalidStateException
*/
public function getHeading()
public function getHeading() : ?string
{
return $this->getAttribute('heading');
}
Expand All @@ -132,7 +132,7 @@ public function getHeading()
*
* @throws Exceptions\InvalidArgumentException
*/
public function setQuestion($question)
public function setQuestion($question) : void
{
// Check variable type
if ($this->checkCallableOrString($question)) {
Expand All @@ -142,27 +142,27 @@ public function setQuestion($question)
}

/**
* @return string|bool
* @return string|NULL
*
* @throws Exceptions\InvalidStateException
*/
public function getQuestion()
public function getQuestion() : ?string
{
$question = FALSE;
$question = NULL;

// Check if attribute is callable
if (is_callable($this->question)) {
$question = $this->callCallableAttribute($this->question);

if (!is_bool($question)) {
if ($question !== NULL) {
$question = (string) $question;
}

} elseif (!is_bool($this->question)) {
} elseif ($this->question !== NULL) {
$question = (string) $this->question;
}

return $question;
return is_bool($question) && $question === FALSE ? NULL : $question;
}

/**
Expand All @@ -174,7 +174,7 @@ public function getQuestion()
*
* @throws Exceptions\InvalidArgumentException
*/
public function setIcon($icon)
public function setIcon($icon) : void
{
// Check variable type
if ($this->checkCallableOrString($icon)) {
Expand All @@ -188,7 +188,7 @@ public function setIcon($icon)
*
* @throws Exceptions\InvalidStateException
*/
public function getIcon()
public function getIcon() : ?string
{
return $this->getAttribute('icon');
}
Expand All @@ -202,12 +202,8 @@ public function getIcon()
*
* @throws Exceptions\InvalidArgumentException
*/
public function setHandler($handler)
public function setHandler(callable $handler) : void
{
if (!is_callable($handler)) {
throw new Exceptions\InvalidArgumentException('$handler must be callable.');
}

// Update confirmation handler
$this->handler = $handler;
}
Expand Down Expand Up @@ -252,23 +248,23 @@ public function callHandler(Nette\ComponentModel\IContainer $obj, array $params)
/**
* @return void
*/
public function enableAjax()
public function enableAjax() : void
{
$this->useAjax = TRUE;
}

/**
* @return void
*/
public function disableAjax()
public function disableAjax() : void
{
$this->useAjax = FALSE;
}

/**
* @return Application\UI\Form
*/
protected function createComponentForm()
protected function createComponentForm() : Application\UI\Form
{
// Create confirmation form
$form = new Application\UI\Form();
Expand Down Expand Up @@ -332,7 +328,7 @@ private function checkCallableOrString($var) : bool
*
* @throws Exceptions\InvalidStateException
*/
private function callCallableAttribute($attribute) : string
private function callCallableAttribute(callable $attribute) : string
{
if ($this['form']['secureToken']->value === NULL) {
throw new Exceptions\InvalidStateException('Token is not set!');
Expand Down
10 changes: 5 additions & 5 deletions src/IPub/ConfirmationDialog/Components/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static function formatSignalMethod($signal) : string
*
* @throws Exceptions\InvalidArgumentException
*/
public function addConfirmer(string $name, $handler, $question, $heading)
public function addConfirmer(string $name, $handler, $question, $heading) : void
{
// Confirmer name could be only A-z
if (!preg_match('/[A-Za-z_]+/', $name)) {
Expand Down Expand Up @@ -226,7 +226,7 @@ protected function createComponentConfirmer() : Application\UI\Multiplier
* @throws Exceptions\InvalidArgumentException
* @throws Exceptions\InvalidStateException
*/
public function showConfirm(string $name, array $params = [])
public function showConfirm(string $name, array $params = []) : void
{
if (!is_string($name)) {
throw new Exceptions\InvalidArgumentException('$name must be string.');
Expand All @@ -248,7 +248,7 @@ public function showConfirm(string $name, array $params = [])
* @throws Exceptions\InvalidArgumentException
* @throws Exceptions\InvalidStateException
*/
public function handleShowConfirmer()
public function handleShowConfirmer() : void
{
if (!$this->getPresenter() instanceof Application\UI\Presenter) {
throw new Exceptions\InvalidArgumentException('Confirmer is not attached to presenter.');
Expand All @@ -271,15 +271,15 @@ public function handleShowConfirmer()
/**
* @return void
*/
public function enableAjax()
public function enableAjax() : void
{
$this->useAjax = TRUE;
}

/**
* @return void
*/
public function disableAjax()
public function disableAjax() : void
{
$this->useAjax = FALSE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function loadConfiguration()
*/
public static function register(Nette\Configurator $config, $extensionName = 'confirmationDialog')
{
$config->onCompile[] = function (Nette\Configurator $config, DI\Compiler $compiler) use ($extensionName) {
$config->onCompile[] = function (Nette\Configurator $config, DI\Compiler $compiler) use ($extensionName) : void {
$compiler->addExtension($extensionName, new ConfirmationDialogExtension());
};
}
Expand All @@ -95,7 +95,7 @@ public static function register(Nette\Configurator $config, $extensionName = 'co
*
* @return string[]
*/
public function getTranslationResources()
public function getTranslationResources() : array
{
return [
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Translations'
Expand Down
8 changes: 4 additions & 4 deletions src/IPub/ConfirmationDialog/Storage/IStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface IStorage
*
* @return void
*/
function set(string $key, $value);
public function set(string $key, $value) : void;

/**
* Get the data for $key
Expand All @@ -48,7 +48,7 @@ function set(string $key, $value);
*
* @return mixed
*/
function get(string $key, $default = FALSE);
public function get(string $key, $default = FALSE);

/**
* Clear the data with $key from the persistent storage
Expand All @@ -57,12 +57,12 @@ function get(string $key, $default = FALSE);
*
* @return void
*/
function clear(string $key);
public function clear(string $key) : void;

/**
* Clear all data from the persistent storage
*
* @return void
*/
function clearAll();
public function clearAll() : void;
}
6 changes: 3 additions & 3 deletions src/IPub/ConfirmationDialog/Storage/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(Http\Session $session)
/**
* {@inheritdoc}
*/
public function set(string $key, $value)
public function set(string $key, $value) : void
{
$this->session->$key = $value;
}
Expand All @@ -61,15 +61,15 @@ public function get(string $key, $default = FALSE)
/**
* {@inheritdoc}
*/
public function clear(string $key)
public function clear(string $key) : void
{
unset($this->session->$key);
}

/**
* {@inheritdoc}
*/
public function clearAll()
public function clearAll() : void
{
$this->session->remove();
}
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/ConfirmationDialog/TConfirmationDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait TConfirmationDialog
*
* @return void
*/
public function injectConfirmationDialog(Components\IControl $confirmationDialogFactory)
public function injectConfirmationDialog(Components\IControl $confirmationDialogFactory) : void
{
$this->confirmationDialogFactory = $confirmationDialogFactory;
}
Expand Down

0 comments on commit 523f57c

Please sign in to comment.