From 85eedf22e1a6ae58fb79b6fc0119d22035163386 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 11 Jul 2017 16:46:18 +0200 Subject: [PATCH] coding style: fixes in code --- examples/custom-control.php | 7 +++---- examples/custom-validator.php | 2 +- examples/localization.php | 2 +- src/Bridges/FormsLatte/FormMacros.php | 2 +- src/Forms/Controls/BaseControl.php | 6 +++--- src/Forms/Form.php | 10 +++++----- src/Forms/Rendering/DefaultFormRenderer.php | 1 - src/Forms/Rules.php | 2 +- tests/Forms.Latte/FormMacros.forms.phpt | 4 ++-- tests/Forms/Controls.Button.render.phpt | 2 +- tests/Forms/Controls.Checkbox.render.phpt | 2 +- tests/Forms/Controls.CheckboxList.render.phpt | 2 +- tests/Forms/Controls.HiddenField.render.phpt | 2 +- tests/Forms/Controls.ImageButton.render.phpt | 2 +- tests/Forms/Controls.MultiSelectBox.render.phpt | 2 +- tests/Forms/Controls.RadioList.render.phpt | 2 +- tests/Forms/Controls.SelectBox.render.phpt | 2 +- tests/Forms/Controls.TextArea.render.phpt | 2 +- tests/Forms/Controls.TextInput.render.phpt | 2 +- tests/Forms/Controls.UploadControl.render.phpt | 2 +- tests/Forms/Controls.translate().phpt | 2 +- tests/Forms/Forms.renderer.1.phpt | 2 +- tests/Forms/Forms.renderer.2.phpt | 2 +- tests/Forms/Forms.renderer.translate.phpt | 2 +- tests/Forms/Helpers.exportRules.phpt | 2 +- tests/bootstrap.php | 2 +- 26 files changed, 34 insertions(+), 36 deletions(-) diff --git a/examples/custom-control.php b/examples/custom-control.php index ef968e9d7..193f40b35 100644 --- a/examples/custom-control.php +++ b/examples/custom-control.php @@ -17,10 +17,9 @@ class DateInput extends Nette\Forms\Controls\BaseControl { /** @var string */ - private - $day = '', - $month = '', - $year = ''; + private $day = ''; + private $month = ''; + private $year = ''; public function __construct($label = null) diff --git a/examples/custom-validator.php b/examples/custom-validator.php index 7be5de757..94f057a95 100644 --- a/examples/custom-validator.php +++ b/examples/custom-validator.php @@ -19,7 +19,7 @@ // Define custom validator class MyValidators { - static function divisibilityValidator($item, $arg) + public static function divisibilityValidator($item, $arg) { return $item->value % $arg === 0; } diff --git a/examples/localization.php b/examples/localization.php index d4da0beb3..a10e9282d 100644 --- a/examples/localization.php +++ b/examples/localization.php @@ -22,7 +22,7 @@ class MyTranslator implements Nette\Localization\ITranslator private $table; - function __construct(array $table) + public function __construct(array $table) { $this->table = $table; } diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php index 077a98327..789b7bc61 100644 --- a/src/Bridges/FormsLatte/FormMacros.php +++ b/src/Bridges/FormsLatte/FormMacros.php @@ -205,7 +205,7 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer) $node->innerContent .= 'global->formsStack), false); ?>'; } elseif ($tagName === 'label') { if ($node->htmlNode->empty) { - $node->innerContent = "getLabelPart()->getHtml() ?>"; + $node->innerContent = 'getLabelPart()->getHtml() ?>'; } } elseif ($tagName === 'button') { if ($node->htmlNode->empty) { diff --git a/src/Forms/Controls/BaseControl.php b/src/Forms/Controls/BaseControl.php index fc93b6232..145db0a46 100644 --- a/src/Forms/Controls/BaseControl.php +++ b/src/Forms/Controls/BaseControl.php @@ -50,12 +50,12 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo /** @var Html label element template */ protected $label; - /** @var array */ - private $errors = []; - /** @var bool */ protected $disabled = false; + /** @var array */ + private $errors = []; + /** @var bool|null */ private $omitted; diff --git a/src/Forms/Form.php b/src/Forms/Form.php index eb185edb9..c75aee89b 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -93,6 +93,9 @@ class Form extends Container implements Nette\Utils\IHtmlString /** @var callable[] function (Form $sender); Occurs before the form is rendered */ public $onRender; + /** @var Nette\Http\IRequest used only by standalone form */ + public $httpRequest; + /** @var mixed or null meaning: not detected yet */ private $submittedBy; @@ -114,9 +117,6 @@ class Form extends Container implements Nette\Utils\IHtmlString /** @var array */ private $errors = []; - /** @var Nette\Http\IRequest used only by standalone form */ - public $httpRequest; - /** @var bool */ private $beforeRenderCalled; @@ -667,14 +667,14 @@ public function __toString() $this->fireRenderEvents(); return $this->getRenderer()->render($this); - } catch (\Throwable $e) { } catch (\Exception $e) { + } catch (\Throwable $e) { } if (isset($e)) { if (func_num_args()) { throw $e; } - trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR); + trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR); } } diff --git a/src/Forms/Rendering/DefaultFormRenderer.php b/src/Forms/Rendering/DefaultFormRenderer.php index badff3c9a..e6f68aa99 100644 --- a/src/Forms/Rendering/DefaultFormRenderer.php +++ b/src/Forms/Rendering/DefaultFormRenderer.php @@ -54,7 +54,6 @@ class DefaultFormRenderer implements Nette\Forms\IFormRenderer * \--- * \--- * \-- - * * @var array of HTML tags */ public $wrappers = [ 'form' => [ diff --git a/src/Forms/Rules.php b/src/Forms/Rules.php index ca6fbcf6a..e8cf2d6af 100644 --- a/src/Forms/Rules.php +++ b/src/Forms/Rules.php @@ -344,4 +344,4 @@ private static function getCallback(Rule $rule) } } -Rules::$defaultMessages = & Validator::$messages; +Rules::$defaultMessages = &Validator::$messages; diff --git a/tests/Forms.Latte/FormMacros.forms.phpt b/tests/Forms.Latte/FormMacros.forms.phpt index 3697bd87f..a7184d4df 100644 --- a/tests/Forms.Latte/FormMacros.forms.phpt +++ b/tests/Forms.Latte/FormMacros.forms.phpt @@ -14,13 +14,13 @@ require __DIR__ . '/../bootstrap.php'; class MyControl extends Nette\Forms\Controls\BaseControl { - function getLabel($c = null) + public function getLabel($c = null) { return ''; } - function getControl() + public function getControl() { return ''; } diff --git a/tests/Forms/Controls.Button.render.phpt b/tests/Forms/Controls.Button.render.phpt index d02cf0ac6..edc25a740 100644 --- a/tests/Forms/Controls.Button.render.phpt +++ b/tests/Forms/Controls.Button.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.Checkbox.render.phpt b/tests/Forms/Controls.Checkbox.render.phpt index 2bc746cdc..eed4779d8 100644 --- a/tests/Forms/Controls.Checkbox.render.phpt +++ b/tests/Forms/Controls.Checkbox.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.CheckboxList.render.phpt b/tests/Forms/Controls.CheckboxList.render.phpt index fbf4c5e19..399b828f0 100644 --- a/tests/Forms/Controls.CheckboxList.render.phpt +++ b/tests/Forms/Controls.CheckboxList.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.HiddenField.render.phpt b/tests/Forms/Controls.HiddenField.render.phpt index e0cb362c0..e97c126e4 100644 --- a/tests/Forms/Controls.HiddenField.render.phpt +++ b/tests/Forms/Controls.HiddenField.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.ImageButton.render.phpt b/tests/Forms/Controls.ImageButton.render.phpt index 7451fe249..40e9c58cd 100644 --- a/tests/Forms/Controls.ImageButton.render.phpt +++ b/tests/Forms/Controls.ImageButton.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.MultiSelectBox.render.phpt b/tests/Forms/Controls.MultiSelectBox.render.phpt index d60ce3631..85093483f 100644 --- a/tests/Forms/Controls.MultiSelectBox.render.phpt +++ b/tests/Forms/Controls.MultiSelectBox.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.RadioList.render.phpt b/tests/Forms/Controls.RadioList.render.phpt index 352ac30a4..4370deab5 100644 --- a/tests/Forms/Controls.RadioList.render.phpt +++ b/tests/Forms/Controls.RadioList.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.SelectBox.render.phpt b/tests/Forms/Controls.SelectBox.render.phpt index 4c784ddde..7ee472e24 100644 --- a/tests/Forms/Controls.SelectBox.render.phpt +++ b/tests/Forms/Controls.SelectBox.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.TextArea.render.phpt b/tests/Forms/Controls.TextArea.render.phpt index e6b38cb3a..227807569 100644 --- a/tests/Forms/Controls.TextArea.render.phpt +++ b/tests/Forms/Controls.TextArea.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.TextInput.render.phpt b/tests/Forms/Controls.TextInput.render.phpt index 039c2c28e..8b05c269b 100644 --- a/tests/Forms/Controls.TextInput.render.phpt +++ b/tests/Forms/Controls.TextInput.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.UploadControl.render.phpt b/tests/Forms/Controls.UploadControl.render.phpt index d7f34b312..8cedb309f 100644 --- a/tests/Forms/Controls.UploadControl.render.phpt +++ b/tests/Forms/Controls.UploadControl.render.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements Nette\Localization\ITranslator { - function translate($s, $plural = null) + public function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.translate().phpt b/tests/Forms/Controls.translate().phpt index 60cb7a878..871095ef6 100644 --- a/tests/Forms/Controls.translate().phpt +++ b/tests/Forms/Controls.translate().phpt @@ -13,7 +13,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements \Nette\Localization\ITranslator { - function translate($message, $count = null) + public function translate($message, $count = null) { return is_object($message) ? get_class($message) : $message; } diff --git a/tests/Forms/Forms.renderer.1.phpt b/tests/Forms/Forms.renderer.1.phpt index 7827c8518..48b7d7a11 100644 --- a/tests/Forms/Forms.renderer.1.phpt +++ b/tests/Forms/Forms.renderer.1.phpt @@ -13,7 +13,7 @@ require __DIR__ . '/../bootstrap.php'; $_SERVER['REQUEST_METHOD'] = 'POST'; -$_POST = ['name' => 'John Doe ','age' => '','email' => ' @ ','send' => 'on','street' => '','city' => '','country' => 'HU','password' => 'xxx','password2' => '','note' => '','submit1' => 'Send','userid' => '231']; +$_POST = ['name' => 'John Doe ', 'age' => '', 'email' => ' @ ', 'send' => 'on', 'street' => '', 'city' => '', 'country' => 'HU', 'password' => 'xxx', 'password2' => '', 'note' => '', 'submit1' => 'Send', 'userid' => '231']; $countries = [ diff --git a/tests/Forms/Forms.renderer.2.phpt b/tests/Forms/Forms.renderer.2.phpt index 2f69cc7ef..d8e09e669 100644 --- a/tests/Forms/Forms.renderer.2.phpt +++ b/tests/Forms/Forms.renderer.2.phpt @@ -13,7 +13,7 @@ require __DIR__ . '/../bootstrap.php'; $_SERVER['REQUEST_METHOD'] = 'POST'; -$_POST = ['name' => 'John Doe ','age' => '9.9','email' => '@','street' => '','city' => 'Troubsko','country' => '0','password' => 'xx','password2' => 'xx','note' => '','submit1' => 'Send','userid' => '231']; +$_POST = ['name' => 'John Doe ', 'age' => '9.9', 'email' => '@', 'street' => '', 'city' => 'Troubsko', 'country' => '0', 'password' => 'xx', 'password2' => 'xx', 'note' => '', 'submit1' => 'Send', 'userid' => '231']; $countries = [ diff --git a/tests/Forms/Forms.renderer.translate.phpt b/tests/Forms/Forms.renderer.translate.phpt index a26f323b5..8afce201c 100644 --- a/tests/Forms/Forms.renderer.translate.phpt +++ b/tests/Forms/Forms.renderer.translate.phpt @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements ITranslator { - function translate($message, $count = null) + public function translate($message, $count = null) { return strtoupper($message); } diff --git a/tests/Forms/Helpers.exportRules.phpt b/tests/Forms/Helpers.exportRules.phpt index f89bfa501..90fad5880 100644 --- a/tests/Forms/Helpers.exportRules.phpt +++ b/tests/Forms/Helpers.exportRules.phpt @@ -31,7 +31,7 @@ test(function () { $input = $form->addText('text'); $input->addRule(Form::EMAIL); Assert::same([ - ['op' => ':email', 'msg' => 'Please enter a valid email address.'] + ['op' => ':email', 'msg' => 'Please enter a valid email address.'], ], Helpers::exportRules($input->getRules())); }); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e5b866014..030087cbb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -17,7 +17,7 @@ function before(\Closure $function = null) { static $val; if (!func_num_args()) { - return ($val ? $val() : null); + return $val ? $val() : null; } $val = $function; }