diff --git a/examples/basic-example.php b/examples/basic-example.php index d54b5ee67..cc870d835 100644 --- a/examples/basic-example.php +++ b/examples/basic-example.php @@ -48,7 +48,7 @@ // group Shipping address $form->addGroup('Shipping address') - ->setOption('embedNext', TRUE); + ->setOption('embedNext', true); $form->addCheckbox('send', 'Ship to address') ->addCondition($form::FILLED) // conditional rule: if is checkbox checked... @@ -91,7 +91,7 @@ ->addRule($form::EQUAL, 'Passwords do not match', $form['password']); $form->addUpload('avatar', 'Picture:') - ->setRequired(FALSE) + ->setRequired(false) ->addRule($form::IMAGE, 'Uploaded file is not image'); $form->addHidden('userid'); @@ -112,7 +112,7 @@ if ($form->isSuccess()) { echo '

Form was submitted and successfully validated

'; - Dumper::dump($form->getValues(), [Dumper::COLLAPSE => FALSE]); + Dumper::dump($form->getValues(), [Dumper::COLLAPSE => false]); exit; } diff --git a/examples/bootstrap2-rendering.php b/examples/bootstrap2-rendering.php index 602ecca09..c16fb05ec 100644 --- a/examples/bootstrap2-rendering.php +++ b/examples/bootstrap2-rendering.php @@ -19,7 +19,7 @@ function makeBootstrap2(Form $form) { $renderer = $form->getRenderer(); - $renderer->wrappers['controls']['container'] = NULL; + $renderer->wrappers['controls']['container'] = null; $renderer->wrappers['pair']['container'] = 'div class=control-group'; $renderer->wrappers['pair']['.error'] = 'error'; $renderer->wrappers['control']['container'] = 'div class=controls'; @@ -33,9 +33,9 @@ function makeBootstrap2(Form $form) $type = $control->getOption('type'); if ($type === 'button') { $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn'); - $usedPrimary = TRUE; + $usedPrimary = true; - } elseif (in_array($type, ['checkbox', 'radio'], TRUE)) { + } elseif (in_array($type, ['checkbox', 'radio'], true)) { $control->getSeparatorPrototype()->setName('div')->addClass($type); } } diff --git a/examples/bootstrap3-rendering.php b/examples/bootstrap3-rendering.php index b5dc871de..9e8baadb2 100644 --- a/examples/bootstrap3-rendering.php +++ b/examples/bootstrap3-rendering.php @@ -19,7 +19,7 @@ function makeBootstrap3(Form $form) { $renderer = $form->getRenderer(); - $renderer->wrappers['controls']['container'] = NULL; + $renderer->wrappers['controls']['container'] = null; $renderer->wrappers['pair']['container'] = 'div class=form-group'; $renderer->wrappers['pair']['.error'] = 'has-error'; $renderer->wrappers['control']['container'] = 'div class=col-sm-9'; @@ -33,12 +33,12 @@ function makeBootstrap3(Form $form) $type = $control->getOption('type'); if ($type === 'button') { $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default'); - $usedPrimary = TRUE; + $usedPrimary = true; - } elseif (in_array($type, ['text', 'textarea', 'select'], TRUE)) { + } elseif (in_array($type, ['text', 'textarea', 'select'], true)) { $control->getControlPrototype()->addClass('form-control'); - } elseif (in_array($type, ['checkbox', 'radio'], TRUE)) { + } elseif (in_array($type, ['checkbox', 'radio'], true)) { $control->getSeparatorPrototype()->setName('div')->addClass($type); } } diff --git a/examples/bootstrap4-rendering.php b/examples/bootstrap4-rendering.php index 3bda476a2..35791d8b5 100644 --- a/examples/bootstrap4-rendering.php +++ b/examples/bootstrap4-rendering.php @@ -19,7 +19,7 @@ function makeBootstrap4(Form $form) { $renderer = $form->getRenderer(); - $renderer->wrappers['controls']['container'] = NULL; + $renderer->wrappers['controls']['container'] = null; $renderer->wrappers['pair']['container'] = 'div class="form-group row"'; $renderer->wrappers['pair']['.error'] = 'has-danger'; $renderer->wrappers['control']['container'] = 'div class=col-sm-9'; @@ -32,15 +32,15 @@ function makeBootstrap4(Form $form) $type = $control->getOption('type'); if ($type === 'button') { $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-secondary'); - $usedPrimary = TRUE; + $usedPrimary = true; - } elseif (in_array($type, ['text', 'textarea', 'select'], TRUE)) { + } elseif (in_array($type, ['text', 'textarea', 'select'], true)) { $control->getControlPrototype()->addClass('form-control'); } elseif ($type === 'file') { $control->getControlPrototype()->addClass('form-control-file'); - } elseif (in_array($type, ['checkbox', 'radio'], TRUE)) { + } elseif (in_array($type, ['checkbox', 'radio'], true)) { if ($control instanceof Nette\Forms\Controls\Checkbox) { $control->getLabelPrototype()->addClass('form-check-label'); } else { diff --git a/examples/custom-control.php b/examples/custom-control.php index 7ced594a9..ef968e9d7 100644 --- a/examples/custom-control.php +++ b/examples/custom-control.php @@ -23,17 +23,17 @@ class DateInput extends Nette\Forms\Controls\BaseControl $year = ''; - public function __construct($label = NULL) + public function __construct($label = null) { parent::__construct($label); - $this->setRequired(FALSE) + $this->setRequired(false) ->addRule([__CLASS__, 'validateDate'], 'Date is invalid.'); } public function setValue($value) { - if ($value === NULL) { + if ($value === null) { $this->day = $this->month = $this->year = ''; } else { $date = Nette\Utils\DateTime::from($value); @@ -46,13 +46,13 @@ public function setValue($value) /** - * @return DateTimeImmutable|NULL + * @return DateTimeImmutable|null */ public function getValue() { return self::validateDate($this) ? (new DateTimeImmutable)->setDate((int) $this->year, (int) $this->month, (int) $this->day)->setTime(0, 0) - : NULL; + : null; } @@ -86,7 +86,7 @@ public function getControl() 'type' => 'number', 'min' => 1, 'max' => 31, - 'data-nette-rules' => Helpers::exportRules($this->getRules()) ?: NULL, + 'data-nette-rules' => Helpers::exportRules($this->getRules()) ?: null, ]) . Helpers::createSelectBox( diff --git a/examples/custom-rendering.php b/examples/custom-rendering.php index ba4214750..b98022406 100644 --- a/examples/custom-rendering.php +++ b/examples/custom-rendering.php @@ -21,9 +21,9 @@ // setup custom rendering $renderer = $form->getRenderer(); $renderer->wrappers['form']['container'] = Html::el('div')->id('form'); -$renderer->wrappers['group']['container'] = NULL; +$renderer->wrappers['group']['container'] = null; $renderer->wrappers['group']['label'] = 'h3'; -$renderer->wrappers['pair']['container'] = NULL; +$renderer->wrappers['pair']['container'] = null; $renderer->wrappers['controls']['container'] = 'dl'; $renderer->wrappers['control']['container'] = 'dd'; $renderer->wrappers['control']['.odd'] = 'odd'; diff --git a/examples/localization.php b/examples/localization.php index 9a6be0b97..d4da0beb3 100644 --- a/examples/localization.php +++ b/examples/localization.php @@ -31,7 +31,7 @@ function __construct(array $table) /** * Translates the given string. */ - public function translate($message, $count = NULL) + public function translate($message, $count = null) { return isset($this->table[$message]) ? $this->table[$message] : $message; } diff --git a/examples/manual-rendering.php b/examples/manual-rendering.php index bb0596aaa..8c91820c0 100644 --- a/examples/manual-rendering.php +++ b/examples/manual-rendering.php @@ -23,13 +23,13 @@ $form->addText('age') ->setRequired('Enter your age'); -$form->addRadioList('gender', NULL, [ +$form->addRadioList('gender', null, [ 'm' => 'male', 'f' => 'female', ]); $form->addText('email') - ->setRequired(FALSE) + ->setRequired(false) ->addRule($form::EMAIL, 'Incorrect email address'); $form->addSubmit('submit'); diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php index 51510bc8d..077a98327 100644 --- a/src/Bridges/FormsLatte/FormMacros.php +++ b/src/Bridges/FormsLatte/FormMacros.php @@ -32,7 +32,7 @@ public static function install(Latte\Compiler $compiler) $me = new static($compiler); $me->addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));'); $me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = $_form = end($this->global->formsStack)'); - $me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], NULL, self::AUTO_EMPTY); + $me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY); $me->addMacro('input', [$me, 'macroInput']); $me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']); $me->addMacro('inputError', [$me, 'macroInputError']); @@ -54,10 +54,10 @@ public function macroForm(MacroNode $node, PhpWriter $writer) throw new CompileException('Did you mean
?'); } $name = $node->tokenizer->fetchWord(); - if ($name === FALSE) { + if ($name === false) { throw new CompileException('Missing form name in ' . $node->getNotation()); } - $node->replaced = TRUE; + $node->replaced = true; $node->tokenizer->reset(); return $writer->write( "/* line $node->startLine */\n" @@ -77,7 +77,7 @@ public function macroFormContainer(MacroNode $node, PhpWriter $writer) throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); } $name = $node->tokenizer->fetchWord(); - if ($name === FALSE) { + if ($name === false) { throw new CompileException('Missing name in ' . $node->getNotation()); } $node->tokenizer->reset(); @@ -118,7 +118,7 @@ public function macroLabel(MacroNode $node, PhpWriter $writer) */ public function macroLabelEnd(MacroNode $node, PhpWriter $writer) { - if ($node->content != NULL) { + if ($node->content != null) { $node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>'; return $writer->write('if ($_label) echo $_label->endTag()'); } @@ -171,8 +171,8 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer) $name ); return $writer->write( - 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %0.var, FALSE)', - array_fill_keys(array_keys($node->htmlNode->attrs), NULL) + 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %0.var, false)', + array_fill_keys(array_keys($node->htmlNode->attrs), null) ); } else { $method = $tagName === 'label' ? 'getLabel' : 'getControl'; @@ -182,7 +182,7 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer) . ($node->htmlNode->attrs ? '->addAttributes(%2.var)' : '') . '->attributes()', $name, $method . 'Part(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')', - array_fill_keys(array_keys($node->htmlNode->attrs), NULL) + array_fill_keys(array_keys($node->htmlNode->attrs), null) ); } } @@ -202,7 +202,7 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer) { $tagName = strtolower($node->htmlNode->name); if ($tagName === 'form') { - $node->innerContent .= 'global->formsStack), FALSE); ?>'; + $node->innerContent .= 'global->formsStack), false); ?>'; } elseif ($tagName === 'label') { if ($node->htmlNode->empty) { $node->innerContent = "getLabelPart()->getHtml() ?>"; @@ -238,7 +238,7 @@ public function macroInputError(MacroNode $node, PhpWriter $writer) /** @deprecated */ - public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE) + public static function renderFormBegin(Form $form, array $attrs, $withTags = true) { trigger_error(__METHOD__ . '() is deprecated, use Nette\Bridges\FormsLatte\Runtime::renderFormBegin()', E_USER_DEPRECATED); echo Runtime::renderFormBegin($form, $attrs, $withTags); @@ -246,7 +246,7 @@ public static function renderFormBegin(Form $form, array $attrs, $withTags = TRU /** @deprecated */ - public static function renderFormEnd(Form $form, $withTags = TRUE) + public static function renderFormEnd(Form $form, $withTags = true) { trigger_error(__METHOD__ . '() is deprecated, use Nette\Bridges\FormsLatte\Runtime::renderFormEnd()', E_USER_DEPRECATED); echo Runtime::renderFormEnd($form, $withTags); diff --git a/src/Bridges/FormsLatte/Runtime.php b/src/Bridges/FormsLatte/Runtime.php index ff15ecefe..fe75cfaf6 100644 --- a/src/Bridges/FormsLatte/Runtime.php +++ b/src/Bridges/FormsLatte/Runtime.php @@ -24,11 +24,11 @@ class Runtime * Renders form begin. * @return string */ - public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE) + public static function renderFormBegin(Form $form, array $attrs, $withTags = true) { $form->fireRenderEvents(); foreach ($form->getControls() as $control) { - $control->setOption('rendered', FALSE); + $control->setOption('rendered', false); } $el = $form->getElementPrototype(); $el->action = (string) $el->action; @@ -45,7 +45,7 @@ public static function renderFormBegin(Form $form, array $attrs, $withTags = TRU * Renders form end. * @return string */ - public static function renderFormEnd(Form $form, $withTags = TRUE) + public static function renderFormEnd(Form $form, $withTags = true) { $s = ''; if ($form->isMethod('get')) { @@ -64,7 +64,7 @@ public static function renderFormEnd(Form $form, $withTags = TRUE) } } - if (iterator_count($form->getComponents(TRUE, Nette\Forms\Controls\TextInput::class)) < 2) { + if (iterator_count($form->getComponents(true, Nette\Forms\Controls\TextInput::class)) < 2) { $s .= "\n"; } diff --git a/src/Forms/Container.php b/src/Forms/Container.php index 29ac27b27..3446e4bb2 100644 --- a/src/Forms/Container.php +++ b/src/Forms/Container.php @@ -15,14 +15,14 @@ * * @property Nette\Utils\ArrayHash $values * @property-read \Iterator $controls - * @property-read Form|NULL $form + * @property-read Form|null $form */ class Container extends Nette\ComponentModel\Container implements \ArrayAccess { /** @var callable[] function (Container $sender); Occurs when the form is validated */ public $onValidate; - /** @var ControlGroup|NULL */ + /** @var ControlGroup|null */ protected $currentGroup; /** @var bool */ @@ -38,9 +38,9 @@ class Container extends Nette\ComponentModel\Container implements \ArrayAccess * @param bool * @return static */ - public function setDefaults($values, $erase = FALSE) + public function setDefaults($values, $erase = false) { - $form = $this->getForm(FALSE); + $form = $this->getForm(false); if (!$form || !$form->isAnchored() || !$form->isSubmitted()) { $this->setValues($values, $erase); } @@ -55,7 +55,7 @@ public function setDefaults($values, $erase = FALSE) * @return static * @internal */ - public function setValues($values, $erase = FALSE) + public function setValues($values, $erase = false) { if ($values instanceof \Traversable) { $values = iterator_to_array($values); @@ -70,7 +70,7 @@ public function setValues($values, $erase = FALSE) $control->setValue($values[$name]); } elseif ($erase) { - $control->setValue(NULL); + $control->setValue(null); } } elseif ($control instanceof self) { @@ -91,7 +91,7 @@ public function setValues($values, $erase = FALSE) * @param bool * @return Nette\Utils\ArrayHash|array */ - public function getValues($asArray = FALSE) + public function getValues($asArray = false) { $values = $asArray ? [] : new Nette\Utils\ArrayHash; foreach ($this->getComponents() as $name => $control) { @@ -117,7 +117,7 @@ public function isValid() { if (!$this->validated) { if ($this->getErrors()) { - return FALSE; + return false; } $this->validate(); } @@ -130,24 +130,24 @@ public function isValid() * @param IControl[] * @return void */ - public function validate(array $controls = NULL) + public function validate(array $controls = null) { - foreach ($controls === NULL ? $this->getComponents() : $controls as $control) { + foreach ($controls === null ? $this->getComponents() : $controls as $control) { if ($control instanceof IControl || $control instanceof self) { $control->validate(); } } - if ($this->onValidate !== NULL) { + if ($this->onValidate !== null) { if (!is_array($this->onValidate) && !$this->onValidate instanceof \Traversable) { throw new Nette\UnexpectedValueException('Property Form::$onValidate must be array or Traversable, ' . gettype($this->onValidate) . ' given.'); } foreach ($this->onValidate as $handler) { $params = Nette\Utils\Callback::toReflection($handler)->getParameters(); - $values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : NULL; + $values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : null; Nette\Utils\Callback::invoke($handler, $this, $values); } } - $this->validated = TRUE; + $this->validated = true; } @@ -171,7 +171,7 @@ public function getErrors() /** * @return static */ - public function setCurrentGroup(ControlGroup $group = NULL) + public function setCurrentGroup(ControlGroup $group = null) { $this->currentGroup = $group; return $this; @@ -180,7 +180,7 @@ public function setCurrentGroup(ControlGroup $group = NULL) /** * Returns current group. - * @return ControlGroup|NULL + * @return ControlGroup|null */ public function getCurrentGroup() { @@ -196,10 +196,10 @@ public function getCurrentGroup() * @return static * @throws Nette\InvalidStateException */ - public function addComponent(Nette\ComponentModel\IComponent $component, $name, $insertBefore = NULL) + public function addComponent(Nette\ComponentModel\IComponent $component, $name, $insertBefore = null) { parent::addComponent($component, $name, $insertBefore); - if ($this->currentGroup !== NULL) { + if ($this->currentGroup !== null) { $this->currentGroup->add($component); } return $this; @@ -212,16 +212,16 @@ public function addComponent(Nette\ComponentModel\IComponent $component, $name, */ public function getControls() { - return $this->getComponents(TRUE, IControl::class); + return $this->getComponents(true, IControl::class); } /** * Returns form. * @param bool - * @return Form|NULL + * @return Form|null */ - public function getForm($throw = TRUE) + public function getForm($throw = true) { return $this->lookup(Form::class, $throw); } @@ -238,7 +238,7 @@ public function getForm($throw = TRUE) * @param int * @return Controls\TextInput */ - public function addText($name, $label = NULL, $cols = NULL, $maxLength = NULL) + public function addText($name, $label = null, $cols = null, $maxLength = null) { return $this[$name] = (new Controls\TextInput($label, $maxLength)) ->setHtmlAttribute('size', $cols); @@ -253,7 +253,7 @@ public function addText($name, $label = NULL, $cols = NULL, $maxLength = NULL) * @param int * @return Controls\TextInput */ - public function addPassword($name, $label = NULL, $cols = NULL, $maxLength = NULL) + public function addPassword($name, $label = null, $cols = null, $maxLength = null) { return $this[$name] = (new Controls\TextInput($label, $maxLength)) ->setHtmlAttribute('size', $cols) @@ -269,7 +269,7 @@ public function addPassword($name, $label = NULL, $cols = NULL, $maxLength = NUL * @param int * @return Controls\TextArea */ - public function addTextArea($name, $label = NULL, $cols = NULL, $rows = NULL) + public function addTextArea($name, $label = null, $cols = null, $rows = null) { return $this[$name] = (new Controls\TextArea($label)) ->setHtmlAttribute('cols', $cols)->setHtmlAttribute('rows', $rows); @@ -282,10 +282,10 @@ public function addTextArea($name, $label = NULL, $cols = NULL, $rows = NULL) * @param string|object * @return Controls\TextInput */ - public function addEmail($name, $label = NULL) + public function addEmail($name, $label = null) { return $this[$name] = (new Controls\TextInput($label)) - ->setRequired(FALSE) + ->setRequired(false) ->addRule(Form::EMAIL); } @@ -296,11 +296,11 @@ public function addEmail($name, $label = NULL) * @param string|object * @return Controls\TextInput */ - public function addInteger($name, $label = NULL) + public function addInteger($name, $label = null) { return $this[$name] = (new Controls\TextInput($label)) ->setNullable() - ->setRequired(FALSE) + ->setRequired(false) ->addRule(Form::INTEGER); } @@ -312,7 +312,7 @@ public function addInteger($name, $label = NULL) * @param bool * @return Controls\UploadControl */ - public function addUpload($name, $label = NULL, $multiple = FALSE) + public function addUpload($name, $label = null, $multiple = false) { return $this[$name] = new Controls\UploadControl($label, $multiple); } @@ -324,9 +324,9 @@ public function addUpload($name, $label = NULL, $multiple = FALSE) * @param string|object * @return Controls\UploadControl */ - public function addMultiUpload($name, $label = NULL) + public function addMultiUpload($name, $label = null) { - return $this[$name] = new Controls\UploadControl($label, TRUE); + return $this[$name] = new Controls\UploadControl($label, true); } @@ -336,7 +336,7 @@ public function addMultiUpload($name, $label = NULL) * @param string * @return Controls\HiddenField */ - public function addHidden($name, $default = NULL) + public function addHidden($name, $default = null) { return $this[$name] = (new Controls\HiddenField) ->setDefaultValue($default); @@ -349,7 +349,7 @@ public function addHidden($name, $default = NULL) * @param string|object * @return Controls\Checkbox */ - public function addCheckbox($name, $caption = NULL) + public function addCheckbox($name, $caption = null) { return $this[$name] = new Controls\Checkbox($caption); } @@ -361,7 +361,7 @@ public function addCheckbox($name, $caption = NULL) * @param string|object * @return Controls\RadioList */ - public function addRadioList($name, $label = NULL, array $items = NULL) + public function addRadioList($name, $label = null, array $items = null) { return $this[$name] = new Controls\RadioList($label, $items); } @@ -373,7 +373,7 @@ public function addRadioList($name, $label = NULL, array $items = NULL) * @param string|object * @return Controls\CheckboxList */ - public function addCheckboxList($name, $label = NULL, array $items = NULL) + public function addCheckboxList($name, $label = null, array $items = null) { return $this[$name] = new Controls\CheckboxList($label, $items); } @@ -387,10 +387,10 @@ public function addCheckboxList($name, $label = NULL, array $items = NULL) * @param int * @return Controls\SelectBox */ - public function addSelect($name, $label = NULL, array $items = NULL, $size = NULL) + public function addSelect($name, $label = null, array $items = null, $size = null) { return $this[$name] = (new Controls\SelectBox($label, $items)) - ->setHtmlAttribute('size', $size > 1 ? (int) $size : NULL); + ->setHtmlAttribute('size', $size > 1 ? (int) $size : null); } @@ -402,10 +402,10 @@ public function addSelect($name, $label = NULL, array $items = NULL, $size = NUL * @param int * @return Controls\MultiSelectBox */ - public function addMultiSelect($name, $label = NULL, array $items = NULL, $size = NULL) + public function addMultiSelect($name, $label = null, array $items = null, $size = null) { return $this[$name] = (new Controls\MultiSelectBox($label, $items)) - ->setHtmlAttribute('size', $size > 1 ? (int) $size : NULL); + ->setHtmlAttribute('size', $size > 1 ? (int) $size : null); } @@ -415,7 +415,7 @@ public function addMultiSelect($name, $label = NULL, array $items = NULL, $size * @param string|object * @return Controls\SubmitButton */ - public function addSubmit($name, $caption = NULL) + public function addSubmit($name, $caption = null) { return $this[$name] = new Controls\SubmitButton($caption); } @@ -427,7 +427,7 @@ public function addSubmit($name, $caption = NULL) * @param string|object * @return Controls\Button */ - public function addButton($name, $caption = NULL) + public function addButton($name, $caption = null) { return $this[$name] = new Controls\Button($caption); } @@ -440,7 +440,7 @@ public function addButton($name, $caption = NULL) * @param string alternate text for the image * @return Controls\ImageButton */ - public function addImage($name, $src = NULL, $alt = NULL) + public function addImage($name, $src = null, $alt = null) { return $this[$name] = new Controls\ImageButton($src, $alt); } @@ -455,7 +455,7 @@ public function addContainer($name) { $control = new self; $control->currentGroup = $this->currentGroup; - if ($this->currentGroup !== NULL) { + if ($this->currentGroup !== null) { $this->currentGroup->add($control); } return $this[$name] = $control; @@ -474,9 +474,9 @@ public function __call($name, $args) } - public static function extensionMethod($name, $callback = NULL) + public static function extensionMethod($name, $callback = null) { - if (strpos($name, '::') !== FALSE) { // back compatibility + if (strpos($name, '::') !== false) { // back compatibility list(, $name) = explode('::', $name); } Nette\Utils\ObjectMixin::setExtensionMethod(__CLASS__, $name, $callback); @@ -506,7 +506,7 @@ public function offsetSet($name, $component) */ public function offsetGet($name) { - return $this->getComponent($name, TRUE); + return $this->getComponent($name, true); } @@ -517,7 +517,7 @@ public function offsetGet($name) */ public function offsetExists($name) { - return $this->getComponent($name, FALSE) !== NULL; + return $this->getComponent($name, false) !== null; } @@ -528,8 +528,8 @@ public function offsetExists($name) */ public function offsetUnset($name) { - $component = $this->getComponent($name, FALSE); - if ($component !== NULL) { + $component = $this->getComponent($name, false); + if ($component !== null) { $this->removeComponent($component); } } diff --git a/src/Forms/ControlGroup.php b/src/Forms/ControlGroup.php index 63a943b4c..5d5576799 100644 --- a/src/Forms/ControlGroup.php +++ b/src/Forms/ControlGroup.php @@ -70,7 +70,7 @@ public function remove(IControl $control) public function removeOrphans() { foreach ($this->controls as $control) { - if (!$control->getForm(FALSE)) { + if (!$control->getForm(false)) { $this->controls->detach($control); } } @@ -101,7 +101,7 @@ public function getControls() */ public function setOption($key, $value) { - if ($value === NULL) { + if ($value === null) { unset($this->options[$key]); } else { @@ -117,7 +117,7 @@ public function setOption($key, $value) * @param mixed * @return mixed */ - public function getOption($key, $default = NULL) + public function getOption($key, $default = null) { return isset($this->options[$key]) ? $this->options[$key] : $default; } diff --git a/src/Forms/Controls/BaseControl.php b/src/Forms/Controls/BaseControl.php index e8a275410..fc93b6232 100644 --- a/src/Forms/Controls/BaseControl.php +++ b/src/Forms/Controls/BaseControl.php @@ -54,39 +54,39 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo private $errors = []; /** @var bool */ - protected $disabled = FALSE; + protected $disabled = false; - /** @var bool|NULL */ + /** @var bool|null */ private $omitted; /** @var Rules */ private $rules; /** @var Nette\Localization\ITranslator */ - private $translator = TRUE; // means autodetect + private $translator = true; // means autodetect /** @var array user options */ private $options = []; /** @var bool */ - private static $autoOptional = FALSE; + private static $autoOptional = false; /** * @param string|object */ - public function __construct($caption = NULL) + public function __construct($caption = null) { $this->monitor(Form::class); parent::__construct(); - $this->control = Html::el('input', ['type' => NULL, 'name' => NULL]); + $this->control = Html::el('input', ['type' => null, 'name' => null]); $this->label = Html::el('label'); $this->caption = $caption; $this->rules = new Rules($this); if (self::$autoOptional) { - $this->setRequired(FALSE); + $this->setRequired(false); } - $this->setValue(NULL); + $this->setValue(null); } @@ -106,9 +106,9 @@ protected function attached($form) /** * Returns form. * @param bool - * @return Form|NULL + * @return Form|null */ - public function getForm($throw = TRUE) + public function getForm($throw = true) { return $this->lookup(Form::class, $throw); } @@ -128,7 +128,7 @@ public function loadHttpData() * Loads HTTP data. * @return mixed */ - protected function getHttpData($type, $htmlTail = NULL) + protected function getHttpData($type, $htmlTail = null) { return $this->getForm()->getHttpData($type, $this->getHtmlName() . $htmlTail); } @@ -176,7 +176,7 @@ public function getValue() public function isFilled() { $value = $this->getValue(); - return $value !== NULL && $value !== [] && $value !== ''; + return $value !== null && $value !== [] && $value !== ''; } @@ -186,7 +186,7 @@ public function isFilled() */ public function setDefaultValue($value) { - $form = $this->getForm(FALSE); + $form = $this->getForm(false); if ($this->isDisabled() || !$form || !$form->isAnchored() || !$form->isSubmitted()) { $this->setValue($value); } @@ -199,11 +199,11 @@ public function setDefaultValue($value) * @param bool * @return static */ - public function setDisabled($value = TRUE) + public function setDisabled($value = true) { if ($this->disabled = (bool) $value) { - $this->setValue(NULL); - } elseif (($form = $this->getForm(FALSE)) && $form->isAnchored() && $form->isSubmitted()) { + $this->setValue(null); + } elseif (($form = $this->getForm(false)) && $form->isAnchored() && $form->isSubmitted()) { $this->loadHttpData(); } return $this; @@ -216,7 +216,7 @@ public function setDisabled($value = TRUE) */ public function isDisabled() { - return $this->disabled === TRUE; + return $this->disabled === true; } @@ -225,7 +225,7 @@ public function isDisabled() * @param bool * @return static */ - public function setOmitted($value = TRUE) + public function setOmitted($value = true) { $this->omitted = (bool) $value; return $this; @@ -238,7 +238,7 @@ public function setOmitted($value = TRUE) */ public function isOmitted() { - return $this->omitted || ($this->isDisabled() && $this->omitted === NULL); + return $this->omitted || ($this->isDisabled() && $this->omitted === null); } @@ -251,14 +251,14 @@ public function isOmitted() */ public function getControl() { - $this->setOption('rendered', TRUE); + $this->setOption('rendered', true); $el = clone $this->control; return $el->addAttributes([ 'name' => $this->getHtmlName(), 'id' => $this->getHtmlId(), 'required' => $this->isRequired(), 'disabled' => $this->isDisabled(), - 'data-nette-rules' => Nette\Forms\Helpers::exportRules($this->rules) ?: NULL, + 'data-nette-rules' => Nette\Forms\Helpers::exportRules($this->rules) ?: null, ]); } @@ -268,17 +268,17 @@ public function getControl() * @param string|object * @return Html|string */ - public function getLabel($caption = NULL) + public function getLabel($caption = null) { $label = clone $this->label; $label->for = $this->getHtmlId(); - $label->setText($this->translate($caption === NULL ? $this->caption : $caption)); + $label->setText($this->translate($caption === null ? $this->caption : $caption)); return $label; } /** - * @return Nette\Utils\Html|NULL + * @return Nette\Utils\Html|null */ public function getControlPart() { @@ -287,7 +287,7 @@ public function getControlPart() /** - * @return Nette\Utils\Html|NULL + * @return Nette\Utils\Html|null */ public function getLabelPart() { @@ -317,7 +317,7 @@ public function getLabelPrototype() /** * Changes control's HTML id. - * @param mixed new ID, or FALSE or NULL + * @param mixed new ID, or false or null * @return static */ public function setHtmlId($id) @@ -346,7 +346,7 @@ public function getHtmlId() * @param mixed * @return static */ - public function setHtmlAttribute($name, $value = TRUE) + public function setHtmlAttribute($name, $value = true) { return $this->setAttribute($name, $value); } @@ -358,7 +358,7 @@ public function setHtmlAttribute($name, $value = TRUE) * @param mixed * @return static */ - public function setAttribute($name, $value = TRUE) + public function setAttribute($name, $value = true) { $this->control->$name = $value; return $this; @@ -372,7 +372,7 @@ public function setAttribute($name, $value = TRUE) * Sets translate adapter. * @return static */ - public function setTranslator(Nette\Localization\ITranslator $translator = NULL) + public function setTranslator(Nette\Localization\ITranslator $translator = null) { $this->translator = $translator; return $this; @@ -381,12 +381,12 @@ public function setTranslator(Nette\Localization\ITranslator $translator = NULL) /** * Returns translate adapter. - * @return Nette\Localization\ITranslator|NULL + * @return Nette\Localization\ITranslator|null */ public function getTranslator() { - if ($this->translator === TRUE) { - return $this->getForm(FALSE) ? $this->getForm()->getTranslator() : NULL; + if ($this->translator === true) { + return $this->getForm(false) ? $this->getForm()->getTranslator() : null; } return $this->translator; } @@ -398,12 +398,12 @@ public function getTranslator() * @param int plural count * @return mixed */ - public function translate($value, $count = NULL) + public function translate($value, $count = null) { if ($translator = $this->getTranslator()) { $tmp = is_array($value) ? [&$value] : [[&$value]]; foreach ($tmp[0] as &$v) { - if ($v != NULL && !$v instanceof Html) { // intentionally == + if ($v != null && !$v instanceof Html) { // intentionally == $v = $translator->translate($v, $count); } } @@ -422,7 +422,7 @@ public function translate($value, $count = NULL) * @param mixed * @return static */ - public function addRule($validator, $errorMessage = NULL, $arg = NULL) + public function addRule($validator, $errorMessage = null, $arg = null) { $this->rules->addRule($validator, $errorMessage, $arg); return $this; @@ -435,7 +435,7 @@ public function addRule($validator, $errorMessage = NULL, $arg = NULL) * @param mixed * @return Rules new branch */ - public function addCondition($validator, $value = NULL) + public function addCondition($validator, $value = null) { return $this->rules->addCondition($validator, $value); } @@ -448,7 +448,7 @@ public function addCondition($validator, $value = NULL) * @param mixed * @return Rules new branch */ - public function addConditionOn(IControl $control, $validator, $value = NULL) + public function addConditionOn(IControl $control, $validator, $value = null) { return $this->rules->addConditionOn($control, $validator, $value); } @@ -468,7 +468,7 @@ public function getRules() * @param mixed state or error message * @return static */ - public function setRequired($value = TRUE) + public function setRequired($value = true) { $this->rules->setRequired($value); return $this; @@ -512,11 +512,11 @@ public function addError($message) /** * Returns errors corresponding to control. - * @return string|NULL + * @return string|null */ public function getError() { - return $this->errors ? implode(' ', array_unique($this->errors)) : NULL; + return $this->errors ? implode(' ', array_unique($this->errors)) : null; } @@ -554,7 +554,7 @@ public function cleanErrors() */ public static function enableAutoOptionalMode() { - self::$autoOptional = TRUE; + self::$autoOptional = true; } @@ -567,7 +567,7 @@ public static function enableAutoOptionalMode() */ public function setOption($key, $value) { - if ($value === NULL) { + if ($value === null) { unset($this->options[$key]); } else { $this->options[$key] = $value; @@ -580,7 +580,7 @@ public function setOption($key, $value) * Returns user-specific option. * @return mixed */ - public function getOption($key, $default = NULL) + public function getOption($key, $default = null) { return isset($this->options[$key]) ? $this->options[$key] : $default; } @@ -608,9 +608,9 @@ public function __call($name, $args) } - public static function extensionMethod($name, $callback = NULL) + public static function extensionMethod($name, $callback = null) { - if (strpos($name, '::') !== FALSE) { // back compatibility + if (strpos($name, '::') !== false) { // back compatibility list(, $name) = explode('::', $name); } Nette\Utils\ObjectMixin::setExtensionMethod(get_called_class(), $name, $callback); diff --git a/src/Forms/Controls/Button.php b/src/Forms/Controls/Button.php index faf1105ee..11e7ab58d 100644 --- a/src/Forms/Controls/Button.php +++ b/src/Forms/Controls/Button.php @@ -19,7 +19,7 @@ class Button extends BaseControl /** * @param string|object */ - public function __construct($caption = NULL) + public function __construct($caption = null) { parent::__construct($caption); $this->control->type = 'button'; @@ -34,7 +34,7 @@ public function __construct($caption = NULL) public function isFilled() { $value = $this->getValue(); - return $value !== NULL && $value !== []; + return $value !== null && $value !== []; } @@ -42,7 +42,7 @@ public function isFilled() * Bypasses label generation. * @return void */ - public function getLabel($caption = NULL) + public function getLabel($caption = null) { } @@ -52,14 +52,14 @@ public function getLabel($caption = NULL) * @param string|object * @return Nette\Utils\Html */ - public function getControl($caption = NULL) + public function getControl($caption = null) { - $this->setOption('rendered', TRUE); + $this->setOption('rendered', true); $el = clone $this->control; return $el->addAttributes([ 'name' => $this->getHtmlName(), 'disabled' => $this->isDisabled(), - 'value' => $this->translate($caption === NULL ? $this->caption : $caption), + 'value' => $this->translate($caption === null ? $this->caption : $caption), ]); } } diff --git a/src/Forms/Controls/Checkbox.php b/src/Forms/Controls/Checkbox.php index ea2f2ed8e..9cfd03847 100644 --- a/src/Forms/Controls/Checkbox.php +++ b/src/Forms/Controls/Checkbox.php @@ -23,7 +23,7 @@ class Checkbox extends BaseControl /** * @param string|object */ - public function __construct($label = NULL) + public function __construct($label = null) { parent::__construct($label); $this->control->type = 'checkbox'; @@ -40,8 +40,8 @@ public function __construct($label = NULL) */ public function setValue($value) { - if (!is_scalar($value) && $value !== NULL) { - throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name)); + if (!is_scalar($value) && $value !== null) { + throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or null, %s given in field '%s'.", gettype($value), $this->name)); } $this->value = (bool) $value; return $this; @@ -54,7 +54,7 @@ public function setValue($value) */ public function isFilled() { - return $this->getValue() !== FALSE; // back compatibility + return $this->getValue() !== false; // back compatibility } @@ -72,7 +72,7 @@ public function getControl() * Bypasses label generation. * @return void */ - public function getLabel($caption = NULL) + public function getLabel($caption = null) { } diff --git a/src/Forms/Controls/CheckboxList.php b/src/Forms/Controls/CheckboxList.php index 8186eef20..b788a6801 100644 --- a/src/Forms/Controls/CheckboxList.php +++ b/src/Forms/Controls/CheckboxList.php @@ -33,7 +33,7 @@ class CheckboxList extends MultiChoiceControl /** * @param string|object */ - public function __construct($label = NULL, array $items = NULL) + public function __construct($label = null, array $items = null) { parent::__construct($label, $items); $this->control->type = 'checkbox'; @@ -58,10 +58,10 @@ public function getControl() Nette\Forms\Helpers::createInputList( $this->translate($items), array_merge($input->attrs, [ - 'id' => NULL, + 'id' => null, 'checked?' => $this->value, 'disabled:' => $this->disabled, - 'required' => NULL, + 'required' => null, 'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']], ]), $this->itemLabel ? $this->itemLabel->attrs : $this->label->attrs, @@ -76,23 +76,23 @@ public function getControl() * @param string|object * @return Html */ - public function getLabel($caption = NULL) + public function getLabel($caption = null) { - return parent::getLabel($caption)->for(NULL); + return parent::getLabel($caption)->for(null); } /** * @return Html */ - public function getControlPart($key = NULL) + public function getControlPart($key = null) { - $key = key([(string) $key => NULL]); + $key = key([(string) $key => null]); return parent::getControl()->addAttributes([ 'id' => $this->getHtmlId() . '-' . $key, - 'checked' => in_array($key, (array) $this->value, TRUE), + 'checked' => in_array($key, (array) $this->value, true), 'disabled' => is_array($this->disabled) ? isset($this->disabled[$key]) : $this->disabled, - 'required' => NULL, + 'required' => null, 'value' => $key, ]); } @@ -101,7 +101,7 @@ public function getControlPart($key = NULL) /** * @return Html */ - public function getLabelPart($key = NULL) + public function getLabelPart($key = null) { $itemLabel = $this->itemLabel ? clone $this->itemLabel : clone $this->label; return func_num_args() diff --git a/src/Forms/Controls/ChoiceControl.php b/src/Forms/Controls/ChoiceControl.php index eb6138d9c..c1f36f6e9 100644 --- a/src/Forms/Controls/ChoiceControl.php +++ b/src/Forms/Controls/ChoiceControl.php @@ -19,16 +19,16 @@ abstract class ChoiceControl extends BaseControl { /** @var bool */ - public $checkAllowedValues = TRUE; + public $checkAllowedValues = true; /** @var array */ private $items = []; - public function __construct($label = NULL, array $items = NULL) + public function __construct($label = null, array $items = null) { parent::__construct($label); - if ($items !== NULL) { + if ($items !== null) { $this->setItems($items); } } @@ -41,11 +41,11 @@ public function __construct($label = NULL, array $items = NULL) public function loadHttpData() { $this->value = $this->getHttpData(Nette\Forms\Form::DATA_TEXT); - if ($this->value !== NULL) { + if ($this->value !== null) { if (is_array($this->disabled) && isset($this->disabled[$this->value])) { - $this->value = NULL; + $this->value = null; } else { - $this->value = key([$this->value => NULL]); + $this->value = key([$this->value => null]); } } } @@ -59,11 +59,11 @@ public function loadHttpData() */ public function setValue($value) { - if ($this->checkAllowedValues && $value !== NULL && !array_key_exists((string) $value, $this->items)) { - $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, TRUE); }, array_keys($this->items))), 70, '...'); + if ($this->checkAllowedValues && $value !== null && !array_key_exists((string) $value, $this->items)) { + $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, true); }, array_keys($this->items))), 70, '...'); throw new Nette\InvalidArgumentException("Value '$value' is out of allowed set [$set] in field '{$this->name}'."); } - $this->value = $value === NULL ? NULL : key([(string) $value => NULL]); + $this->value = $value === null ? null : key([(string) $value => null]); return $this; } @@ -74,7 +74,7 @@ public function setValue($value) */ public function getValue() { - return array_key_exists($this->value, $this->items) ? $this->value : NULL; + return array_key_exists($this->value, $this->items) ? $this->value : null; } @@ -94,7 +94,7 @@ public function getRawValue() */ public function isFilled() { - return $this->getValue() !== NULL; + return $this->getValue() !== null; } @@ -104,7 +104,7 @@ public function isFilled() * @param bool * @return static */ - public function setItems(array $items, $useKeys = TRUE) + public function setItems(array $items, $useKeys = true) { $this->items = $useKeys ? $items : array_combine($items, $items); return $this; @@ -128,7 +128,7 @@ public function getItems() public function getSelectedItem() { $value = $this->getValue(); - return $value === NULL ? NULL : $this->items[$value]; + return $value === null ? null : $this->items[$value]; } @@ -137,16 +137,16 @@ public function getSelectedItem() * @param bool|array * @return static */ - public function setDisabled($value = TRUE) + public function setDisabled($value = true) { if (!is_array($value)) { return parent::setDisabled($value); } - parent::setDisabled(FALSE); - $this->disabled = array_fill_keys($value, TRUE); + parent::setDisabled(false); + $this->disabled = array_fill_keys($value, true); if (isset($this->disabled[$this->value])) { - $this->value = NULL; + $this->value = null; } return $this; } diff --git a/src/Forms/Controls/CsrfProtection.php b/src/Forms/Controls/CsrfProtection.php index 33eb076d4..bdd0c0639 100644 --- a/src/Forms/Controls/CsrfProtection.php +++ b/src/Forms/Controls/CsrfProtection.php @@ -79,12 +79,12 @@ public function getToken() /** * @return string */ - private function generateToken($random = NULL) + private function generateToken($random = null) { - if ($random === NULL) { + if ($random === null) { $random = Nette\Utils\Random::generate(10); } - return $random . base64_encode(sha1($this->getToken() . $random, TRUE)); + return $random . base64_encode(sha1($this->getToken() . $random, true)); } diff --git a/src/Forms/Controls/HiddenField.php b/src/Forms/Controls/HiddenField.php index 710948342..fd023026d 100644 --- a/src/Forms/Controls/HiddenField.php +++ b/src/Forms/Controls/HiddenField.php @@ -19,14 +19,14 @@ class HiddenField extends BaseControl private $persistValue; - public function __construct($persistentValue = NULL) + public function __construct($persistentValue = null) { parent::__construct(); $this->control->type = 'hidden'; $this->setOption('type', 'hidden'); - if ($persistentValue !== NULL) { + if ($persistentValue !== null) { $this->unmonitor(Nette\Forms\Form::class); - $this->persistValue = TRUE; + $this->persistValue = true; $this->value = (string) $persistentValue; } } @@ -40,8 +40,8 @@ public function __construct($persistentValue = NULL) */ public function setValue($value) { - if (!is_scalar($value) && $value !== NULL && !method_exists($value, '__toString')) { - throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name)); + if (!is_scalar($value) && $value !== null && !method_exists($value, '__toString')) { + throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or null, %s given in field '%s'.", gettype($value), $this->name)); } if (!$this->persistValue) { $this->value = (string) $value; @@ -56,7 +56,7 @@ public function setValue($value) */ public function getControl() { - $this->setOption('rendered', TRUE); + $this->setOption('rendered', true); $el = clone $this->control; return $el->addAttributes([ 'name' => $this->getHtmlName(), @@ -71,7 +71,7 @@ public function getControl() * @param string|object * @return void */ - public function getLabel($caption = NULL) + public function getLabel($caption = null) { } diff --git a/src/Forms/Controls/ImageButton.php b/src/Forms/Controls/ImageButton.php index bca4a8979..33f8c755b 100644 --- a/src/Forms/Controls/ImageButton.php +++ b/src/Forms/Controls/ImageButton.php @@ -18,7 +18,7 @@ class ImageButton extends SubmitButton * @param string URI of the image * @param string alternate text for the image */ - public function __construct($src = NULL, $alt = NULL) + public function __construct($src = null, $alt = null) { parent::__construct(); $this->control->type = 'image'; @@ -36,7 +36,7 @@ public function loadHttpData() parent::loadHttpData(); $this->value = $this->value ? [(int) array_shift($this->value), (int) array_shift($this->value)] - : NULL; + : null; } diff --git a/src/Forms/Controls/MultiChoiceControl.php b/src/Forms/Controls/MultiChoiceControl.php index 20dde4a76..db916951c 100644 --- a/src/Forms/Controls/MultiChoiceControl.php +++ b/src/Forms/Controls/MultiChoiceControl.php @@ -19,16 +19,16 @@ abstract class MultiChoiceControl extends BaseControl { /** @var bool */ - public $checkAllowedValues = TRUE; + public $checkAllowedValues = true; /** @var array */ private $items = []; - public function __construct($label = NULL, array $items = NULL) + public function __construct($label = null, array $items = null) { parent::__construct($label); - if ($items !== NULL) { + if ($items !== null) { $this->setItems($items); } } @@ -55,21 +55,21 @@ public function loadHttpData() */ public function setValue($values) { - if (is_scalar($values) || $values === NULL) { + if (is_scalar($values) || $values === null) { $values = (array) $values; } elseif (!is_array($values)) { - throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name)); + throw new Nette\InvalidArgumentException(sprintf("Value must be array or null, %s given in field '%s'.", gettype($values), $this->name)); } $flip = []; foreach ($values as $value) { if (!is_scalar($value) && !method_exists($value, '__toString')) { throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name)); } - $flip[(string) $value] = TRUE; + $flip[(string) $value] = true; } $values = array_keys($flip); if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) { - $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, TRUE); }, array_keys($this->items))), 70, '...'); + $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, true); }, array_keys($this->items))), 70, '...'); $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'"; throw new Nette\InvalidArgumentException("Value$vals are out of allowed set [$set] in field '{$this->name}'."); } @@ -114,7 +114,7 @@ public function isFilled() * @param bool * @return static */ - public function setItems(array $items, $useKeys = TRUE) + public function setItems(array $items, $useKeys = true) { $this->items = $useKeys ? $items : array_combine($items, $items); return $this; @@ -146,14 +146,14 @@ public function getSelectedItems() * @param bool|array * @return static */ - public function setDisabled($value = TRUE) + public function setDisabled($value = true) { if (!is_array($value)) { return parent::setDisabled($value); } - parent::setDisabled(FALSE); - $this->disabled = array_fill_keys($value, TRUE); + parent::setDisabled(false); + $this->disabled = array_fill_keys($value, true); $this->value = array_diff($this->value, $value); return $this; } diff --git a/src/Forms/Controls/MultiSelectBox.php b/src/Forms/Controls/MultiSelectBox.php index 693c13aeb..d20692f58 100644 --- a/src/Forms/Controls/MultiSelectBox.php +++ b/src/Forms/Controls/MultiSelectBox.php @@ -22,7 +22,7 @@ class MultiSelectBox extends MultiChoiceControl private $optionAttributes = []; - public function __construct($label = NULL, array $items = NULL) + public function __construct($label = null, array $items = null) { parent::__construct($label, $items); $this->setOption('type', 'select'); @@ -33,7 +33,7 @@ public function __construct($label = NULL, array $items = NULL) * Sets options and option groups from which to choose. * @return static */ - public function setItems(array $items, $useKeys = TRUE) + public function setItems(array $items, $useKeys = true) { if (!$useKeys) { $res = []; @@ -50,7 +50,7 @@ public function setItems(array $items, $useKeys = TRUE) $items = $res; } $this->options = $items; - return parent::setItems(Nette\Utils\Arrays::flatten($items, TRUE)); + return parent::setItems(Nette\Utils\Arrays::flatten($items, true)); } @@ -68,10 +68,10 @@ public function getControl() return Nette\Forms\Helpers::createSelectBox( $items, [ - 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL, + 'disabled:' => is_array($this->disabled) ? $this->disabled : null, ] + $this->optionAttributes, $this->value - )->addAttributes(parent::getControl()->attrs)->multiple(TRUE); + )->addAttributes(parent::getControl()->attrs)->multiple(true); } diff --git a/src/Forms/Controls/RadioList.php b/src/Forms/Controls/RadioList.php index 894e4b6b8..6b4e5ab19 100644 --- a/src/Forms/Controls/RadioList.php +++ b/src/Forms/Controls/RadioList.php @@ -21,7 +21,7 @@ class RadioList extends ChoiceControl { /** @var bool */ - public $generateId = FALSE; + public $generateId = false; /** @var Html separator element template */ protected $separator; @@ -36,7 +36,7 @@ class RadioList extends ChoiceControl /** * @param string|object */ - public function __construct($label = NULL, array $items = NULL) + public function __construct($label = null, array $items = null) { parent::__construct($label, $items); $this->control->type = 'radio'; @@ -83,21 +83,21 @@ public function getControl() * @param string|object * @return Html */ - public function getLabel($caption = NULL) + public function getLabel($caption = null) { - return parent::getLabel($caption)->for(NULL); + return parent::getLabel($caption)->for(null); } /** * @return Html */ - public function getControlPart($key = NULL) + public function getControlPart($key = null) { - $key = key([(string) $key => NULL]); + $key = key([(string) $key => null]); return parent::getControl()->addAttributes([ 'id' => $this->getHtmlId() . '-' . $key, - 'checked' => in_array($key, (array) $this->value, TRUE), + 'checked' => in_array($key, (array) $this->value, true), 'disabled' => is_array($this->disabled) ? isset($this->disabled[$key]) : $this->disabled, 'value' => $key, ]); @@ -107,7 +107,7 @@ public function getControlPart($key = NULL) /** * @return Html */ - public function getLabelPart($key = NULL) + public function getLabelPart($key = null) { $itemLabel = clone $this->itemLabel; return func_num_args() diff --git a/src/Forms/Controls/SelectBox.php b/src/Forms/Controls/SelectBox.php index f8f5d4a20..ed9e6de14 100644 --- a/src/Forms/Controls/SelectBox.php +++ b/src/Forms/Controls/SelectBox.php @@ -22,13 +22,13 @@ class SelectBox extends ChoiceControl private $options = []; /** @var mixed */ - private $prompt = FALSE; + private $prompt = false; /** @var array */ private $optionAttributes = []; - public function __construct($label = NULL, array $items = NULL) + public function __construct($label = null, array $items = null) { parent::__construct($label, $items); $this->setOption('type', 'select'); @@ -63,7 +63,7 @@ public function getPrompt() * Sets options and option groups from which to choose. * @return static */ - public function setItems(array $items, $useKeys = TRUE) + public function setItems(array $items, $useKeys = true) { if (!$useKeys) { $res = []; @@ -80,7 +80,7 @@ public function setItems(array $items, $useKeys = TRUE) $items = $res; } $this->options = $items; - return parent::setItems(Nette\Utils\Arrays::flatten($items, TRUE)); + return parent::setItems(Nette\Utils\Arrays::flatten($items, true)); } @@ -90,7 +90,7 @@ public function setItems(array $items, $useKeys = TRUE) */ public function getControl() { - $items = $this->prompt === FALSE ? [] : ['' => $this->translate($this->prompt)]; + $items = $this->prompt === false ? [] : ['' => $this->translate($this->prompt)]; foreach ($this->options as $key => $value) { $items[is_array($value) ? $this->translate($key) : $key] = $this->translate($value); } @@ -98,7 +98,7 @@ public function getControl() return Nette\Forms\Helpers::createSelectBox( $items, [ - 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL, + 'disabled:' => is_array($this->disabled) ? $this->disabled : null, ] + $this->optionAttributes, $this->value )->addAttributes(parent::getControl()->attrs); @@ -121,8 +121,8 @@ public function addOptionAttributes(array $attributes) public function isOk() { return $this->isDisabled() - || $this->prompt !== FALSE - || $this->getValue() !== NULL + || $this->prompt !== false + || $this->getValue() !== null || !$this->options || $this->control->size > 1; } diff --git a/src/Forms/Controls/SubmitButton.php b/src/Forms/Controls/SubmitButton.php index eac513203..2d670239e 100644 --- a/src/Forms/Controls/SubmitButton.php +++ b/src/Forms/Controls/SubmitButton.php @@ -23,18 +23,18 @@ class SubmitButton extends Button implements Nette\Forms\ISubmitterControl /** @var callable[] function (SubmitButton $sender); Occurs when the button is clicked and form is not validated */ public $onInvalidClick; - /** @var array|NULL */ + /** @var array|null */ private $validationScope; /** * @param string|object */ - public function __construct($caption = NULL) + public function __construct($caption = null) { parent::__construct($caption); $this->control->type = 'submit'; - $this->setOmitted(TRUE); + $this->setOmitted(true); } @@ -65,10 +65,10 @@ public function isSubmittedBy() * Sets the validation scope. Clicking the button validates only the controls within the specified scope. * @return static */ - public function setValidationScope(/*array*/$scope = NULL) + public function setValidationScope(/*array*/$scope = null) { - if ($scope === NULL || $scope === TRUE) { - $this->validationScope = NULL; + if ($scope === null || $scope === true) { + $this->validationScope = null; } else { $this->validationScope = []; foreach ($scope ?: [] as $control) { @@ -84,7 +84,7 @@ public function setValidationScope(/*array*/$scope = NULL) /** * Gets the validation scope. - * @return array|NULL + * @return array|null */ public function getValidationScope() { @@ -107,15 +107,15 @@ public function click() * @param string|object * @return Nette\Utils\Html */ - public function getControl($caption = NULL) + public function getControl($caption = null) { $scope = []; foreach ((array) $this->validationScope as $control) { $scope[] = $control->lookupPath(Nette\Forms\Form::class); } return parent::getControl($caption)->addAttributes([ - 'formnovalidate' => $this->validationScope !== NULL, - 'data-nette-validation-scope' => $scope ?: NULL, + 'formnovalidate' => $this->validationScope !== null, + 'data-nette-validation-scope' => $scope ?: null, ]); } } diff --git a/src/Forms/Controls/TextArea.php b/src/Forms/Controls/TextArea.php index a3e55ee15..8b033de6b 100644 --- a/src/Forms/Controls/TextArea.php +++ b/src/Forms/Controls/TextArea.php @@ -19,7 +19,7 @@ class TextArea extends TextBase /** * @param string|object */ - public function __construct($label = NULL) + public function __construct($label = null) { parent::__construct($label); $this->control->setName('textarea'); diff --git a/src/Forms/Controls/TextBase.php b/src/Forms/Controls/TextBase.php index 5ace8b177..4331f170f 100644 --- a/src/Forms/Controls/TextBase.php +++ b/src/Forms/Controls/TextBase.php @@ -34,10 +34,10 @@ abstract class TextBase extends BaseControl */ public function setValue($value) { - if ($value === NULL) { + if ($value === null) { $value = ''; } elseif (!is_scalar($value) && !method_exists($value, '__toString')) { - throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name)); + throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or null, %s given in field '%s'.", gettype($value), $this->name)); } $this->value = $value; $this->rawValue = (string) $value; @@ -52,16 +52,16 @@ public function setValue($value) public function getValue() { $value = $this->value === Strings::trim($this->translate($this->emptyValue)) ? '' : $this->value; - return $this->nullable && $value === '' ? NULL : $value; + return $this->nullable && $value === '' ? null : $value; } /** - * Sets whether getValue() returns NULL instead of empty string. + * Sets whether getValue() returns null instead of empty string. * @param bool * @return static */ - public function setNullable($value = TRUE) + public function setNullable($value = true) { $this->nullable = (bool) $value; return $this; @@ -128,12 +128,12 @@ public function getControl() /** - * @return string|NULL + * @return string|null */ protected function getRenderedValue() { return $this->rawValue === '' - ? ($this->emptyValue === '' ? NULL : $this->translate($this->emptyValue)) + ? ($this->emptyValue === '' ? null : $this->translate($this->emptyValue)) : $this->rawValue; } @@ -141,7 +141,7 @@ protected function getRenderedValue() /** * @return static */ - public function addRule($validator, $errorMessage = NULL, $arg = NULL) + public function addRule($validator, $errorMessage = null, $arg = null) { if ($validator === Form::LENGTH || $validator === Form::MAX_LENGTH) { $tmp = is_array($arg) ? $arg[1] : $arg; diff --git a/src/Forms/Controls/TextInput.php b/src/Forms/Controls/TextInput.php index e7528624a..a6d57f41d 100644 --- a/src/Forms/Controls/TextInput.php +++ b/src/Forms/Controls/TextInput.php @@ -21,7 +21,7 @@ class TextInput extends TextBase * @param string|object * @param int */ - public function __construct($label = NULL, $maxLength = NULL) + public function __construct($label = null, $maxLength = null) { parent::__construct($label); $this->control->maxlength = $maxLength; @@ -78,19 +78,19 @@ public function getControl() /** * @return static */ - public function addRule($validator, $errorMessage = NULL, $arg = NULL) + public function addRule($validator, $errorMessage = null, $arg = null) { - if ($this->control->type === NULL && in_array($validator, [Form::EMAIL, Form::URL, Form::INTEGER], TRUE)) { + if ($this->control->type === null && in_array($validator, [Form::EMAIL, Form::URL, Form::INTEGER], true)) { static $types = [Form::EMAIL => 'email', Form::URL => 'url', Form::INTEGER => 'number']; $this->control->type = $types[$validator]; - } elseif (in_array($validator, [Form::MIN, Form::MAX, Form::RANGE], TRUE) - && in_array($this->control->type, ['number', 'range', 'datetime-local', 'datetime', 'date', 'month', 'week', 'time'], TRUE) + } elseif (in_array($validator, [Form::MIN, Form::MAX, Form::RANGE], true) + && in_array($this->control->type, ['number', 'range', 'datetime-local', 'datetime', 'date', 'month', 'week', 'time'], true) ) { if ($validator === Form::MIN) { - $range = [$arg, NULL]; + $range = [$arg, null]; } elseif ($validator === Form::MAX) { - $range = [NULL, $arg]; + $range = [null, $arg]; } else { $range = $arg; } @@ -102,7 +102,7 @@ public function addRule($validator, $errorMessage = NULL, $arg = NULL) } } elseif ($validator === Form::PATTERN && is_scalar($arg) - && in_array($this->control->type, [NULL, 'text', 'search', 'tel', 'url', 'email', 'password'], TRUE) + && in_array($this->control->type, [null, 'text', 'search', 'tel', 'url', 'email', 'password'], true) ) { $this->control->pattern = $arg; } diff --git a/src/Forms/Controls/UploadControl.php b/src/Forms/Controls/UploadControl.php index e86a80635..cff078778 100644 --- a/src/Forms/Controls/UploadControl.php +++ b/src/Forms/Controls/UploadControl.php @@ -25,7 +25,7 @@ class UploadControl extends BaseControl * @param string|object * @param bool */ - public function __construct($label = NULL, $multiple = FALSE) + public function __construct($label = null, $multiple = false) { parent::__construct($label); $this->control->type = 'file'; @@ -61,8 +61,8 @@ protected function attached($form) public function loadHttpData() { $this->value = $this->getHttpData(Nette\Forms\Form::DATA_FILE); - if ($this->value === NULL) { - $this->value = new FileUpload(NULL); + if ($this->value === null) { + $this->value = new FileUpload(null); } } @@ -94,7 +94,7 @@ public function setValue($value) public function isFilled() { return $this->value instanceof FileUpload - ? $this->value->getError() !== UPLOAD_ERR_NO_FILE // ignore NULL object + ? $this->value->getError() !== UPLOAD_ERR_NO_FILE // ignore null object : (bool) $this->value; } @@ -109,6 +109,6 @@ public function isOk() ? $this->value->isOk() : $this->value && array_reduce($this->value, function ($carry, $fileUpload) { return $carry && $fileUpload->isOk(); - }, TRUE); + }, true); } } diff --git a/src/Forms/Form.php b/src/Forms/Form.php index bd1335ac4..eb185edb9 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -93,7 +93,7 @@ class Form extends Container implements Nette\Utils\IHtmlString /** @var callable[] function (Form $sender); Occurs before the form is rendered */ public $onRender; - /** @var mixed or NULL meaning: not detected yet */ + /** @var mixed or null meaning: not detected yet */ private $submittedBy; /** @var array */ @@ -125,15 +125,15 @@ class Form extends Container implements Nette\Utils\IHtmlString * Form constructor. * @param string */ - public function __construct($name = NULL) + public function __construct($name = null) { parent::__construct(); - if ($name !== NULL) { + if ($name !== null) { $this->getElementPrototype()->id = 'frm-' . $name; $tracker = new Controls\HiddenField($name); $tracker->setOmitted(); $this[self::TRACKER_ID] = $tracker; - $this->setParent(NULL, $name); + $this->setParent(null, $name); } } @@ -166,7 +166,7 @@ protected function attached($obj) * Returns self. * @return static */ - public function getForm($throw = TRUE) + public function getForm($throw = true) { return $this; } @@ -201,7 +201,7 @@ public function getAction() */ public function setMethod($method) { - if ($this->httpData !== NULL) { + if ($this->httpData !== null) { throw new Nette\InvalidStateException(__METHOD__ . '() must be called until the form is empty.'); } $this->getElementPrototype()->method = strtolower($method); @@ -235,7 +235,7 @@ public function isMethod($method) * @param string * @return Controls\CsrfProtection */ - public function addProtection($errorMessage = NULL) + public function addProtection($errorMessage = null) { $control = new Controls\CsrfProtection($errorMessage); $this->addComponent($control, self::PROTECTOR_ID, key($this->getComponents())); @@ -249,11 +249,11 @@ public function addProtection($errorMessage = NULL) * @param bool * @return ControlGroup */ - public function addGroup($caption = NULL, $setAsCurrent = TRUE) + public function addGroup($caption = null, $setAsCurrent = true) { $group = new ControlGroup; $group->setOption('label', $caption); - $group->setOption('visual', TRUE); + $group->setOption('visual', true); if ($setAsCurrent) { $this->setCurrentGroup($group); @@ -277,9 +277,9 @@ public function removeGroup($name) if (is_string($name) && isset($this->groups[$name])) { $group = $this->groups[$name]; - } elseif ($name instanceof ControlGroup && in_array($name, $this->groups, TRUE)) { + } elseif ($name instanceof ControlGroup && in_array($name, $this->groups, true)) { $group = $name; - $name = array_search($group, $this->groups, TRUE); + $name = array_search($group, $this->groups, true); } else { throw new Nette\InvalidArgumentException("Group not found in form '$this->name'"); @@ -306,11 +306,11 @@ public function getGroups() /** * Returns the specified group. * @param string|int - * @return ControlGroup|NULL + * @return ControlGroup|null */ public function getGroup($name) { - return isset($this->groups[$name]) ? $this->groups[$name] : NULL; + return isset($this->groups[$name]) ? $this->groups[$name] : null; } @@ -321,7 +321,7 @@ public function getGroup($name) * Sets translate adapter. * @return static */ - public function setTranslator(Nette\Localization\ITranslator $translator = NULL) + public function setTranslator(Nette\Localization\ITranslator $translator = null) { $this->translator = $translator; return $this; @@ -330,7 +330,7 @@ public function setTranslator(Nette\Localization\ITranslator $translator = NULL) /** * Returns translate adapter. - * @return Nette\Localization\ITranslator|NULL + * @return Nette\Localization\ITranslator|null */ public function getTranslator() { @@ -347,17 +347,17 @@ public function getTranslator() */ public function isAnchored() { - return TRUE; + return true; } /** * Tells if the form was submitted. - * @return ISubmitterControl|FALSE submittor control + * @return ISubmitterControl|false submittor control */ public function isSubmitted() { - if ($this->submittedBy === NULL) { + if ($this->submittedBy === null) { $this->getHttpData(); } return $this->submittedBy; @@ -379,9 +379,9 @@ public function isSuccess() * @return static * @internal */ - public function setSubmittedBy(ISubmitterControl $by = NULL) + public function setSubmittedBy(ISubmitterControl $by = null) { - $this->submittedBy = $by === NULL ? FALSE : $by; + $this->submittedBy = $by === null ? false : $by; return $this; } @@ -392,9 +392,9 @@ public function setSubmittedBy(ISubmitterControl $by = NULL) * @param string * @return mixed */ - public function getHttpData($type = NULL, $htmlName = NULL) + public function getHttpData($type = null, $htmlName = null) { - if ($this->httpData === NULL) { + if ($this->httpData === null) { if (!$this->isAnchored()) { throw new Nette\InvalidStateException('Form is not anchored and therefore can not determine whether it was submitted.'); } @@ -402,7 +402,7 @@ public function getHttpData($type = NULL, $htmlName = NULL) $this->httpData = (array) $data; $this->submittedBy = is_array($data); } - if ($htmlName === NULL) { + if ($htmlName === null) { return $this->httpData; } return Helpers::extractHttpData($this->httpData, $htmlName, $type); @@ -438,7 +438,7 @@ public function fireEvents() if (!$this->isValid()) { $this->onError($this); - } elseif ($this->onSuccess !== NULL) { + } elseif ($this->onSuccess !== null) { if (!is_array($this->onSuccess) && !$this->onSuccess instanceof \Traversable) { throw new Nette\UnexpectedValueException('Property Form::$onSuccess must be array or Traversable, ' . gettype($this->onSuccess) . ' given.'); } @@ -452,11 +452,11 @@ public function fireEvents() } - private function invokeHandlers($handlers, $button = NULL) + private function invokeHandlers($handlers, $button = null) { foreach ($handlers as $handler) { $params = Nette\Utils\Callback::toReflection($handler)->getParameters(); - $values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : NULL; + $values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : null; Nette\Utils\Callback::invoke($handler, $button ?: $this, $values); if (!$button && !$this->isValid()) { return; @@ -466,8 +466,8 @@ private function invokeHandlers($handlers, $button = NULL) /** - * Internal: returns submitted HTTP data or NULL when form was not submitted. - * @return array|NULL + * Internal: returns submitted HTTP data or null when form was not submitted. + * @return array|null */ protected function receiveHttpData() { @@ -485,7 +485,7 @@ protected function receiveHttpData() } } - if ($tracker = $this->getComponent(self::TRACKER_ID, FALSE)) { + if ($tracker = $this->getComponent(self::TRACKER_ID, false)) { if (!isset($data[self::TRACKER_ID]) || $data[self::TRACKER_ID] !== $tracker->getValue()) { return; } @@ -501,10 +501,10 @@ protected function receiveHttpData() /** * @return void */ - public function validate(array $controls = NULL) + public function validate(array $controls = null) { $this->cleanErrors(); - if ($controls === NULL && $this->submittedBy instanceof ISubmitterControl) { + if ($controls === null && $this->submittedBy instanceof ISubmitterControl) { $controls = $this->submittedBy->getValidationScope(); } $this->validateMaxPostSize(); @@ -600,7 +600,7 @@ public function getElementPrototype() * Sets form renderer. * @return static */ - public function setRenderer(IFormRenderer $renderer = NULL) + public function setRenderer(IFormRenderer $renderer = null) { $this->renderer = $renderer; return $this; @@ -613,7 +613,7 @@ public function setRenderer(IFormRenderer $renderer = NULL) */ public function getRenderer() { - if ($this->renderer === NULL) { + if ($this->renderer === null) { $this->renderer = new Rendering\DefaultFormRenderer; } return $this->renderer; @@ -635,10 +635,10 @@ protected function beforeRender() public function fireRenderEvents() { if (!$this->beforeRenderCalled) { - foreach ($this->getComponents(TRUE, Controls\BaseControl::class) as $control) { + foreach ($this->getComponents(true, Controls\BaseControl::class) as $control) { $control->getRules()->check(); } - $this->beforeRenderCalled = TRUE; + $this->beforeRenderCalled = true; $this->beforeRender(); $this->onRender($this); } @@ -701,7 +701,7 @@ private function getHttpRequest() public function getToggles() { $toggles = []; - foreach ($this->getComponents(TRUE, Controls\BaseControl::class) as $control) { + foreach ($this->getComponents(true, Controls\BaseControl::class) as $control) { $toggles = $control->getRules()->getToggleStates($toggles); } return $toggles; diff --git a/src/Forms/Helpers.php b/src/Forms/Helpers.php index 3f6edd973..b540d1be9 100644 --- a/src/Forms/Helpers.php +++ b/src/Forms/Helpers.php @@ -36,7 +36,7 @@ class Helpers public static function extractHttpData(array $data, $htmlName, $type) { $name = explode('[', str_replace(['[]', ']', '.'], ['', '', '_'], $htmlName)); - $data = Nette\Utils\Arrays::get($data, $name, NULL); + $data = Nette\Utils\Arrays::get($data, $name, null); $itype = $type & ~Form::DATA_KEYS; if (substr($htmlName, -2) === '[]') { @@ -45,7 +45,7 @@ public static function extractHttpData(array $data, $htmlName, $type) } foreach ($data as $k => $v) { $data[$k] = $v = static::sanitize($itype, $v); - if ($v === NULL) { + if ($v === null) { unset($data[$k]); } } @@ -62,13 +62,13 @@ public static function extractHttpData(array $data, $htmlName, $type) private static function sanitize($type, $value) { if ($type === Form::DATA_TEXT) { - return is_scalar($value) ? Strings::normalizeNewLines($value) : NULL; + return is_scalar($value) ? Strings::normalizeNewLines($value) : null; } elseif ($type === Form::DATA_LINE) { - return is_scalar($value) ? Strings::trim(strtr((string) $value, "\r\n", ' ')) : NULL; + return is_scalar($value) ? Strings::trim(strtr((string) $value, "\r\n", ' ')) : null; } elseif ($type === Form::DATA_FILE) { - return $value instanceof Nette\Http\FileUpload ? $value : NULL; + return $value instanceof Nette\Http\FileUpload ? $value : null; } else { throw new Nette\InvalidArgumentException('Unknown data type'); @@ -86,7 +86,7 @@ public static function generateHtmlName($id) if ($count) { $name = substr_replace($name, '', strpos($name, ']'), 1) . ']'; } - if (is_numeric($name) || in_array($name, self::$unsafeNames, TRUE)) { + if (is_numeric($name) || in_array($name, self::$unsafeNames, true)) { $name = '_' . $name; } return $name; @@ -118,7 +118,7 @@ public static function exportRules(Rules $rules) continue; } } else { - $item = ['op' => ($rule->isNegative ? '~' : '') . $op, 'msg' => Validator::formatMessage($rule, FALSE)]; + $item = ['op' => ($rule->isNegative ? '~' : '') . $op, 'msg' => Validator::formatMessage($rule, false)]; } if (is_array($rule->arg)) { @@ -126,7 +126,7 @@ public static function exportRules(Rules $rules) foreach ($rule->arg as $key => $value) { $item['arg'][$key] = $value instanceof IControl ? ['control' => $value->getHtmlName()] : $value; } - } elseif ($rule->arg !== NULL) { + } elseif ($rule->arg !== null) { $item['arg'] = $rule->arg instanceof IControl ? ['control' => $rule->arg->getHtmlName()] : $rule->arg; } @@ -142,7 +142,7 @@ public static function exportRules(Rules $rules) /** * @return string */ - public static function createInputList(array $items, array $inputAttrs = NULL, array $labelAttrs = NULL, $wrapper = NULL) + public static function createInputList(array $items, array $inputAttrs = null, array $labelAttrs = null, $wrapper = null) { list($inputAttrs, $inputTag) = self::prepareAttrs($inputAttrs, 'input'); list($labelAttrs, $labelTag) = self::prepareAttrs($labelAttrs, 'label'); @@ -153,10 +153,10 @@ public static function createInputList(array $items, array $inputAttrs = NULL, a foreach ($items as $value => $caption) { foreach ($inputAttrs as $k => $v) { - $input->attrs[$k] = isset($v[$value]) ? $v[$value] : NULL; + $input->attrs[$k] = isset($v[$value]) ? $v[$value] : null; } foreach ($labelAttrs as $k => $v) { - $label->attrs[$k] = isset($v[$value]) ? $v[$value] : NULL; + $label->attrs[$k] = isset($v[$value]) ? $v[$value] : null; } $input->value = $value; $res .= ($res === '' && $wrapperEnd === '' ? '' : $wrapper) @@ -173,9 +173,9 @@ public static function createInputList(array $items, array $inputAttrs = NULL, a /** * @return Html */ - public static function createSelectBox(array $items, array $optionAttrs = NULL, $selected = NULL) + public static function createSelectBox(array $items, array $optionAttrs = null, $selected = null) { - if ($selected !== NULL) { + if ($selected !== null) { $optionAttrs['selected?'] = $selected; } list($optionAttrs, $optionTag) = self::prepareAttrs($optionAttrs, 'option'); @@ -191,7 +191,7 @@ public static function createSelectBox(array $items, array $optionAttrs = NULL, foreach ($subitems as $value => $caption) { $option->value = $value; foreach ($optionAttrs as $k => $v) { - $option->attrs[$k] = isset($v[$value]) ? $v[$value] : NULL; + $option->attrs[$k] = isset($v[$value]) ? $v[$value] : null; } if ($caption instanceof Html) { $caption = clone $caption; @@ -220,7 +220,7 @@ private static function prepareAttrs($attrs, $name) if ($p[1] === '?' || $p[1] === ':') { unset($attrs[$k], $attrs[$p[0]]); if ($p[1] === '?') { - $dynamic[$p[0]] = array_fill_keys((array) $v, TRUE); + $dynamic[$p[0]] = array_fill_keys((array) $v, true); } elseif (is_array($v) && $v) { $dynamic[$p[0]] = $v; } else { @@ -228,6 +228,6 @@ private static function prepareAttrs($attrs, $name) } } } - return [$dynamic, '<' . $name . Html::el(NULL, $attrs)->attributes()]; + return [$dynamic, '<' . $name . Html::el(null, $attrs)->attributes()]; } } diff --git a/src/Forms/ISubmitterControl.php b/src/Forms/ISubmitterControl.php index 0ab14e56b..31a997f3d 100644 --- a/src/Forms/ISubmitterControl.php +++ b/src/Forms/ISubmitterControl.php @@ -16,7 +16,7 @@ interface ISubmitterControl extends IControl /** * Gets the validation scope. Clicking the button validates only the controls within the specified scope. - * @return array|NULL + * @return array|null */ function getValidationScope(); } diff --git a/src/Forms/Rendering/DefaultFormRenderer.php b/src/Forms/Rendering/DefaultFormRenderer.php index 916aee5f6..badff3c9a 100644 --- a/src/Forms/Rendering/DefaultFormRenderer.php +++ b/src/Forms/Rendering/DefaultFormRenderer.php @@ -58,7 +58,7 @@ class DefaultFormRenderer implements Nette\Forms\IFormRenderer * @var array of HTML tags */ public $wrappers = [ 'form' => [ - 'container' => NULL, + 'container' => null, ], 'error' => [ @@ -79,14 +79,14 @@ class DefaultFormRenderer implements Nette\Forms\IFormRenderer 'pair' => [ 'container' => 'tr', '.required' => 'required', - '.optional' => NULL, - '.odd' => NULL, - '.error' => NULL, + '.optional' => null, + '.odd' => null, + '.error' => null, ], 'control' => [ 'container' => 'td', - '.odd' => NULL, + '.odd' => null, 'description' => 'small', 'requiredsuffix' => '', @@ -106,12 +106,12 @@ class DefaultFormRenderer implements Nette\Forms\IFormRenderer 'label' => [ 'container' => 'th', - 'suffix' => NULL, + 'suffix' => null, 'requiredsuffix' => '', ], 'hidden' => [ - 'container' => NULL, + 'container' => null, ], ]; @@ -128,7 +128,7 @@ class DefaultFormRenderer implements Nette\Forms\IFormRenderer * @param string 'begin', 'errors', 'ownerrors', 'body', 'end' or empty to render all * @return string */ - public function render(Nette\Forms\Form $form, $mode = NULL) + public function render(Nette\Forms\Form $form, $mode = null) { if ($this->form !== $form) { $this->form = $form; @@ -142,7 +142,7 @@ public function render(Nette\Forms\Form $form, $mode = NULL) $s .= $this->renderErrors(); } elseif ($mode === 'errors') { - $s .= $this->renderErrors(NULL, FALSE); + $s .= $this->renderErrors(null, false); } if (!$mode || $mode === 'body') { $s .= $this->renderBody(); @@ -163,7 +163,7 @@ public function renderBegin() $this->counter = 0; foreach ($this->form->getControls() as $control) { - $control->setOption('rendered', FALSE); + $control->setOption('rendered', false); } if ($this->form->isMethod('get')) { @@ -198,7 +198,7 @@ public function renderEnd() $s .= $control->getControl(); } } - if (iterator_count($this->form->getComponents(TRUE, Nette\Forms\Controls\TextInput::class)) < 2) { + if (iterator_count($this->form->getComponents(true, Nette\Forms\Controls\TextInput::class)) < 2) { $s .= ''; } if ($s) { @@ -213,10 +213,10 @@ public function renderEnd() * Renders validation errors (per form or per control). * @return string */ - public function renderErrors(Nette\Forms\IControl $control = NULL, $own = TRUE) + public function renderErrors(Nette\Forms\IControl $control = null, $own = true) { $translator = $control - ? ($control instanceof \Nette\Forms\Controls\BaseControl ? $control->getTranslator() : NULL) + ? ($control instanceof \Nette\Forms\Controls\BaseControl ? $control->getTranslator() : null) : $this->form->getTranslator(); $errors = $control @@ -271,8 +271,8 @@ public function renderBody() if ($text instanceof IHtmlString) { $s .= $this->getWrapper('group label')->addHtml($text); - } elseif ($text != NULL) { // intentionally == - if ($translator !== NULL) { + } elseif ($text != null) { // intentionally == + if ($translator !== null) { $text = $translator->translate($text); } $s .= "\n" . $this->getWrapper('group label')->setText($text) . "\n"; @@ -282,8 +282,8 @@ public function renderBody() if ($text instanceof IHtmlString) { $s .= $text; - } elseif ($text != NULL) { // intentionally == - if ($translator !== NULL) { + } elseif ($text != null) { // intentionally == + if ($translator !== null) { $text = $translator->translate($text); } $s .= $this->getWrapper('group description')->setText($text) . "\n"; @@ -319,9 +319,9 @@ public function renderControls($parent) $container = $this->getWrapper('controls container'); - $buttons = NULL; + $buttons = null; foreach ($parent->getControls() as $control) { - if ($control->getOption('rendered') || $control->getOption('type') === 'hidden' || $control->getForm(FALSE) !== $this->form) { + if ($control->getOption('rendered') || $control->getOption('type') === 'hidden' || $control->getForm(false) !== $this->form) { // skip } elseif ($control->getOption('type') === 'button') { @@ -330,7 +330,7 @@ public function renderControls($parent) } else { if ($buttons) { $container->addHtml($this->renderPairMulti($buttons)); - $buttons = NULL; + $buttons = null; } $container->addHtml($this->renderPair($control)); } @@ -358,11 +358,11 @@ public function renderPair(Nette\Forms\IControl $control) $pair = $this->getWrapper('pair container'); $pair->addHtml($this->renderLabel($control)); $pair->addHtml($this->renderControl($control)); - $pair->class($this->getValue($control->isRequired() ? 'pair .required' : 'pair .optional'), TRUE); - $pair->class($control->hasErrors() ? $this->getValue('pair .error') : NULL, TRUE); - $pair->class($control->getOption('class'), TRUE); + $pair->class($this->getValue($control->isRequired() ? 'pair .required' : 'pair .optional'), true); + $pair->class($control->hasErrors() ? $this->getValue('pair .error') : null, true); + $pair->class($control->getOption('class'), true); if (++$this->counter % 2) { - $pair->class($this->getValue('pair .odd'), TRUE); + $pair->class($this->getValue('pair .odd'), true); } $pair->id = $control->getOption('id'); return $pair->render(0); @@ -385,7 +385,7 @@ public function renderPairMulti(array $controls) if ($description instanceof IHtmlString) { $description = ' ' . $description; - } elseif ($description != NULL) { // intentionally == + } elseif ($description != null) { // intentionally == if ($control instanceof Nette\Forms\Controls\BaseControl) { $description = $control->translate($description); } @@ -395,10 +395,10 @@ public function renderPairMulti(array $controls) $description = ''; } - $control->setOption('rendered', TRUE); + $control->setOption('rendered', true); $el = $control->getControl(); if ($el instanceof Html && $el->getName() === 'input') { - $el->class($this->getValue("control .$el->type"), TRUE); + $el->class($this->getValue("control .$el->type"), true); } $s[] = $el . $description; } @@ -420,9 +420,9 @@ public function renderLabel(Nette\Forms\IControl $control) if ($label instanceof Html) { $label->addHtml($suffix); if ($control->isRequired()) { - $label->class($this->getValue('control .required'), TRUE); + $label->class($this->getValue('control .required'), true); } - } elseif ($label != NULL) { // @intentionally == + } elseif ($label != null) { // @intentionally == $label .= $suffix; } return $this->getWrapper('label container')->setHtml($label); @@ -437,14 +437,14 @@ public function renderControl(Nette\Forms\IControl $control) { $body = $this->getWrapper('control container'); if ($this->counter % 2) { - $body->class($this->getValue('control .odd'), TRUE); + $body->class($this->getValue('control .odd'), true); } $description = $control->getOption('description'); if ($description instanceof IHtmlString) { $description = ' ' . $description; - } elseif ($description != NULL) { // intentionally == + } elseif ($description != null) { // intentionally == if ($control instanceof Nette\Forms\Controls\BaseControl) { $description = $control->translate($description); } @@ -458,10 +458,10 @@ public function renderControl(Nette\Forms\IControl $control) $description = $this->getValue('control requiredsuffix') . $description; } - $control->setOption('rendered', TRUE); + $control->setOption('rendered', true); $el = $control->getControl(); if ($el instanceof Html && $el->getName() === 'input') { - $el->class($this->getValue("control .$el->type"), TRUE); + $el->class($this->getValue("control .$el->type"), true); } return $body->setHtml($el . $description . $this->renderErrors($control)); } diff --git a/src/Forms/Rule.php b/src/Forms/Rule.php index 8b32fdbab..09464e17f 100644 --- a/src/Forms/Rule.php +++ b/src/Forms/Rule.php @@ -27,7 +27,7 @@ class Rule public $arg; /** @var bool */ - public $isNegative = FALSE; + public $isNegative = false; /** @var string */ public $message; diff --git a/src/Forms/Rules.php b/src/Forms/Rules.php index df968ffea..ca6fbcf6a 100644 --- a/src/Forms/Rules.php +++ b/src/Forms/Rules.php @@ -20,7 +20,7 @@ class Rules implements \IteratorAggregate /** @deprecated */ public static $defaultMessages; - /** @var Rule|FALSE|NULL */ + /** @var Rule|false|null */ private $required; /** @var Rule[] */ @@ -47,12 +47,12 @@ public function __construct(IControl $control) * @param mixed state or error message * @return static */ - public function setRequired($value = TRUE) + public function setRequired($value = true) { if ($value) { - $this->addRule(Form::REQUIRED, $value === TRUE ? NULL : $value); + $this->addRule(Form::REQUIRED, $value === true ? null : $value); } else { - $this->required = FALSE; + $this->required = false; } return $this; } @@ -73,7 +73,7 @@ public function isRequired() */ public function isOptional() { - return $this->required === FALSE; + return $this->required === false; } @@ -84,7 +84,7 @@ public function isOptional() * @param mixed * @return static */ - public function addRule($validator, $errorMessage = NULL, $arg = NULL) + public function addRule($validator, $errorMessage = null, $arg = null) { if ($validator === Form::VALID || $validator === ~Form::VALID) { throw new Nette\InvalidArgumentException('You cannot use Form::VALID in the addRule method.'); @@ -110,7 +110,7 @@ public function addRule($validator, $errorMessage = NULL, $arg = NULL) * @param mixed * @return static new branch */ - public function addCondition($validator, $arg = NULL) + public function addCondition($validator, $arg = null) { if ($validator === Form::VALID || $validator === ~Form::VALID) { throw new Nette\InvalidArgumentException('You cannot use Form::VALID in the addCondition method.'); @@ -129,7 +129,7 @@ public function addCondition($validator, $arg = NULL) * @param mixed * @return static new branch */ - public function addConditionOn(IControl $control, $validator, $arg = NULL) + public function addConditionOn(IControl $control, $validator, $arg = null) { $rule = new Rule; $rule->control = $control; @@ -181,7 +181,7 @@ public function addFilter($filter) $rule->control = $this->control; $rule->validator = function (IControl $control) use ($filter) { $control->setValue(call_user_func($filter, $control->getValue())); - return TRUE; + return true; }; return $this; } @@ -193,7 +193,7 @@ public function addFilter($filter) * @param bool * @return static */ - public function toggle($id, $hide = TRUE) + public function toggle($id, $hide = true) { $this->toggles[$id] = $hide; return $this; @@ -204,7 +204,7 @@ public function toggle($id, $hide = TRUE) * @param bool * @return array */ - public function getToggles($actual = FALSE) + public function getToggles($actual = false) { return $actual ? $this->getToggleStates() : $this->toggles; } @@ -214,7 +214,7 @@ public function getToggles($actual = FALSE) * @internal * @return array */ - public function getToggleStates($toggles = [], $success = TRUE) + public function getToggleStates($toggles = [], $success = true) { foreach ($this->toggles as $id => $hide) { $toggles[$id] = ($success xor !$hide) || !empty($toggles[$id]); @@ -233,7 +233,7 @@ public function getToggleStates($toggles = [], $success = TRUE) * Validates against ruleset. * @return bool */ - public function validate($emptyOptional = FALSE) + public function validate($emptyOptional = false) { $emptyOptional = $emptyOptional || $this->isOptional() && !$this->control->isFilled(); foreach ($this as $rule) { @@ -242,15 +242,15 @@ public function validate($emptyOptional = FALSE) } $success = $this->validateRule($rule); - if ($success && $rule->branch && !$rule->branch->validate($rule->validator === Form::BLANK ? FALSE : $emptyOptional)) { - return FALSE; + if ($success && $rule->branch && !$rule->branch->validate($rule->validator === Form::BLANK ? false : $emptyOptional)) { + return false; } elseif (!$success && !$rule->branch) { - $rule->control->addError(Validator::formatMessage($rule, TRUE)); - return FALSE; + $rule->control->addError(Validator::formatMessage($rule, true)); + return false; } } - return TRUE; + return true; } @@ -259,19 +259,19 @@ public function validate($emptyOptional = FALSE) */ public function check() { - if ($this->required !== NULL) { + if ($this->required !== null) { return; } foreach ($this->rules as $rule) { if ($rule->control === $this->control && ($rule->validator === Form::FILLED || $rule->validator === Form::BLANK)) { // ignore } elseif ($rule->branch) { - if ($rule->branch->check() === TRUE) { - return TRUE; + if ($rule->branch->check() === true) { + return true; } } else { - trigger_error("Missing setRequired(TRUE | FALSE) on field '{$rule->control->getName()}' in form '{$rule->control->getForm()->getName()}'.", E_USER_WARNING); - return TRUE; + trigger_error("Missing setRequired(true | false) on field '{$rule->control->getName()}' in form '{$rule->control->getForm()->getName()}'.", E_USER_WARNING); + return true; } } } @@ -313,7 +313,7 @@ public function getIterator() private function adjustOperation(Rule $rule) { if (is_string($rule->validator) && ord($rule->validator[0]) > 127) { - $rule->isNegative = TRUE; + $rule->isNegative = true; $rule->validator = ~$rule->validator; if (!$rule->branch) { $name = strncmp($rule->validator, ':', 1) ? $rule->validator : 'Form:' . strtoupper($rule->validator); @@ -321,7 +321,7 @@ private function adjustOperation(Rule $rule) } if ($rule->validator === Form::FILLED) { $rule->validator = Form::BLANK; - $rule->isNegative = FALSE; + $rule->isNegative = false; trigger_error('Replace negative validation rule ~Form::FILLED with Form::BLANK.', E_USER_DEPRECATED); } } diff --git a/src/Forms/Validator.php b/src/Forms/Validator.php index 3997b8d7f..5a725338f 100644 --- a/src/Forms/Validator.php +++ b/src/Forms/Validator.php @@ -46,28 +46,28 @@ class Validator /** @internal */ - public static function formatMessage(Rule $rule, $withValue = TRUE) + public static function formatMessage(Rule $rule, $withValue = true) { $message = $rule->message; if ($message instanceof Nette\Utils\IHtmlString) { return $message; - } elseif ($message === NULL && is_string($rule->validator) && isset(static::$messages[$rule->validator])) { + } elseif ($message === null && is_string($rule->validator) && isset(static::$messages[$rule->validator])) { $message = static::$messages[$rule->validator]; - } elseif ($message == NULL) { // intentionally == + } elseif ($message == null) { // intentionally == trigger_error("Missing validation message for control '{$rule->control->getName()}'.", E_USER_WARNING); } if ($translator = $rule->control->getForm()->getTranslator()) { - $message = $translator->translate($message, is_int($rule->arg) ? $rule->arg : NULL); + $message = $translator->translate($message, is_int($rule->arg) ? $rule->arg : null); } $message = preg_replace_callback('#%(name|label|value|\d+\$[ds]|[ds])#', function ($m) use ($rule, $withValue) { static $i = -1; switch ($m[1]) { case 'name': return $rule->control->getName(); - case 'label': return $rule->control instanceof Controls\BaseControl ? $rule->control->translate($rule->control->caption) : NULL; + case 'label': return $rule->control instanceof Controls\BaseControl ? $rule->control->translate($rule->control->caption) : null; case 'value': return $withValue ? $rule->control->getValue() : $m[0]; default: $args = is_array($rule->arg) ? $rule->arg : [$rule->arg]; @@ -95,9 +95,9 @@ public static function validateEqual(IControl $control, $arg) continue 2; } } - return FALSE; + return false; } - return TRUE; + return true; } @@ -160,7 +160,7 @@ public static function validateValid(Controls\BaseControl $control) public static function validateRange(IControl $control, $range) { $range = array_map(function ($v) { - return $v === '' ? NULL : $v; + return $v === '' ? null : $v; }, $range); return Validators::isInRange($control->getValue(), $range); } @@ -174,7 +174,7 @@ public static function validateRange(IControl $control, $range) */ public static function validateMin(IControl $control, $minimum) { - return Validators::isInRange($control->getValue(), [$minimum === '' ? NULL : $minimum, NULL]); + return Validators::isInRange($control->getValue(), [$minimum === '' ? null : $minimum, null]); } @@ -186,7 +186,7 @@ public static function validateMin(IControl $control, $minimum) */ public static function validateMax(IControl $control, $maximum) { - return Validators::isInRange($control->getValue(), [NULL, $maximum === '' ? NULL : $maximum]); + return Validators::isInRange($control->getValue(), [null, $maximum === '' ? null : $maximum]); } @@ -214,7 +214,7 @@ public static function validateLength(IControl $control, $range) */ public static function validateMinLength(IControl $control, $length) { - return static::validateLength($control, [$length, NULL]); + return static::validateLength($control, [$length, null]); } @@ -226,7 +226,7 @@ public static function validateMinLength(IControl $control, $length) */ public static function validateMaxLength(IControl $control, $length) { - return static::validateLength($control, [NULL, $length]); + return static::validateLength($control, [null, $length]); } @@ -257,13 +257,13 @@ public static function validateEmail(IControl $control) public static function validateUrl(IControl $control) { if (Validators::isUrl($value = $control->getValue())) { - return TRUE; + return true; } elseif (Validators::isUrl($value = "http://$value")) { $control->setValue($value); - return TRUE; + return true; } - return FALSE; + return false; } @@ -288,9 +288,9 @@ public static function validateInteger(IControl $control) if (!is_float($tmp = $value * 1)) { // bigint leave as string $control->setValue($tmp); } - return TRUE; + return true; } - return FALSE; + return false; } @@ -303,9 +303,9 @@ public static function validateFloat(IControl $control) $value = str_replace([' ', ','], ['', '.'], $control->getValue()); if (Validators::isNumeric($value)) { $control->setValue((float) $value); - return TRUE; + return true; } - return FALSE; + return false; } @@ -318,10 +318,10 @@ public static function validateFileSize(Controls\UploadControl $control, $limit) { foreach (static::toArray($control->getValue()) as $file) { if ($file->getSize() > $limit || $file->getError() === UPLOAD_ERR_INI_SIZE) { - return FALSE; + return false; } } - return TRUE; + return true; } @@ -336,11 +336,11 @@ public static function validateMimeType(Controls\UploadControl $control, $mimeTy $mimeTypes = is_array($mimeType) ? $mimeType : explode(',', $mimeType); foreach (static::toArray($control->getValue()) as $file) { $type = strtolower($file->getContentType()); - if (!in_array($type, $mimeTypes, TRUE) && !in_array(preg_replace('#/.*#', '/*', $type), $mimeTypes, TRUE)) { - return FALSE; + if (!in_array($type, $mimeTypes, true) && !in_array(preg_replace('#/.*#', '/*', $type), $mimeTypes, true)) { + return false; } } - return TRUE; + return true; } @@ -352,10 +352,10 @@ public static function validateImage(Controls\UploadControl $control) { foreach (static::toArray($control->getValue()) as $file) { if (!$file->isImage()) { - return FALSE; + return false; } } - return TRUE; + return true; } diff --git a/tests/Forms.Latte/FormMacros.forms.phpt b/tests/Forms.Latte/FormMacros.forms.phpt index b69a24680..3697bd87f 100644 --- a/tests/Forms.Latte/FormMacros.forms.phpt +++ b/tests/Forms.Latte/FormMacros.forms.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; class MyControl extends Nette\Forms\Controls\BaseControl { - function getLabel($c = NULL) + function getLabel($c = null) { return ''; } @@ -31,8 +31,8 @@ $form = new Form; $form->addHidden('id'); $form->addText('username', 'Username:'); // must have just one textfield to generate IE fix $form->addRadioList('sex', 'Sex:', ['m' => 'male', 'f' => 'female']); -$form->addSelect('select', NULL, ['m' => 'male', 'f' => 'female']); -$form->addTextArea('area', NULL)->setValue('oneaddSelect('select', null, ['m' => 'male', 'f' => 'female']); +$form->addTextArea('area', null)->setValue('oneaddCheckbox('checkbox', 'Checkbox'); $form->addCheckboxList('checklist', 'CheckboxList:', ['m' => 'male', 'f' => 'female']); $form->addSubmit('send', 'Sign in'); diff --git a/tests/Forms.Latte/expected/FormMacros.button.phtml b/tests/Forms.Latte/expected/FormMacros.button.phtml index 85255c744..7a8baf182 100644 --- a/tests/Forms.Latte/expected/FormMacros.button.phtml +++ b/tests/Forms.Latte/expected/FormMacros.button.phtml @@ -3,7 +3,7 @@ $form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; ?>global->formsStack), array ( - ), FALSE) ?>> + ), false) ?>> global->formsStack)["send"]; echo $_input->getControlPart()->attributes() ?>> @@ -18,6 +18,6 @@ $_input = end($this->global->formsStack)["send"]; echo $_input->getControlPart()->attributes() ?>>caption) ?> global->formsStack), FALSE); + echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?> %A% diff --git a/tests/Forms.Latte/expected/FormMacros.forms.phtml b/tests/Forms.Latte/expected/FormMacros.forms.phtml index 63925763f..7f59824b9 100644 --- a/tests/Forms.Latte/expected/FormMacros.forms.phtml +++ b/tests/Forms.Latte/expected/FormMacros.forms.phtml @@ -190,12 +190,12 @@ echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), array ( 'id' => NULL, 'class' => NULL, - ), FALSE) ?>> + ), false) ?>> global->formsStack)["username"]; echo $_input->getControlPart()->attributes() ?>> global->formsStack), FALSE); + echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?> global->formsStack[] = is_object($this->global->uiControl['myForm']) ? $this->global->uiControl['myForm'] : $this->global->uiControl[$this->global->uiControl['myForm']]; ?>global->formsStack), array ( - ), FALSE) ?>> + ), false) ?>> global->formsStack)["username"]; echo $_input->getControlPart()->attributes() ?>> global->formsStack), FALSE); + echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?> diff --git a/tests/Forms.Latte/expected/FormMacros.get.phtml b/tests/Forms.Latte/expected/FormMacros.get.phtml index 56285d782..98454dcc7 100644 --- a/tests/Forms.Latte/expected/FormMacros.get.phtml +++ b/tests/Forms.Latte/expected/FormMacros.get.phtml @@ -9,8 +9,8 @@ $form = $_form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; ?>global->formsStack), array ( - ), FALSE) ?>> + ), false) ?>> global->formsStack), FALSE); + echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?> %A% diff --git a/tests/Forms/Container.validate().phpt b/tests/Forms/Container.validate().phpt index 61ae8af54..7a2773c26 100644 --- a/tests/Forms/Container.validate().phpt +++ b/tests/Forms/Container.validate().phpt @@ -36,6 +36,6 @@ Assert::same([ Assert::exception(function () { $form = new Form; - $form->onValidate = TRUE; + $form->onValidate = true; $form->validate(); }, Nette\UnexpectedValueException::class, 'Property Form::$onValidate must be array or Traversable, boolean given.'); diff --git a/tests/Forms/Container.values.phpt b/tests/Forms/Container.values.phpt index 5ef2a7109..89890d79d 100644 --- a/tests/Forms/Container.values.phpt +++ b/tests/Forms/Container.values.phpt @@ -23,7 +23,7 @@ $_POST = [ 'name' => 'david', ], ], - 'invalid' => TRUE, + 'invalid' => true, ]; diff --git a/tests/Forms/Controls.BaseControl.phpt b/tests/Forms/Controls.BaseControl.phpt index 8245be901..99a826f34 100644 --- a/tests/Forms/Controls.BaseControl.phpt +++ b/tests/Forms/Controls.BaseControl.phpt @@ -45,7 +45,7 @@ test(function () { // validators Assert::true(Validator::validateFilled($input)); Assert::true(Validator::validateValid($input)); - Assert::false(Validator::validateLength($input, NULL)); + Assert::false(Validator::validateLength($input, null)); Assert::false(Validator::validateLength($input, 2)); Assert::true(Validator::validateLength($input, 3)); @@ -55,9 +55,9 @@ test(function () { // validators Assert::true(Validator::validateMaxLength($input, 3)); Assert::false(Validator::validateMaxLength($input, 2)); - Assert::false(Validator::validateRange($input, [NULL, NULL])); + Assert::false(Validator::validateRange($input, [null, null])); Assert::true(Validator::validateRange($input, [100, 1000])); - Assert::false(Validator::validateRange($input, [1000, NULL])); + Assert::false(Validator::validateRange($input, [1000, null])); Assert::true(Validator::validateMin($input, 122)); Assert::true(Validator::validateMin($input, 123)); @@ -71,7 +71,7 @@ test(function () { // validators test(function () { // validators for array $form = new Form; - $input = $form->addMultiSelect('select', NULL, ['a', 'b', 'c', 'd']); + $input = $form->addMultiSelect('select', null, ['a', 'b', 'c', 'd']); $input->setValue([1, 2, 3]); Assert::true(Validator::validateEqual($input, [1, 2, 3, 4])); @@ -81,7 +81,7 @@ test(function () { // validators for array Assert::true(Validator::validateFilled($input)); Assert::true(Validator::validateValid($input)); - Assert::false(Validator::validateLength($input, NULL)); + Assert::false(Validator::validateLength($input, null)); Assert::false(Validator::validateLength($input, 2)); Assert::true(Validator::validateLength($input, 3)); diff --git a/tests/Forms/Controls.Button.render.phpt b/tests/Forms/Controls.Button.render.phpt index 9135be760..d02cf0ac6 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -82,7 +82,7 @@ test(function () { // SubmitButton test(function () { // SubmitButton with scope $form = new Form; - $input = $form->addSubmit('button', 'Caption')->setValidationScope(FALSE); + $input = $form->addSubmit('button', 'Caption')->setValidationScope(false); Assert::same('', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.Checkbox.loadData.phpt b/tests/Forms/Controls.Checkbox.loadData.phpt index f9919dea5..394319dac 100644 --- a/tests/Forms/Controls.Checkbox.loadData.phpt +++ b/tests/Forms/Controls.Checkbox.loadData.phpt @@ -37,7 +37,7 @@ test(function () { test(function () { // malformed data - $_POST = ['malformed' => [NULL]]; + $_POST = ['malformed' => [null]]; $form = new Form; $input = $form->addCheckbox('malformed'); @@ -50,9 +50,9 @@ test(function () { // malformed data test(function () { // setValue() and invalid argument $form = new Form; $input = $form->addCheckbox('checkbox'); - $input->setValue(NULL); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue([]); - }, Nette\InvalidArgumentException::class, "Value must be scalar or NULL, array given in field 'checkbox'."); + }, Nette\InvalidArgumentException::class, "Value must be scalar or null, array given in field 'checkbox'."); }); diff --git a/tests/Forms/Controls.Checkbox.render.phpt b/tests/Forms/Controls.Checkbox.render.phpt index c60cacad4..2bc746cdc 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -36,7 +36,7 @@ test(function () { Assert::type(Html::class, $input->getControlPart()); Assert::same('', (string) $input->getControlPart()); - $input->setValue(TRUE); + $input->setValue(true); Assert::same('', (string) $input->getControl()); Assert::same('', (string) $input->getControlPart()); }); diff --git a/tests/Forms/Controls.CheckboxList.loadData.phpt b/tests/Forms/Controls.CheckboxList.loadData.phpt index 29274ef2c..d9be6ccea 100644 --- a/tests/Forms/Controls.CheckboxList.loadData.phpt +++ b/tests/Forms/Controls.CheckboxList.loadData.phpt @@ -31,7 +31,7 @@ test(function () use ($series) { // invalid input $_POST = ['list' => 'red-dwarf']; $form = new Form; - $input = $form->addCheckboxList('list', NULL, $series); + $input = $form->addCheckboxList('list', null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -44,7 +44,7 @@ test(function () use ($series) { // multiple selected items, zero item $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form->addCheckboxList('multi', NULL, $series); + $input = $form->addCheckboxList('multi', null, $series); Assert::true($form->isValid()); Assert::same(['red-dwarf', 0], $input->getValue()); @@ -58,7 +58,7 @@ test(function () use ($series) { // empty key $_POST = ['empty' => ['']]; $form = new Form; - $input = $form->addCheckboxList('empty', NULL, $series); + $input = $form->addCheckboxList('empty', null, $series); Assert::true($form->isValid()); Assert::same([''], $input->getValue()); @@ -69,7 +69,7 @@ test(function () use ($series) { // empty key test(function () use ($series) { // missing key $form = new Form; - $input = $form->addCheckboxList('missing', NULL, $series); + $input = $form->addCheckboxList('missing', null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -82,7 +82,7 @@ test(function () use ($series) { // disabled key $_POST = ['disabled' => 'red-dwarf']; $form = new Form; - $input = $form->addCheckboxList('disabled', NULL, $series) + $input = $form->addCheckboxList('disabled', null, $series) ->setDisabled(); Assert::true($form->isValid()); @@ -91,10 +91,10 @@ test(function () use ($series) { // disabled key test(function () use ($series) { // malformed data - $_POST = ['malformed' => [[NULL]]]; + $_POST = ['malformed' => [[null]]]; $form = new Form; - $input = $form->addCheckboxList('malformed', NULL, $series); + $input = $form->addCheckboxList('malformed', null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -107,7 +107,7 @@ test(function () use ($series) { // validateLength $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form->addCheckboxList('multi', NULL, $series); + $input = $form->addCheckboxList('multi', null, $series); Assert::true(Validator::validateLength($input, 2)); Assert::false(Validator::validateLength($input, 3)); @@ -120,7 +120,7 @@ test(function () use ($series) { // validateEqual $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form->addCheckboxList('multi', NULL, $series); + $input = $form->addCheckboxList('multi', null, $series); Assert::true(Validator::validateEqual($input, ['red-dwarf', 0])); Assert::false(Validator::validateEqual($input, 'unknown')); @@ -131,8 +131,8 @@ test(function () use ($series) { // validateEqual test(function () use ($series) { // setValue() and invalid argument $form = new Form; - $input = $form->addCheckboxList('list', NULL, $series); - $input->setValue(NULL); + $input = $form->addCheckboxList('list', null, $series); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue('unknown'); @@ -142,7 +142,7 @@ test(function () use ($series) { // setValue() and invalid argument test(function () { // object as value $form = new Form; - $input = $form->addCheckboxList('list', NULL, ['2013-07-05 00:00:00' => 1]) + $input = $form->addCheckboxList('list', null, ['2013-07-05 00:00:00' => 1]) ->setValue([new DateTime('2013-07-05')]); Assert::same(['2013-07-05 00:00:00'], $input->getValue()); @@ -152,7 +152,7 @@ test(function () { // object as value test(function () { // object as item $form = new Form; $input = $form->addCheckboxList('list') - ->setItems([new DateTime('2013-07-05')], FALSE) + ->setItems([new DateTime('2013-07-05')], false) ->setValue('2013-07-05 00:00:00'); Assert::equal(['2013-07-05 00:00:00' => new DateTime('2013-07-05')], $input->getSelectedItems()); @@ -163,13 +163,13 @@ test(function () use ($series) { // disabled one $_POST = ['list' => ['red-dwarf', 0]]; $form = new Form; - $input = $form->addCheckboxList('list', NULL, $series) + $input = $form->addCheckboxList('list', null, $series) ->setDisabled(['red-dwarf']); Assert::same([0], $input->getValue()); unset($form['list']); - $input = new Nette\Forms\Controls\CheckboxList(NULL, $series); + $input = new Nette\Forms\Controls\CheckboxList(null, $series); $input->setDisabled(['red-dwarf']); $form['list'] = $input; diff --git a/tests/Forms/Controls.CheckboxList.render.phpt b/tests/Forms/Controls.CheckboxList.render.phpt index 8e6f8e4d6..fbf4c5e19 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -112,7 +112,7 @@ test(function () { // container test(function () { // separator prototype $form = new Form; - $input = $form->addCheckboxList('list', NULL, [ + $input = $form->addCheckboxList('list', null, [ 'a' => 'b', ]); $input->getSeparatorPrototype()->setName('div'); @@ -126,7 +126,7 @@ test(function () { // disabled all $input = $form->addCheckboxList('list', 'Label', [ 'a' => 'First', 0 => 'Second', - ])->setDisabled(TRUE); + ])->setDisabled(true); Assert::same('
', (string) $input->getControl()); }); @@ -157,7 +157,7 @@ test(function () { // numeric key as string & getControlPart test(function () { // container prototype $form = new Form; - $input = $form->addCheckboxList('list', NULL, [ + $input = $form->addCheckboxList('list', null, [ 'a' => 'b', ]); $input->getSeparatorPrototype()->setName('hr'); @@ -181,7 +181,7 @@ test(function () { // rendering options test(function () { // item label prototype $form = new Form; - $input = $form->addCheckboxList('list', NULL, [ + $input = $form->addCheckboxList('list', null, [ 'a' => 'b', ]); $input->getItemLabelPrototype()->class('foo'); @@ -194,7 +194,7 @@ test(function () { // item label prototype test(function () { // item label prototype (back compatiblity) $form = new Form; - $input = $form->addCheckboxList('list', NULL, [ + $input = $form->addCheckboxList('list', null, [ 'a' => 'b', ]); $input->getLabelPrototype()->class('foo'); diff --git a/tests/Forms/Controls.ChoiceControl.loadData.phpt b/tests/Forms/Controls.ChoiceControl.loadData.phpt index 0fd7059fb..11ae394fb 100644 --- a/tests/Forms/Controls.ChoiceControl.loadData.phpt +++ b/tests/Forms/Controls.ChoiceControl.loadData.phpt @@ -35,7 +35,7 @@ test(function () use ($series) { // Select $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL, $series); + $input = $form['select'] = new ChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same('red-dwarf', $input->getValue()); @@ -48,7 +48,7 @@ test(function () use ($series) { // Select with invalid input $_POST = ['select' => 'days-of-our-lives']; $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL, $series); + $input = $form['select'] = new ChoiceControl(null, $series); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -61,7 +61,7 @@ test(function () use ($series) { // Indexed arrays $_POST = ['zero' => 0]; $form = new Form; - $input = $form['zero'] = new ChoiceControl(NULL, $series); + $input = $form['zero'] = new ChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same(0, $input->getValue()); @@ -75,7 +75,7 @@ test(function () use ($series) { // empty key $_POST = ['empty' => '']; $form = new Form; - $input = $form['empty'] = new ChoiceControl(NULL, $series); + $input = $form['empty'] = new ChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same('', $input->getValue()); @@ -86,7 +86,7 @@ test(function () use ($series) { // empty key test(function () use ($series) { // missing key $form = new Form; - $input = $form['missing'] = new ChoiceControl(NULL, $series); + $input = $form['missing'] = new ChoiceControl(null, $series); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -99,7 +99,7 @@ test(function () use ($series) { // disabled key $_POST = ['disabled' => 'red-dwarf']; $form = new Form; - $input = $form['disabled'] = new ChoiceControl(NULL, $series); + $input = $form['disabled'] = new ChoiceControl(null, $series); $input->setDisabled(); Assert::true($form->isValid()); @@ -109,10 +109,10 @@ test(function () use ($series) { // disabled key test(function () use ($series) { // malformed data - $_POST = ['malformed' => [NULL]]; + $_POST = ['malformed' => [null]]; $form = new Form; - $input = $form['malformed'] = new ChoiceControl(NULL, $series); + $input = $form['malformed'] = new ChoiceControl(null, $series); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -126,7 +126,7 @@ test(function () use ($series) { // setItems without keys $form = new Form; $input = $form['select'] = new ChoiceControl; - $input->setItems(array_keys($series), FALSE); + $input->setItems(array_keys($series), false); Assert::same([ 'red-dwarf' => 'red-dwarf', 'the-simpsons' => 'the-simpsons', @@ -143,8 +143,8 @@ test(function () use ($series) { // setItems without keys test(function () use ($series) { // setValue() and invalid argument $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL, $series); - $input->setValue(NULL); + $input = $form['select'] = new ChoiceControl(null, $series); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue('unknown'); @@ -154,8 +154,8 @@ test(function () use ($series) { // setValue() and invalid argument test(function () use ($series) { // setValue() and disabled $checkAllowedValues $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL, $series); - $input->checkAllowedValues = FALSE; + $input = $form['select'] = new ChoiceControl(null, $series); + $input->checkAllowedValues = false; $input->setValue('unknown'); Assert::null($input->getValue()); }); @@ -163,7 +163,7 @@ test(function () use ($series) { // setValue() and disabled $checkAllowedValues test(function () { // object as value $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL, ['2013-07-05 00:00:00' => 1]); + $input = $form['select'] = new ChoiceControl(null, ['2013-07-05 00:00:00' => 1]); $input->setValue(new DateTime('2013-07-05')); Assert::same('2013-07-05 00:00:00', $input->getValue()); @@ -173,7 +173,7 @@ test(function () { // object as value test(function () { // object as item $form = new Form; $input = $form['select'] = new ChoiceControl; - $input->setItems([new DateTime('2013-07-05')], FALSE) + $input->setItems([new DateTime('2013-07-05')], false) ->setValue(new DateTime('2013-07-05')); Assert::same('2013-07-05 00:00:00', $input->getValue()); @@ -184,13 +184,13 @@ test(function () use ($series) { // disabled one $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL, $series); + $input = $form['select'] = new ChoiceControl(null, $series); $input->setDisabled(['red-dwarf']); Assert::null($input->getValue()); unset($form['select']); - $input = new ChoiceControl(NULL, $series); + $input = new ChoiceControl(null, $series); $input->setDisabled(['red-dwarf']); $form['select'] = $input; @@ -201,9 +201,9 @@ test(function () { $_POST = ['select' => 1]; $form = new Form; - $input = $form['select'] = new ChoiceControl(NULL); + $input = $form['select'] = new ChoiceControl(null); $input->setItems([ - 1 => NULL, + 1 => null, 2 => 'Red dwarf', ]); diff --git a/tests/Forms/Controls.CsrfProtection.breachAttack.phpt b/tests/Forms/Controls.CsrfProtection.breachAttack.phpt index e1fae299c..85c6b6bab 100644 --- a/tests/Forms/Controls.CsrfProtection.breachAttack.phpt +++ b/tests/Forms/Controls.CsrfProtection.breachAttack.phpt @@ -31,13 +31,13 @@ for ($a = 0; $a < $charCount; $a++) { for ($i = 3; $i <= strlen($token); $i++) { $code = (string) $input->getControl(); - $shortest = NULL; + $shortest = null; $adepts = []; foreach ($strings as $string) { for ($j = 0; $j < $charCount; $j++) { $try = $string . $charlist[$j]; $length = strlen(gzdeflate($code . $try)); - if ($shortest === NULL || $length < $shortest) { + if ($shortest === null || $length < $shortest) { $shortest = $length; $adepts = []; } diff --git a/tests/Forms/Controls.CsrfProtection.phpt b/tests/Forms/Controls.CsrfProtection.phpt index 5c239a636..0d6737367 100644 --- a/tests/Forms/Controls.CsrfProtection.phpt +++ b/tests/Forms/Controls.CsrfProtection.phpt @@ -27,7 +27,7 @@ Assert::match('', (string) $inpu Assert::true($input->getOption('rendered')); Assert::same('hidden', $input->getOption('type')); -$input->setValue(NULL); +$input->setValue(null); Assert::false(CsrfProtection::validateCsrf($input)); call_user_func([$input, 'Nette\Forms\Controls\BaseControl::setValue'], '12345678901234567890123456789012345678'); diff --git a/tests/Forms/Controls.HiddenField.loadData.phpt b/tests/Forms/Controls.HiddenField.loadData.phpt index 86779c090..ca3c8a6e7 100644 --- a/tests/Forms/Controls.HiddenField.loadData.phpt +++ b/tests/Forms/Controls.HiddenField.loadData.phpt @@ -35,7 +35,7 @@ test(function () { test(function () { // invalid data - $_POST = ['malformed' => [NULL]]; + $_POST = ['malformed' => [null]]; $form = new Form; $input = $form->addHidden('malformed'); Assert::same('', $input->getValue()); @@ -55,11 +55,11 @@ test(function () { // errors are moved to form test(function () { // setValue() and invalid argument $form = new Form; $input = $form->addHidden('hidden'); - $input->setValue(NULL); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue([]); - }, Nette\InvalidArgumentException::class, "Value must be scalar or NULL, array given in field 'hidden'."); + }, Nette\InvalidArgumentException::class, "Value must be scalar or null, array given in field 'hidden'."); }); diff --git a/tests/Forms/Controls.HiddenField.render.phpt b/tests/Forms/Controls.HiddenField.render.phpt index ca1204473..e0cb362c0 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) + function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.ImageButton.loadData.phpt b/tests/Forms/Controls.ImageButton.loadData.phpt index cb7fb24a6..bbceff44a 100644 --- a/tests/Forms/Controls.ImageButton.loadData.phpt +++ b/tests/Forms/Controls.ImageButton.loadData.phpt @@ -46,7 +46,7 @@ test(function () { // missing data test(function () { // malformed data $_POST = [ 'malformed1' => [1], - 'malformed2' => [[NULL]], + 'malformed2' => [[null]], ]; $form = new Form; diff --git a/tests/Forms/Controls.ImageButton.render.phpt b/tests/Forms/Controls.ImageButton.render.phpt index 92d5016ba..7451fe249 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) + function translate($s, $plural = null) { return strtoupper($s); } diff --git a/tests/Forms/Controls.MultiChoiceControl.loadData.phpt b/tests/Forms/Controls.MultiChoiceControl.loadData.phpt index 3ea783697..730093417 100644 --- a/tests/Forms/Controls.MultiChoiceControl.loadData.phpt +++ b/tests/Forms/Controls.MultiChoiceControl.loadData.phpt @@ -36,7 +36,7 @@ test(function () use ($series) { // invalid input $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form['select'] = new MultiChoiceControl(NULL, $series); + $input = $form['select'] = new MultiChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -49,7 +49,7 @@ test(function () use ($series) { // multiple selected items, zero item $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form['multi'] = new MultiChoiceControl(NULL, $series); + $input = $form['multi'] = new MultiChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same(['red-dwarf', 0], $input->getValue()); @@ -63,7 +63,7 @@ test(function () use ($series) { // empty key $_POST = ['empty' => ['']]; $form = new Form; - $input = $form['empty'] = new MultiChoiceControl(NULL, $series); + $input = $form['empty'] = new MultiChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same([''], $input->getValue()); @@ -74,7 +74,7 @@ test(function () use ($series) { // empty key test(function () use ($series) { // missing key $form = new Form; - $input = $form['missing'] = new MultiChoiceControl(NULL, $series); + $input = $form['missing'] = new MultiChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -87,7 +87,7 @@ test(function () use ($series) { // disabled key $_POST = ['disabled' => 'red-dwarf']; $form = new Form; - $input = $form['disabled'] = new MultiChoiceControl(NULL, $series); + $input = $form['disabled'] = new MultiChoiceControl(null, $series); $input->setDisabled(); Assert::true($form->isValid()); @@ -96,10 +96,10 @@ test(function () use ($series) { // disabled key test(function () use ($series) { // malformed data - $_POST = ['malformed' => [[NULL]]]; + $_POST = ['malformed' => [[null]]]; $form = new Form; - $input = $form['malformed'] = new MultiChoiceControl(NULL, $series); + $input = $form['malformed'] = new MultiChoiceControl(null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -113,7 +113,7 @@ test(function () use ($series) { // setItems without keys $form = new Form; $input = $form['multi'] = new MultiChoiceControl; - $input->setItems(array_keys($series), FALSE); + $input->setItems(array_keys($series), false); Assert::same([ 'red-dwarf' => 'red-dwarf', 'the-simpsons' => 'the-simpsons', @@ -132,7 +132,7 @@ test(function () use ($series) { // validateLength $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form['multi'] = new MultiChoiceControl(NULL, $series); + $input = $form['multi'] = new MultiChoiceControl(null, $series); Assert::true(Validator::validateLength($input, 2)); Assert::false(Validator::validateLength($input, 3)); @@ -145,7 +145,7 @@ test(function () use ($series) { // validateEqual $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form['multi'] = new MultiChoiceControl(NULL, $series); + $input = $form['multi'] = new MultiChoiceControl(null, $series); Assert::true(Validator::validateEqual($input, ['red-dwarf', 0])); Assert::false(Validator::validateEqual($input, 'unknown')); @@ -156,8 +156,8 @@ test(function () use ($series) { // validateEqual test(function () use ($series) { // setValue() and invalid argument $form = new Form; - $input = $form['select'] = new MultiChoiceControl(NULL, $series); - $input->setValue(NULL); + $input = $form['select'] = new MultiChoiceControl(null, $series); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue('unknown'); @@ -165,7 +165,7 @@ test(function () use ($series) { // setValue() and invalid argument Assert::exception(function () use ($input) { $input->setValue(new stdClass); - }, Nette\InvalidArgumentException::class, "Value must be array or NULL, object given in field 'select'."); + }, Nette\InvalidArgumentException::class, "Value must be array or null, object given in field 'select'."); Assert::exception(function () use ($input) { $input->setValue([new stdClass]); @@ -175,14 +175,14 @@ test(function () use ($series) { // setValue() and invalid argument test(function () use ($series) { // setValue() and disabled $checkAllowedValues $form = new Form; - $input = $form['select'] = new MultiChoiceControl(NULL, $series); - $input->checkAllowedValues = FALSE; + $input = $form['select'] = new MultiChoiceControl(null, $series); + $input->checkAllowedValues = false; $input->setValue('unknown'); Assert::same([], $input->getValue()); Assert::exception(function () use ($input) { $input->setValue(new stdClass); - }, Nette\InvalidArgumentException::class, "Value must be array or NULL, object given in field 'select'."); + }, Nette\InvalidArgumentException::class, "Value must be array or null, object given in field 'select'."); Assert::exception(function () use ($input) { $input->setValue([new stdClass]); @@ -192,7 +192,7 @@ test(function () use ($series) { // setValue() and disabled $checkAllowedValues test(function () { // object as value $form = new Form; - $input = $form['select'] = new MultiChoiceControl(NULL, ['2013-07-05 00:00:00' => 1]); + $input = $form['select'] = new MultiChoiceControl(null, ['2013-07-05 00:00:00' => 1]); $input->setValue([new DateTime('2013-07-05')]); Assert::same(['2013-07-05 00:00:00'], $input->getValue()); @@ -203,13 +203,13 @@ test(function () use ($series) { // disabled one $_POST = ['select' => ['red-dwarf', 0]]; $form = new Form; - $input = $form['select'] = new MultiChoiceControl(NULL, $series); + $input = $form['select'] = new MultiChoiceControl(null, $series); $input->setDisabled(['red-dwarf']); Assert::same([0], $input->getValue()); unset($form['select']); - $input = new Nette\Forms\Controls\MultiSelectBox(NULL, $series); + $input = new Nette\Forms\Controls\MultiSelectBox(null, $series); $input->setDisabled(['red-dwarf']); $form['select'] = $input; diff --git a/tests/Forms/Controls.MultiSelectBox.loadData.phpt b/tests/Forms/Controls.MultiSelectBox.loadData.phpt index b868ddd7d..dd0398906 100644 --- a/tests/Forms/Controls.MultiSelectBox.loadData.phpt +++ b/tests/Forms/Controls.MultiSelectBox.loadData.phpt @@ -31,7 +31,7 @@ test(function () use ($series) { // Select with optgroups $_POST = ['multi' => ['red-dwarf']]; $form = new Form; - $input = $form->addMultiSelect('multi', NULL, [ + $input = $form->addMultiSelect('multi', null, [ 'usa' => [ 'the-simpsons' => 'The Simpsons', 0 => 'South Park', @@ -52,7 +52,7 @@ test(function () use ($series) { // invalid input $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addMultiSelect('select', NULL, $series); + $input = $form->addMultiSelect('select', null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -65,7 +65,7 @@ test(function () use ($series) { // multiple selected items, zero item $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form->addMultiSelect('multi', NULL, $series); + $input = $form->addMultiSelect('multi', null, $series); Assert::true($form->isValid()); Assert::same(['red-dwarf', 0], $input->getValue()); @@ -79,7 +79,7 @@ test(function () use ($series) { // empty key $_POST = ['empty' => ['']]; $form = new Form; - $input = $form->addMultiSelect('empty', NULL, $series); + $input = $form->addMultiSelect('empty', null, $series); Assert::true($form->isValid()); Assert::same([''], $input->getValue()); @@ -90,7 +90,7 @@ test(function () use ($series) { // empty key test(function () use ($series) { // missing key $form = new Form; - $input = $form->addMultiSelect('missing', NULL, $series); + $input = $form->addMultiSelect('missing', null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -103,7 +103,7 @@ test(function () use ($series) { // disabled key $_POST = ['disabled' => 'red-dwarf']; $form = new Form; - $input = $form->addMultiSelect('disabled', NULL, $series) + $input = $form->addMultiSelect('disabled', null, $series) ->setDisabled(); Assert::true($form->isValid()); @@ -112,10 +112,10 @@ test(function () use ($series) { // disabled key test(function () use ($series) { // malformed data - $_POST = ['malformed' => [[NULL]]]; + $_POST = ['malformed' => [[null]]]; $form = new Form; - $input = $form->addMultiSelect('malformed', NULL, $series); + $input = $form->addMultiSelect('malformed', null, $series); Assert::true($form->isValid()); Assert::same([], $input->getValue()); @@ -128,7 +128,7 @@ test(function () use ($series) { // validateLength $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form->addMultiSelect('multi', NULL, $series); + $input = $form->addMultiSelect('multi', null, $series); Assert::true(Validator::validateLength($input, 2)); Assert::false(Validator::validateLength($input, 3)); @@ -141,7 +141,7 @@ test(function () use ($series) { // validateEqual $_POST = ['multi' => ['red-dwarf', 'unknown', 0]]; $form = new Form; - $input = $form->addMultiSelect('multi', NULL, $series); + $input = $form->addMultiSelect('multi', null, $series); Assert::true(Validator::validateEqual($input, ['red-dwarf', 0])); Assert::false(Validator::validateEqual($input, 'unknown')); @@ -154,7 +154,7 @@ test(function () use ($series) { // setItems without keys $_POST = ['multi' => ['red-dwarf']]; $form = new Form; - $input = $form->addMultiSelect('multi')->setItems(array_keys($series), FALSE); + $input = $form->addMultiSelect('multi')->setItems(array_keys($series), false); Assert::same([ 'red-dwarf' => 'red-dwarf', 'the-simpsons' => 'the-simpsons', @@ -171,7 +171,7 @@ test(function () use ($series) { // setItems without keys test(function () use ($series) { // setItems without keys $form = new Form; - $input = $form->addMultiSelect('select')->setItems(range(1, 5), FALSE); + $input = $form->addMultiSelect('select')->setItems(range(1, 5), false); Assert::same([1 => 1, 2, 3, 4, 5], $input->getItems()); }); @@ -183,7 +183,7 @@ test(function () { // setItems without keys with optgroups $input = $form->addMultiSelect('multi')->setItems([ 'usa' => ['the-simpsons', 0], 'uk' => ['red-dwarf'], - ], FALSE); + ], false); Assert::true($form->isValid()); Assert::same(['red-dwarf'], $input->getValue()); @@ -194,8 +194,8 @@ test(function () { // setItems without keys with optgroups test(function () use ($series) { // setValue() and invalid argument $form = new Form; - $input = $form->addMultiSelect('select', NULL, $series); - $input->setValue(NULL); + $input = $form->addMultiSelect('select', null, $series); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue('unknown'); @@ -205,7 +205,7 @@ test(function () use ($series) { // setValue() and invalid argument test(function () { // object as value $form = new Form; - $input = $form->addMultiSelect('select', NULL, ['2013-07-05 00:00:00' => 1]) + $input = $form->addMultiSelect('select', null, ['2013-07-05 00:00:00' => 1]) ->setValue([new DateTime('2013-07-05')]); Assert::same(['2013-07-05 00:00:00'], $input->getValue()); @@ -218,7 +218,7 @@ test(function () { // object as item ->setItems([ 'group' => [new DateTime('2013-07-05')], new DateTime('2013-07-06'), - ], FALSE) + ], false) ->setValue('2013-07-05 00:00:00'); Assert::equal(['2013-07-05 00:00:00' => new DateTime('2013-07-05')], $input->getSelectedItems()); @@ -229,13 +229,13 @@ test(function () use ($series) { // disabled one $_POST = ['select' => ['red-dwarf', 0]]; $form = new Form; - $input = $form->addMultiSelect('select', NULL, $series) + $input = $form->addMultiSelect('select', null, $series) ->setDisabled(['red-dwarf']); Assert::same([0], $input->getValue()); unset($form['select']); - $input = new Nette\Forms\Controls\MultiSelectBox(NULL, $series); + $input = new Nette\Forms\Controls\MultiSelectBox(null, $series); $input->setDisabled(['red-dwarf']); $form['select'] = $input; diff --git a/tests/Forms/Controls.MultiSelectBox.render.phpt b/tests/Forms/Controls.MultiSelectBox.render.phpt index e2a7efe97..d60ce3631 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -115,7 +115,7 @@ test(function () { // disabled all $input = $form->addMultiSelect('list', 'Label', [ 'a' => 'First', 0 => 'Second', - ])->setDisabled(TRUE); + ])->setDisabled(true); Assert::same('', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.RadioList.loadData.phpt b/tests/Forms/Controls.RadioList.loadData.phpt index 36a8a078b..3fba57c82 100644 --- a/tests/Forms/Controls.RadioList.loadData.phpt +++ b/tests/Forms/Controls.RadioList.loadData.phpt @@ -30,7 +30,7 @@ test(function () use ($series) { // Radio list $_POST = ['radio' => 'red-dwarf']; $form = new Form; - $input = $form->addRadioList('radio', NULL, $series); + $input = $form->addRadioList('radio', null, $series); Assert::true($form->isValid()); Assert::same('red-dwarf', $input->getValue()); @@ -43,7 +43,7 @@ test(function () use ($series) { // Radio list with invalid input $_POST = ['radio' => 'days-of-our-lives']; $form = new Form; - $input = $form->addRadioList('radio', NULL, $series); + $input = $form->addRadioList('radio', null, $series); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -56,7 +56,7 @@ test(function () use ($series) { // Indexed arrays $_POST = ['zero' => 0]; $form = new Form; - $input = $form->addRadioList('zero', NULL, $series); + $input = $form->addRadioList('zero', null, $series); Assert::true($form->isValid()); Assert::same(0, $input->getValue()); @@ -70,7 +70,7 @@ test(function () use ($series) { // empty key $_POST = ['empty' => '']; $form = new Form; - $input = $form->addRadioList('empty', NULL, $series); + $input = $form->addRadioList('empty', null, $series); Assert::true($form->isValid()); Assert::same('', $input->getValue()); @@ -81,7 +81,7 @@ test(function () use ($series) { // empty key test(function () use ($series) { // missing key $form = new Form; - $input = $form->addRadioList('missing', NULL, $series); + $input = $form->addRadioList('missing', null, $series); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -94,7 +94,7 @@ test(function () use ($series) { // disabled key $_POST = ['disabled' => 'red-dwarf']; $form = new Form; - $input = $form->addRadioList('disabled', NULL, $series) + $input = $form->addRadioList('disabled', null, $series) ->setDisabled(); Assert::true($form->isValid()); @@ -104,10 +104,10 @@ test(function () use ($series) { // disabled key test(function () use ($series) { // malformed data - $_POST = ['malformed' => [NULL]]; + $_POST = ['malformed' => [null]]; $form = new Form; - $input = $form->addRadioList('malformed', NULL, $series); + $input = $form->addRadioList('malformed', null, $series); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -120,7 +120,7 @@ test(function () use ($series) { // setItems without keys $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addRadioList('select')->setItems(array_keys($series), FALSE); + $input = $form->addRadioList('select')->setItems(array_keys($series), false); Assert::true($form->isValid()); Assert::same('red-dwarf', $input->getValue()); @@ -131,8 +131,8 @@ test(function () use ($series) { // setItems without keys test(function () use ($series) { // setValue() and invalid argument $form = new Form; - $input = $form->addRadioList('radio', NULL, $series); - $input->setValue(NULL); + $input = $form->addRadioList('radio', null, $series); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue('unknown'); @@ -142,7 +142,7 @@ test(function () use ($series) { // setValue() and invalid argument test(function () { // object as value $form = new Form; - $input = $form->addRadioList('radio', NULL, ['2013-07-05 00:00:00' => 1]) + $input = $form->addRadioList('radio', null, ['2013-07-05 00:00:00' => 1]) ->setValue(new DateTime('2013-07-05')); Assert::same('2013-07-05 00:00:00', $input->getValue()); @@ -152,7 +152,7 @@ test(function () { // object as value test(function () { // object as item $form = new Form; $input = $form->addRadioList('radio') - ->setItems([new DateTime('2013-07-05')], FALSE) + ->setItems([new DateTime('2013-07-05')], false) ->setValue(new DateTime('2013-07-05')); Assert::same('2013-07-05 00:00:00', $input->getValue()); @@ -163,13 +163,13 @@ test(function () use ($series) { // disabled one $_POST = ['radio' => 'red-dwarf']; $form = new Form; - $input = $form->addRadioList('radio', NULL, $series) + $input = $form->addRadioList('radio', null, $series) ->setDisabled(['red-dwarf']); Assert::null($input->getValue()); unset($form['radio']); - $input = new Nette\Forms\Controls\RadioList(NULL, $series); + $input = new Nette\Forms\Controls\RadioList(null, $series); $input->setDisabled(['red-dwarf']); $form['radio'] = $input; diff --git a/tests/Forms/Controls.RadioList.render.phpt b/tests/Forms/Controls.RadioList.render.phpt index 6a34aa0d9..352ac30a4 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -112,7 +112,7 @@ test(function () { // container test(function () { // container prototype $form = new Form; - $input = $form->addRadioList('list', NULL, [ + $input = $form->addRadioList('list', null, [ 'a' => 'b', ]); $input->getSeparatorPrototype()->setName('hr'); @@ -127,7 +127,7 @@ test(function () { // disabled all $input = $form->addRadioList('list', 'Label', [ 'a' => 'First', 0 => 'Second', - ])->setDisabled(TRUE); + ])->setDisabled(true); Assert::same('
', (string) $input->getControl()); }); @@ -147,7 +147,7 @@ test(function () { // disabled one test(function () { // item label prototype $form = new Form; - $input = $form->addRadioList('list', NULL, [ + $input = $form->addRadioList('list', null, [ 'a' => 'b', ]); $input->getItemLabelPrototype()->class('foo'); @@ -164,7 +164,7 @@ test(function () { // forced ID 'a' => 'First', 0 => 'Second', ]); - $input->generateId = TRUE; + $input->generateId = true; Assert::same('
', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.SelectBox.isOk.phpt b/tests/Forms/Controls.SelectBox.isOk.phpt index 0018c837f..eae9eeca7 100644 --- a/tests/Forms/Controls.SelectBox.isOk.phpt +++ b/tests/Forms/Controls.SelectBox.isOk.phpt @@ -13,21 +13,21 @@ require __DIR__ . '/../bootstrap.php'; $form = new Form; -$select = $form->addSelect('foo', NULL, ['bar' => 'Bar']); +$select = $form->addSelect('foo', null, ['bar' => 'Bar']); Assert::false($select->isOk()); -$select->setDisabled(TRUE); +$select->setDisabled(true); Assert::true($select->isOk()); -$select->setDisabled(FALSE); +$select->setDisabled(false); $select->setPrompt('Empty'); Assert::true($select->isOk()); -$select->setPrompt(FALSE); +$select->setPrompt(false); $select->setValue('bar'); Assert::true($select->isOk()); -$select->setValue(NULL); +$select->setValue(null); $select->setItems([]); Assert::true($select->isOk()); diff --git a/tests/Forms/Controls.SelectBox.loadData.phpt b/tests/Forms/Controls.SelectBox.loadData.phpt index 8fcf0e7ec..13b6ad3bb 100644 --- a/tests/Forms/Controls.SelectBox.loadData.phpt +++ b/tests/Forms/Controls.SelectBox.loadData.phpt @@ -30,7 +30,7 @@ test(function () use ($series) { // Select $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addSelect('select', NULL, $series); + $input = $form->addSelect('select', null, $series); Assert::true($form->isValid()); Assert::same('red-dwarf', $input->getValue()); @@ -46,8 +46,8 @@ test(function () { // Empty select $input = $form->addSelect('select'); Assert::true($form->isValid()); - Assert::same(NULL, $input->getValue()); - Assert::same(NULL, $input->getSelectedItem()); + Assert::same(null, $input->getValue()); + Assert::same(null, $input->getSelectedItem()); Assert::false($input->isFilled()); }); @@ -56,7 +56,7 @@ test(function () use ($series) { // Select with prompt $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addSelect('select', NULL, $series)->setPrompt('Select series'); + $input = $form->addSelect('select', null, $series)->setPrompt('Select series'); Assert::true($form->isValid()); Assert::same('red-dwarf', $input->getValue()); @@ -67,12 +67,12 @@ test(function () use ($series) { // Select with prompt test(function () use ($series) { // Select with more visible options and no input $form = new Form; - $input = $form->addSelect('select', NULL, $series); + $input = $form->addSelect('select', null, $series); $input->getControlPrototype()->size = 2; Assert::true($form->isValid()); - Assert::same(NULL, $input->getValue()); - Assert::same(NULL, $input->getSelectedItem()); + Assert::same(null, $input->getValue()); + Assert::same(null, $input->getSelectedItem()); Assert::false($input->isFilled()); }); @@ -81,7 +81,7 @@ test(function () { // Select with optgroups $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addSelect('select', NULL, [ + $input = $form->addSelect('select', null, [ 'usa' => [ 'the-simpsons' => 'The Simpsons', 0 => 'South Park', @@ -102,7 +102,7 @@ test(function () use ($series) { // Select with invalid input $_POST = ['select' => 'days-of-our-lives']; $form = new Form; - $input = $form->addSelect('select', NULL, $series); + $input = $form->addSelect('select', null, $series); Assert::false($form->isValid()); Assert::null($input->getValue()); @@ -113,7 +113,7 @@ test(function () use ($series) { // Select with invalid input test(function () use ($series) { // Select with prompt and invalid input $form = new Form; - $input = $form->addSelect('select', NULL, $series)->setPrompt('Select series'); + $input = $form->addSelect('select', null, $series)->setPrompt('Select series'); Assert::true($form->isValid()); Assert::null($input->getValue()); @@ -126,7 +126,7 @@ test(function () use ($series) { // Indexed arrays $_POST = ['zero' => 0]; $form = new Form; - $input = $form->addSelect('zero', NULL, $series); + $input = $form->addSelect('zero', null, $series); Assert::true($form->isValid()); Assert::same(0, $input->getValue()); @@ -140,7 +140,7 @@ test(function () use ($series) { // empty key $_POST = ['empty' => '']; $form = new Form; - $input = $form->addSelect('empty', NULL, $series); + $input = $form->addSelect('empty', null, $series); Assert::true($form->isValid()); Assert::same('', $input->getValue()); @@ -151,7 +151,7 @@ test(function () use ($series) { // empty key test(function () use ($series) { // missing key $form = new Form; - $input = $form->addSelect('missing', NULL, $series); + $input = $form->addSelect('missing', null, $series); Assert::false($form->isValid()); Assert::null($input->getValue()); @@ -164,7 +164,7 @@ test(function () use ($series) { // disabled key $_POST = ['disabled' => 'red-dwarf']; $form = new Form; - $input = $form->addSelect('disabled', NULL, $series) + $input = $form->addSelect('disabled', null, $series) ->setDisabled(); Assert::true($form->isValid()); @@ -173,10 +173,10 @@ test(function () use ($series) { // disabled key test(function () use ($series) { // malformed data - $_POST = ['malformed' => [NULL]]; + $_POST = ['malformed' => [null]]; $form = new Form; - $input = $form->addSelect('malformed', NULL, $series); + $input = $form->addSelect('malformed', null, $series); Assert::false($form->isValid()); Assert::null($input->getValue()); @@ -189,7 +189,7 @@ test(function () use ($series) { // setItems without keys $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addSelect('select')->setItems(array_keys($series), FALSE); + $input = $form->addSelect('select')->setItems(array_keys($series), false); Assert::same([ 'red-dwarf' => 'red-dwarf', 'the-simpsons' => 'the-simpsons', @@ -206,7 +206,7 @@ test(function () use ($series) { // setItems without keys test(function () { // setItems without keys $form = new Form; - $input = $form->addSelect('select')->setItems(range(1, 5), FALSE); + $input = $form->addSelect('select')->setItems(range(1, 5), false); Assert::same([1 => 1, 2, 3, 4, 5], $input->getItems()); }); @@ -218,7 +218,7 @@ test(function () { // setItems without keys with optgroups $input = $form->addSelect('select')->setItems([ 'usa' => ['the-simpsons', 0], 'uk' => ['red-dwarf'], - ], FALSE); + ], false); Assert::true($form->isValid()); Assert::same('red-dwarf', $input->getValue()); @@ -229,8 +229,8 @@ test(function () { // setItems without keys with optgroups test(function () use ($series) { // setValue() and invalid argument $form = new Form; - $input = $form->addSelect('select', NULL, $series); - $input->setValue(NULL); + $input = $form->addSelect('select', null, $series); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue('unknown'); @@ -240,7 +240,7 @@ test(function () use ($series) { // setValue() and invalid argument test(function () { // object as value $form = new Form; - $input = $form->addSelect('select', NULL, ['2013-07-05 00:00:00' => 1]) + $input = $form->addSelect('select', null, ['2013-07-05 00:00:00' => 1]) ->setValue(new DateTime('2013-07-05')); Assert::same('2013-07-05 00:00:00', $input->getValue()); @@ -253,7 +253,7 @@ test(function () { // object as item ->setItems([ 'group' => [new DateTime('2013-07-05')], new DateTime('2013-07-06'), - ], FALSE) + ], false) ->setValue('2013-07-05 00:00:00'); Assert::equal(new DateTime('2013-07-05'), $input->getSelectedItem()); @@ -264,13 +264,13 @@ test(function () use ($series) { // disabled one $_POST = ['select' => 'red-dwarf']; $form = new Form; - $input = $form->addSelect('select', NULL, $series) + $input = $form->addSelect('select', null, $series) ->setDisabled(['red-dwarf']); Assert::null($input->getValue()); unset($form['select']); - $input = new Nette\Forms\Controls\SelectBox(NULL, $series); + $input = new Nette\Forms\Controls\SelectBox(null, $series); $input->setDisabled(['red-dwarf']); $form['select'] = $input; @@ -281,8 +281,8 @@ test(function () { $_POST = ['select' => 1]; $form = new Form; - $input = $form->addSelect('select', NULL, [ - 1 => NULL, + $input = $form->addSelect('select', null, [ + 1 => null, 2 => 'Red dwarf', ]); diff --git a/tests/Forms/Controls.SelectBox.render.phpt b/tests/Forms/Controls.SelectBox.render.phpt index 3fee947d4..4c784ddde 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -115,7 +115,7 @@ test(function () { // disabled all $input = $form->addSelect('list', 'Label', [ 'a' => 'First', 0 => 'Second', - ])->setDisabled(TRUE); + ])->setDisabled(true); Assert::same('', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.TextArea.render.phpt b/tests/Forms/Controls.TextArea.render.phpt index c36980094..e6b38cb3a 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -62,7 +62,7 @@ test(function () { // Html with translator test(function () { // validation rule LENGTH $form = new Form; $input = $form->addTextArea('text') - ->addRule($form::LENGTH, NULL, [10, 20]); + ->addRule($form::LENGTH, null, [10, 20]); Assert::same('', (string) $input->getControl()); }); @@ -71,8 +71,8 @@ test(function () { // validation rule LENGTH test(function () { // validation rule MAX_LENGTH $form = new Form; $input = $form->addTextArea('text') - ->addRule($form::MAX_LENGTH, NULL, 30) - ->addRule($form::MAX_LENGTH, NULL, 10); + ->addRule($form::MAX_LENGTH, null, 30) + ->addRule($form::MAX_LENGTH, null, 10); Assert::same('', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.TextBase.loadData.phpt b/tests/Forms/Controls.TextBase.loadData.phpt index b5a77a420..4eddb8372 100644 --- a/tests/Forms/Controls.TextBase.loadData.phpt +++ b/tests/Forms/Controls.TextBase.loadData.phpt @@ -79,7 +79,7 @@ test(function () { // missing data test(function () { // malformed data - $_POST = ['malformed' => [NULL]]; + $_POST = ['malformed' => [null]]; $form = new Form; $input = $form->addText('malformed'); @@ -94,11 +94,11 @@ test(function () { // setValue() and invalid argument $form = new Form; $input = $form->addText('text'); - $input->setValue(NULL); + $input->setValue(null); Assert::exception(function () use ($input) { $input->setValue([]); - }, Nette\InvalidArgumentException::class, "Value must be scalar or NULL, array given in field 'text'."); + }, Nette\InvalidArgumentException::class, "Value must be scalar or null, array given in field 'text'."); }); diff --git a/tests/Forms/Controls.TextInput.render.phpt b/tests/Forms/Controls.TextInput.render.phpt index aa0e80d4c..039c2c28e 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -110,7 +110,7 @@ test(function () { // validation rule LENGTH $form = new Form; $input = $form->addText('text') ->setMaxLength(30) - ->addRule($form::LENGTH, NULL, [10, 20]); + ->addRule($form::LENGTH, null, [10, 20]); Assert::same('', (string) $input->getControl()); }); @@ -118,8 +118,8 @@ test(function () { // validation rule LENGTH test(function () { // validation rule MAX_LENGTH $form = new Form; - $input = $form->addText('text', NULL, NULL, 30) - ->addRule($form::MAX_LENGTH, NULL, 10); + $input = $form->addText('text', null, null, 30) + ->addRule($form::MAX_LENGTH, null, 10); Assert::same('', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.UploadControl.loadData.phpt b/tests/Forms/Controls.UploadControl.loadData.phpt index 5c9edcf6b..c271cf475 100644 --- a/tests/Forms/Controls.UploadControl.loadData.phpt +++ b/tests/Forms/Controls.UploadControl.loadData.phpt @@ -45,11 +45,11 @@ $_FILES = [ 'size' => [0], ], 'invalid1' => [ - 'name' => [NULL], - 'type' => [NULL], - 'tmp_name' => [NULL], - 'error' => [NULL], - 'size' => [NULL], + 'name' => [null], + 'type' => [null], + 'tmp_name' => [null], + 'error' => [null], + 'size' => [null], ], 'invalid2' => '', 'partial' => [ @@ -199,7 +199,7 @@ test(function () { // partial uploaded (error) test(function () { // validators $form = new Form; $input = $form->addUpload('avatar') - ->addRule($form::MAX_FILE_SIZE, NULL, 3000); + ->addRule($form::MAX_FILE_SIZE, null, 3000); Assert::false(Validator::validateFileSize($input, 3012)); Assert::true(Validator::validateFileSize($input, 3013)); @@ -218,7 +218,7 @@ test(function () { // validators test(function () { // validators on multiple files $form = new Form; $input = $form->addContainer('multiple')->addMultiUpload('avatar') - ->addRule($form::MAX_FILE_SIZE, NULL, 3000); + ->addRule($form::MAX_FILE_SIZE, null, 3000); Assert::false(Validator::validateFileSize($input, 150)); Assert::true(Validator::validateFileSize($input, 300)); diff --git a/tests/Forms/Controls.UploadControl.render.phpt b/tests/Forms/Controls.UploadControl.render.phpt index 67b6731f7..d7f34b312 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) + function translate($s, $plural = null) { return strtoupper($s); } @@ -36,7 +36,7 @@ test(function () { test(function () { // multiple $form = new Form; - $input = $form->addUpload('file', 'Label', TRUE); + $input = $form->addUpload('file', 'Label', true); Assert::same('', (string) $input->getControl()); }); diff --git a/tests/Forms/Controls.translate().phpt b/tests/Forms/Controls.translate().phpt index 10393666f..60cb7a878 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) + function translate($message, $count = null) { return is_object($message) ? get_class($message) : $message; } diff --git a/tests/Forms/Forms.callbackParameters.phpt b/tests/Forms/Forms.callbackParameters.phpt index b0e78c2d2..b311cdc19 100644 --- a/tests/Forms/Forms.callbackParameters.phpt +++ b/tests/Forms/Forms.callbackParameters.phpt @@ -59,5 +59,5 @@ $form->onValidate = [$f1, $f2, $f1, $f4, $f5]; $form['btn']->onClick = [$b1, $b2, $b1, $f4, $f5]; $form->fireEvents(); -Assert::same([TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE], $types); -Assert::same([TRUE, TRUE, TRUE], $arrayHashIsImmutable); +Assert::same([true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], $types); +Assert::same([true, true, true], $arrayHashIsImmutable); diff --git a/tests/Forms/Forms.getHttpData.get.2.phpt b/tests/Forms/Forms.getHttpData.get.2.phpt index 16dcec2f6..b589be865 100644 --- a/tests/Forms/Forms.getHttpData.get.2.phpt +++ b/tests/Forms/Forms.getHttpData.get.2.phpt @@ -27,5 +27,5 @@ test(function () { Assert::truthy($form->isSubmitted()); Assert::same(['item'], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); }); diff --git a/tests/Forms/Forms.getHttpData.get.phpt b/tests/Forms/Forms.getHttpData.get.phpt index 97935e23a..776c7482b 100644 --- a/tests/Forms/Forms.getHttpData.get.phpt +++ b/tests/Forms/Forms.getHttpData.get.phpt @@ -25,7 +25,7 @@ test(function () { Assert::false($form->isSubmitted()); Assert::false($form->isSuccess()); Assert::same([], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); }); @@ -35,7 +35,7 @@ test(function () { Assert::false($form->isSubmitted()); Assert::same([], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); }); @@ -50,6 +50,6 @@ test(function () { Assert::truthy($form->isSubmitted()); Assert::same([Form::TRACKER_ID => $name], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); Assert::same($name, $form[Form::TRACKER_ID]->getValue()); }); diff --git a/tests/Forms/Forms.getHttpData.post.phpt b/tests/Forms/Forms.getHttpData.post.phpt index 7193480be..39ff8b5cc 100644 --- a/tests/Forms/Forms.getHttpData.post.phpt +++ b/tests/Forms/Forms.getHttpData.post.phpt @@ -25,7 +25,7 @@ test(function () { Assert::truthy($form->isSubmitted()); Assert::true($form->isSuccess()); Assert::same([], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); }); @@ -37,7 +37,7 @@ test(function () { Assert::false($form->isSubmitted()); Assert::false($form->isSuccess()); Assert::same([], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); }); @@ -50,7 +50,7 @@ test(function () { Assert::truthy($form->isSubmitted()); Assert::same([Form::TRACKER_ID => $name], $form->getHttpData()); - Assert::same([], $form->getValues(TRUE)); + Assert::same([], $form->getValues(true)); Assert::same($name, $form[Form::TRACKER_ID]->getValue()); }); diff --git a/tests/Forms/Forms.omittedValue.phpt b/tests/Forms/Forms.omittedValue.phpt index eb846aa80..edad6816f 100644 --- a/tests/Forms/Forms.omittedValue.phpt +++ b/tests/Forms/Forms.omittedValue.phpt @@ -18,9 +18,9 @@ $form->addText('input'); $form->addText('omittedInput') ->setOmitted(); -Assert::same(['input' => ''], $form->getValues(TRUE)); +Assert::same(['input' => ''], $form->getValues(true)); Assert::true((new TextInput)->setDisabled()->isOmitted()); -Assert::false((new TextInput)->setDisabled()->setDisabled(FALSE)->isOmitted()); -Assert::false((new TextInput)->setDisabled()->setOmitted(FALSE)->isOmitted()); +Assert::false((new TextInput)->setDisabled()->setDisabled(false)->isOmitted()); +Assert::false((new TextInput)->setDisabled()->setOmitted(false)->isOmitted()); diff --git a/tests/Forms/Forms.onClick.phpt b/tests/Forms/Forms.onClick.phpt index 8a2dbc9d2..1a25f37fa 100644 --- a/tests/Forms/Forms.onClick.phpt +++ b/tests/Forms/Forms.onClick.phpt @@ -69,6 +69,6 @@ test(function () { // invalid Assert::exception(function () { $form = new Form; - $form->addSubmit('btn')->onClick = TRUE; + $form->addSubmit('btn')->onClick = true; $form->fireEvents(); }, Nette\UnexpectedValueException::class, "Property \$onClick in button 'btn' must be iterable, boolean given."); diff --git a/tests/Forms/Forms.onSuccess.phpt b/tests/Forms/Forms.onSuccess.phpt index 6c9ed8797..c2a76f4c0 100644 --- a/tests/Forms/Forms.onSuccess.phpt +++ b/tests/Forms/Forms.onSuccess.phpt @@ -87,6 +87,6 @@ test(function () { // invalid Assert::exception(function () { $form = new Form; - $form->onSuccess = TRUE; + $form->onSuccess = true; $form->fireEvents(); }, Nette\UnexpectedValueException::class, 'Property Form::$onSuccess must be array or Traversable, boolean given.'); diff --git a/tests/Forms/Forms.renderer.1.phpt b/tests/Forms/Forms.renderer.1.phpt index 1a35deeb5..7827c8518 100644 --- a/tests/Forms/Forms.renderer.1.phpt +++ b/tests/Forms/Forms.renderer.1.phpt @@ -54,10 +54,10 @@ $form->addEmail('email', 'Email:') $form->addGroup('Shipping address') - ->setOption('embedNext', TRUE); + ->setOption('embedNext', true); $form->addCheckbox('send', 'Ship to address') - ->addCondition(Form::EQUAL, FALSE) + ->addCondition(Form::EQUAL, false) ->elseCondition() ->toggle('sendBox'); @@ -68,12 +68,12 @@ $form->addGroup() $form->addText('street', 'Street:'); $form->addText('city', 'City:') - ->addConditionOn($form['send'], Form::EQUAL, TRUE) + ->addConditionOn($form['send'], Form::EQUAL, true) ->addRule(Form::FILLED, 'Enter your shipping address'); $form->addSelect('country', 'Country:', $countries) ->setPrompt('Select your country') - ->addConditionOn($form['send'], Form::EQUAL, TRUE) + ->addConditionOn($form['send'], Form::EQUAL, true) ->addRule(Form::FILLED, 'Select your country'); $form->addSelect('countrySetItems', 'Country:') @@ -119,4 +119,4 @@ $defaults = [ $form->setDefaults($defaults); $form->fireEvents(); -Assert::matchFile(__DIR__ . '/Forms.renderer.1.expect', $form->__toString(TRUE)); +Assert::matchFile(__DIR__ . '/Forms.renderer.1.expect', $form->__toString(true)); diff --git a/tests/Forms/Forms.renderer.2.phpt b/tests/Forms/Forms.renderer.2.phpt index 532b41396..2f69cc7ef 100644 --- a/tests/Forms/Forms.renderer.2.phpt +++ b/tests/Forms/Forms.renderer.2.phpt @@ -37,14 +37,14 @@ $form = new Form; $renderer = $form->renderer; $renderer->wrappers['form']['container'] = Html::el('div')->id('form'); -$renderer->wrappers['form']['errors'] = FALSE; -$renderer->wrappers['group']['container'] = NULL; +$renderer->wrappers['form']['errors'] = false; +$renderer->wrappers['group']['container'] = null; $renderer->wrappers['group']['label'] = 'h3'; -$renderer->wrappers['pair']['container'] = NULL; +$renderer->wrappers['pair']['container'] = null; $renderer->wrappers['controls']['container'] = 'dl'; $renderer->wrappers['control']['container'] = 'dd'; $renderer->wrappers['control']['.odd'] = 'odd'; -$renderer->wrappers['control']['errors'] = TRUE; +$renderer->wrappers['control']['errors'] = true; $renderer->wrappers['label']['container'] = 'dt'; $renderer->wrappers['label']['suffix'] = ':'; $renderer->wrappers['control']['requiredsuffix'] = " \xE2\x80\xA2"; @@ -68,10 +68,10 @@ $form->addText('email', 'Email') $form->addGroup('Shipping address') - ->setOption('embedNext', TRUE); + ->setOption('embedNext', true); $form->addCheckbox('send', 'Ship to address') - ->addCondition(Form::EQUAL, TRUE) + ->addCondition(Form::EQUAL, true) ->toggle('sendBox'); @@ -81,12 +81,12 @@ $form->addGroup() $form->addText('street', 'Street'); $form->addText('city', 'City') - ->addConditionOn($form['send'], Form::EQUAL, TRUE) + ->addConditionOn($form['send'], Form::EQUAL, true) ->addRule(Form::FILLED, 'Enter your shipping address'); $form->addSelect('country', 'Country', $countries) ->setPrompt('Select your country') - ->addConditionOn($form['send'], Form::EQUAL, TRUE) + ->addConditionOn($form['send'], Form::EQUAL, true) ->addRule(Form::FILLED, 'Select your country'); @@ -123,4 +123,4 @@ $defaults = [ $form->setDefaults($defaults); $form->fireEvents(); -Assert::matchFile(__DIR__ . '/Forms.renderer.2.expect', $form->__toString(TRUE)); +Assert::matchFile(__DIR__ . '/Forms.renderer.2.expect', $form->__toString(true)); diff --git a/tests/Forms/Forms.renderer.3.phpt b/tests/Forms/Forms.renderer.3.phpt index adf1ddff0..86002900c 100644 --- a/tests/Forms/Forms.renderer.3.phpt +++ b/tests/Forms/Forms.renderer.3.phpt @@ -28,4 +28,4 @@ Assert::match('
-
', $form->__toString(TRUE)); +', $form->__toString(true)); diff --git a/tests/Forms/Forms.renderer.4.phpt b/tests/Forms/Forms.renderer.4.phpt index 3115cfa80..59e52a2be 100644 --- a/tests/Forms/Forms.renderer.4.phpt +++ b/tests/Forms/Forms.renderer.4.phpt @@ -29,6 +29,6 @@ Assert::match('
-
', $form->__toString(TRUE)); +', $form->__toString(true)); Assert::same('link?a=b&c[]=d', $form->getAction()); diff --git a/tests/Forms/Forms.renderer.5.phpt b/tests/Forms/Forms.renderer.5.phpt index 1e4685f0e..c240300e8 100644 --- a/tests/Forms/Forms.renderer.5.phpt +++ b/tests/Forms/Forms.renderer.5.phpt @@ -46,4 +46,4 @@ $form->addSubmit('submit', 'Order'); $form->fireEvents(); -Assert::matchFile(__DIR__ . '/Forms.renderer.5.expect', $form->__toString(TRUE)); +Assert::matchFile(__DIR__ . '/Forms.renderer.5.expect', $form->__toString(true)); diff --git a/tests/Forms/Forms.renderer.translate.phpt b/tests/Forms/Forms.renderer.translate.phpt index 7f2e60be1..a26f323b5 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) + function translate($message, $count = null) { return strtoupper($message); } @@ -31,10 +31,10 @@ $form->addText('username', 'Username') ->setOption('description', 'or email') ->setRequired('Please enter your username'); $form->addPassword('password', 'Password') - ->setRequired(TRUE) + ->setRequired(true) ->addRule(Form::MIN_LENGTH, 'Minimal length is %d chars', 8) ->addError('Weak password'); $form->addSubmit('submit', 'Send'); -Assert::matchFile(__DIR__ . '/Forms.renderer.translate.expect', $form->__toString(TRUE)); +Assert::matchFile(__DIR__ . '/Forms.renderer.translate.expect', $form->__toString(true)); diff --git a/tests/Forms/Forms.toggle.phpt b/tests/Forms/Forms.toggle.phpt index 005905405..0f08d5974 100644 --- a/tests/Forms/Forms.toggle.phpt +++ b/tests/Forms/Forms.toggle.phpt @@ -22,8 +22,8 @@ test(function () { // AND ->toggle('b'); Assert::same([ - 'a' => FALSE, - 'b' => FALSE, + 'a' => false, + 'b' => false, ], $form->getToggles()); }); @@ -39,8 +39,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => FALSE, - 'b' => FALSE, + 'a' => false, + 'b' => false, ], $form->getToggles()); }); @@ -56,8 +56,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => FALSE, + 'a' => true, + 'b' => false, ], $form->getToggles()); }); @@ -73,8 +73,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); @@ -91,8 +91,8 @@ test(function () { // OR ->toggle('b'); Assert::same([ - 'a' => FALSE, - 'b' => FALSE, + 'a' => false, + 'b' => false, ], $form->getToggles()); }); @@ -109,8 +109,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => FALSE, - 'b' => TRUE, + 'a' => false, + 'b' => true, ], $form->getToggles()); }); @@ -127,8 +127,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => FALSE, + 'a' => true, + 'b' => false, ], $form->getToggles()); }); @@ -145,8 +145,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); @@ -161,8 +161,8 @@ test(function () { // OR & two components ->toggle('b'); Assert::same([ - 'a' => FALSE, - 'b' => FALSE, + 'a' => false, + 'b' => false, ], $form->getToggles()); }); @@ -177,8 +177,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => FALSE, - 'b' => TRUE, + 'a' => false, + 'b' => true, ], $form->getToggles()); }); @@ -193,8 +193,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => FALSE, + 'a' => true, + 'b' => false, ], $form->getToggles()); }); @@ -209,8 +209,8 @@ test(function () { ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); @@ -225,7 +225,7 @@ test(function () { // OR & multiple used ID ->toggle('a'); Assert::same([ - 'a' => FALSE, + 'a' => false, ], $form->getToggles()); }); @@ -240,7 +240,7 @@ test(function () { ->toggle('a'); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -255,7 +255,7 @@ test(function () { ->toggle('a'); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -270,7 +270,7 @@ test(function () { ->toggle('a'); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -286,7 +286,7 @@ test(function () { // AND & multiple used ID ->toggle('a'); Assert::same([ - 'a' => FALSE, + 'a' => false, ], $form->getToggles()); }); @@ -302,7 +302,7 @@ test(function () { ->toggle('a'); Assert::same([ - 'a' => FALSE, + 'a' => false, ], $form->getToggles()); }); @@ -318,7 +318,7 @@ test(function () { ->toggle('a'); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -334,24 +334,24 @@ test(function () { ->toggle('a'); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); -test(function () { // $hide = FALSE +test(function () { // $hide = false $form = new Form; $form->addText('1'); $form->addText('2'); $form->addText('3') ->addConditionOn($form['1'], Form::EQUAL, 'x') - ->toggle('a', FALSE) + ->toggle('a', false) ->addConditionOn($form['2'], Form::NOT_EQUAL, 'x') ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => FALSE, + 'a' => true, + 'b' => false, ], $form->getToggles()); }); @@ -362,13 +362,13 @@ test(function () { $form->addText('2'); $form->addText('3') ->addConditionOn($form['1'], Form::EQUAL, 'x') - ->toggle('a', FALSE) + ->toggle('a', false) ->addConditionOn($form['2'], Form::NOT_EQUAL, 'x') - ->toggle('b', FALSE); + ->toggle('b', false); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); @@ -379,13 +379,13 @@ test(function () { $form->addText('2'); $form->addText('3') ->addConditionOn($form['1'], Form::NOT_EQUAL, 'x') - ->toggle('a', FALSE) + ->toggle('a', false) ->addConditionOn($form['2'], Form::EQUAL, 'x') - ->toggle('b', FALSE); + ->toggle('b', false); Assert::same([ - 'a' => FALSE, - 'b' => TRUE, + 'a' => false, + 'b' => true, ], $form->getToggles()); }); @@ -394,14 +394,14 @@ test(function () { $form = new Form; $form->addText('1') ->addCondition(Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); $form->addText('2') ->addCondition(Form::NOT_EQUAL, 'x') ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); @@ -413,11 +413,11 @@ test(function () { ->toggle('a'); $form->addText('2') ->addCondition(Form::NOT_EQUAL, 'x') - ->toggle('b', FALSE); + ->toggle('b', false); Assert::same([ - 'a' => FALSE, - 'b' => FALSE, + 'a' => false, + 'b' => false, ], $form->getToggles()); }); @@ -426,30 +426,30 @@ test(function () { $form = new Form; $form->addText('1') ->addCondition(Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); $form->addText('2') ->addCondition(Form::EQUAL, 'x') - ->toggle('b', FALSE); + ->toggle('b', false); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); -test(function () { // $hide = FALSE & multiple used ID +test(function () { // $hide = false & multiple used ID $form = new Form; $form->addText('1'); $form->addText('2'); $form->addText('3') ->addConditionOn($form['1'], Form::EQUAL, 'x') - ->toggle('a', FALSE) + ->toggle('a', false) ->addConditionOn($form['2'], Form::NOT_EQUAL, 'x') ->toggle('a'); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -460,12 +460,12 @@ test(function () { $form->addText('2'); $form->addText('3') ->addConditionOn($form['1'], Form::EQUAL, 'x') - ->toggle('a', FALSE) + ->toggle('a', false) ->addConditionOn($form['2'], Form::NOT_EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -476,12 +476,12 @@ test(function () { $form->addText('2'); $form->addText('3') ->addConditionOn($form['1'], Form::NOT_EQUAL, 'x') - ->toggle('a', FALSE) + ->toggle('a', false) ->addConditionOn($form['2'], Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -490,14 +490,14 @@ test(function () { $form = new Form; $form->addText('1') ->addCondition(Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); $form->addText('2') ->addCondition(Form::NOT_EQUAL, 'x') ->toggle('b'); Assert::same([ - 'a' => TRUE, - 'b' => TRUE, + 'a' => true, + 'b' => true, ], $form->getToggles()); }); @@ -509,11 +509,11 @@ test(function () { ->toggle('a'); $form->addText('2') ->addCondition(Form::NOT_EQUAL, 'x') - ->toggle('b', FALSE); + ->toggle('b', false); Assert::same([ - 'a' => FALSE, - 'b' => FALSE, + 'a' => false, + 'b' => false, ], $form->getToggles()); }); @@ -522,13 +522,13 @@ test(function () { $form = new Form; $form->addText('1') ->addCondition(Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); $form->addText('2') ->addCondition(Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); @@ -537,12 +537,12 @@ test(function () { $form = new Form; $form->addText('1') ->addCondition(Form::EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); $form->addText('2') ->addCondition(Form::NOT_EQUAL, 'x') - ->toggle('a', FALSE); + ->toggle('a', false); Assert::same([ - 'a' => TRUE, + 'a' => true, ], $form->getToggles()); }); diff --git a/tests/Forms/Forms.validationScope.phpt b/tests/Forms/Forms.validationScope.phpt index 29350be8b..5ed28e7c8 100644 --- a/tests/Forms/Forms.validationScope.phpt +++ b/tests/Forms/Forms.validationScope.phpt @@ -35,7 +35,7 @@ foreach ($datasets as $case) { $details->addText('age2')->setRequired('age2'); $form->addSubmit('send1'); - $form->addSubmit('send2')->setValidationScope(FALSE); + $form->addSubmit('send2')->setValidationScope(false); $form->addSubmit('send3')->setValidationScope([$form['name']]); $form->addSubmit('send4')->setValidationScope([$form['details']['age']]); $form->addSubmit('send5')->setValidationScope([$form['details']]); diff --git a/tests/Forms/Helpers.createInputList.phpt b/tests/Forms/Helpers.createInputList.phpt index ee7896f7f..4ac36c4f3 100644 --- a/tests/Forms/Helpers.createInputList.phpt +++ b/tests/Forms/Helpers.createInputList.phpt @@ -59,8 +59,8 @@ test(function () { '
', Helpers::createInputList( ['a' => 'First', 'b' => 'Second'], - NULL, - NULL, + null, + null, '
' ) ); @@ -69,8 +69,8 @@ test(function () { '
', Helpers::createInputList( ['a' => 'First', 'b' => 'Second'], - NULL, - NULL, + null, + null, Html::el('div') ) ); @@ -79,9 +79,9 @@ test(function () { '', Helpers::createInputList( ['a' => 'First', 'b' => 'Second'], - NULL, - NULL, - Html::el(NULL) + null, + null, + Html::el(null) ) ); }); diff --git a/tests/Forms/Helpers.createSelectBox.phpt b/tests/Forms/Helpers.createSelectBox.phpt index 82f0e4d75..e617850e0 100644 --- a/tests/Forms/Helpers.createSelectBox.phpt +++ b/tests/Forms/Helpers.createSelectBox.phpt @@ -60,7 +60,7 @@ test(function () { (string) Helpers::createSelectBox( ['a' => 'First', 'b' => 'Second'], [ - 'disabled:' => ['b' => TRUE], + 'disabled:' => ['b' => true], 'selected?' => ['a'], 'title' => 'Hello', 'style' => ['color' => 'blue'], @@ -72,7 +72,7 @@ test(function () { '', (string) Helpers::createSelectBox( ['a' => 'First', 'b' => 'Second'], - ['disabled:' => TRUE, 'selected?' => 'b'] + ['disabled:' => true, 'selected?' => 'b'] ) ); diff --git a/tests/Forms/Helpers.exportRules.phpt b/tests/Forms/Helpers.exportRules.phpt index 9e45fdd4c..f89bfa501 100644 --- a/tests/Forms/Helpers.exportRules.phpt +++ b/tests/Forms/Helpers.exportRules.phpt @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php'; test(function () { $form = new Form; $input = $form->addText('text'); - $input->addRule(Form::FILLED, NULL, []); + $input->addRule(Form::FILLED, null, []); Assert::same([ [ 'op' => ':filled', @@ -39,7 +39,7 @@ test(function () { test(function () { $form = new Form; $input = $form->addText('text'); - $input->setRequired(FALSE); + $input->setRequired(false); $input->addRule(Form::EMAIL); Assert::same([ ['op' => 'optional'], @@ -52,12 +52,12 @@ test(function () { $form = new Form; $input1 = $form->addText('text1'); $input2 = $form->addText('text2'); - $input2->setRequired(FALSE); + $input2->setRequired(false); $input2->addConditionOn($input1, Form::EMAIL) - ->setRequired(TRUE) + ->setRequired(true) ->addRule($form::EMAIL); $input2->addConditionOn($input1, Form::INTEGER) - ->setRequired(FALSE) + ->setRequired(false) ->addRule($form::EMAIL); Assert::same([ diff --git a/tests/Forms/Helpers.extractHttpData.phpt b/tests/Forms/Helpers.extractHttpData.phpt index 5e5135d2a..40b2630aa 100644 --- a/tests/Forms/Helpers.extractHttpData.phpt +++ b/tests/Forms/Helpers.extractHttpData.phpt @@ -58,7 +58,7 @@ test(function () { // multiple test(function () { // files $file = new Nette\Http\FileUpload([ 'name' => 'license.txt', - 'type' => NULL, + 'type' => null, 'size' => 3013, 'tmpName' => 'tmp', 'error' => 0, @@ -67,15 +67,15 @@ test(function () { // files Assert::equal($file, Helpers::extractHttpData(['avatar' => $file], 'avatar', Form::DATA_FILE)); Assert::null(Helpers::extractHttpData([], 'missing', Form::DATA_FILE)); - Assert::null(Helpers::extractHttpData(['invalid' => NULL], 'invalid', Form::DATA_FILE)); - Assert::null(Helpers::extractHttpData(['invalid' => [NULL]], 'invalid', Form::DATA_FILE)); + Assert::null(Helpers::extractHttpData(['invalid' => null], 'invalid', Form::DATA_FILE)); + Assert::null(Helpers::extractHttpData(['invalid' => [null]], 'invalid', Form::DATA_FILE)); Assert::null(Helpers::extractHttpData([ 'multiple' => ['avatar' => [$file, $file]], ], 'multiple[avatar]', Form::DATA_FILE)); Assert::equal([$file, $file], Helpers::extractHttpData([ - 'multiple' => ['avatar' => ['x' => $file, NULL, $file]], + 'multiple' => ['avatar' => ['x' => $file, null, $file]], ], 'multiple[avatar][]', Form::DATA_FILE)); Assert::equal(['x' => $file, $file], Helpers::extractHttpData([ @@ -83,7 +83,7 @@ test(function () { // files ], 'multiple[avatar][]', Form::DATA_KEYS | Form::DATA_FILE)); Assert::same([], Helpers::extractHttpData([], 'missing[]', Form::DATA_FILE)); - Assert::same([], Helpers::extractHttpData(['invalid' => NULL], 'invalid[]', Form::DATA_FILE)); + Assert::same([], Helpers::extractHttpData(['invalid' => null], 'invalid[]', Form::DATA_FILE)); Assert::same([], Helpers::extractHttpData(['invalid' => $file], 'invalid[]', Form::DATA_FILE)); - Assert::same([], Helpers::extractHttpData(['invalid' => [NULL]], 'invalid[]', Form::DATA_FILE)); + Assert::same([], Helpers::extractHttpData(['invalid' => [null]], 'invalid[]', Form::DATA_FILE)); }); diff --git a/tests/Forms/Rules.dynamic.phpt b/tests/Forms/Rules.dynamic.phpt index 27e688883..bc7bd0d40 100644 --- a/tests/Forms/Rules.dynamic.phpt +++ b/tests/Forms/Rules.dynamic.phpt @@ -12,10 +12,10 @@ require __DIR__ . '/../bootstrap.php'; $datasets = [ - [['min' => '10', 'max' => '20', 'value' => 5], FALSE], - [['min' => '10', 'max' => '20', 'value' => 15], TRUE], - [['min' => '10', 'max' => '', 'value' => 15], TRUE], - [['min' => '10', 'max' => '', 'value' => 5], FALSE], + [['min' => '10', 'max' => '20', 'value' => 5], false], + [['min' => '10', 'max' => '20', 'value' => 15], true], + [['min' => '10', 'max' => '', 'value' => 15], true], + [['min' => '10', 'max' => '', 'value' => 5], false], ]; foreach ($datasets as $case) { @@ -23,7 +23,7 @@ foreach ($datasets as $case) { $form->addText('min'); $form->addText('max'); - $form->addText('value')->addRule(Form::RANGE, NULL, [$form['min'], $form['max']]); + $form->addText('value')->addRule(Form::RANGE, null, [$form['min'], $form['max']]); $form->setValues($case[0]); Assert::equal($case[1], $form->isValid()); diff --git a/tests/Forms/Rules.formatMessage.phpt b/tests/Forms/Rules.formatMessage.phpt index 095031710..55a7d6e88 100644 --- a/tests/Forms/Rules.formatMessage.phpt +++ b/tests/Forms/Rules.formatMessage.phpt @@ -48,4 +48,4 @@ Assert::same(['1 '], $form['args3']->getErrors()); Assert::same(['Label xyz is invalid [field special] xyz'], $form['special']->getErrors()); -Assert::match('%A%data-nette-rules=\'%A%{"op":":email","msg":"Label %value is invalid [field special] %0"%A%', $form->__toString(TRUE)); +Assert::match('%A%data-nette-rules=\'%A%{"op":":email","msg":"Label %value is invalid [field special] %0"%A%', $form->__toString(true)); diff --git a/tests/Forms/Rules.required.phpt b/tests/Forms/Rules.required.phpt index beb3f43ef..e5ad53810 100644 --- a/tests/Forms/Rules.required.phpt +++ b/tests/Forms/Rules.required.phpt @@ -65,14 +65,14 @@ test(function () { // 'required' is always the first rule }); -test(function () { // setRequired(FALSE) +test(function () { // setRequired(false) $form = new Form; $input = $form->addText('text'); $rules = $input->getRules(); $rules->addRule($form::EMAIL); $rules->addRule($form::REQUIRED); - $rules->setRequired(FALSE); + $rules->setRequired(false); $items = iterator_to_array($rules); Assert::count(1, $items); @@ -83,13 +83,13 @@ test(function () { // setRequired(FALSE) }); -test(function () { // setRequired(FALSE) and addConditionOn +test(function () { // setRequired(false) and addConditionOn $form = new Form; $form->addCheckbox('checkbox'); $input = $form->addText('text'); - $input->setRequired(FALSE) + $input->setRequired(false) ->addRule($form::EMAIL) - ->addConditionOn($form['checkbox'], $form::EQUAL, FALSE) + ->addConditionOn($form['checkbox'], $form::EQUAL, false) ->addRule($form::REQUIRED); Assert::false($input->getRules()->validate()); diff --git a/tests/Forms/Rules.static.phpt b/tests/Forms/Rules.static.phpt index af11271b7..72eb1d76e 100644 --- a/tests/Forms/Rules.static.phpt +++ b/tests/Forms/Rules.static.phpt @@ -11,7 +11,7 @@ require __DIR__ . '/../bootstrap.php'; test(function () { $form = new Form; $input = $form->addText('text'); - $input->addCondition(FALSE) + $input->addCondition(false) ->setRequired(); $rules = $input->getRules(); @@ -28,7 +28,7 @@ test(function () { test(function () { $form = new Form; $input = $form->addText('text'); - $input->addCondition(TRUE) + $input->addCondition(true) ->setRequired(); $rules = $input->getRules(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 323e5a983..e5b866014 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,11 +13,11 @@ date_default_timezone_set('Europe/Prague'); -function before(\Closure $function = NULL) +function before(\Closure $function = null) { static $val; if (!func_num_args()) { - return ($val ? $val() : NULL); + return ($val ? $val() : null); } $val = $function; }