Skip to content

Commit a16ae63

Browse files
committed
coding style: TRUE/FALSE/NULL -> true/false/null
1 parent 318c6b0 commit a16ae63

File tree

91 files changed

+703
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+703
-703
lines changed

examples/basic-example.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
// group Shipping address
5252
$form->addGroup('Shipping address')
53-
->setOption('embedNext', TRUE);
53+
->setOption('embedNext', true);
5454

5555
$form->addCheckbox('send', 'Ship to address')
5656
->addCondition($form::FILLED) // conditional rule: if is checkbox checked...
@@ -93,7 +93,7 @@
9393
->addRule($form::EQUAL, 'Passwords do not match', $form['password']);
9494

9595
$form->addUpload('avatar', 'Picture:')
96-
->setRequired(FALSE)
96+
->setRequired(false)
9797
->addRule($form::IMAGE, 'Uploaded file is not image');
9898

9999
$form->addHidden('userid');
@@ -114,7 +114,7 @@
114114

115115
if ($form->isSuccess()) {
116116
echo '<h2>Form was submitted and successfully validated</h2>';
117-
Dumper::dump($form->getValues(), [Dumper::COLLAPSE => FALSE]);
117+
Dumper::dump($form->getValues(), [Dumper::COLLAPSE => false]);
118118
exit;
119119
}
120120

examples/bootstrap2-rendering.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
function makeBootstrap2(Form $form)
2222
{
2323
$renderer = $form->getRenderer();
24-
$renderer->wrappers['controls']['container'] = NULL;
24+
$renderer->wrappers['controls']['container'] = null;
2525
$renderer->wrappers['pair']['container'] = 'div class=control-group';
2626
$renderer->wrappers['pair']['.error'] = 'error';
2727
$renderer->wrappers['control']['container'] = 'div class=controls';
@@ -35,9 +35,9 @@ function makeBootstrap2(Form $form)
3535
$type = $control->getOption('type');
3636
if ($type === 'button') {
3737
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn');
38-
$usedPrimary = TRUE;
38+
$usedPrimary = true;
3939

40-
} elseif (in_array($type, ['checkbox', 'radio'], TRUE)) {
40+
} elseif (in_array($type, ['checkbox', 'radio'], true)) {
4141
$control->getSeparatorPrototype()->setName('div')->addClass($type);
4242
}
4343
}

examples/bootstrap3-rendering.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
function makeBootstrap3(Form $form)
2222
{
2323
$renderer = $form->getRenderer();
24-
$renderer->wrappers['controls']['container'] = NULL;
24+
$renderer->wrappers['controls']['container'] = null;
2525
$renderer->wrappers['pair']['container'] = 'div class=form-group';
2626
$renderer->wrappers['pair']['.error'] = 'has-error';
2727
$renderer->wrappers['control']['container'] = 'div class=col-sm-9';
@@ -35,12 +35,12 @@ function makeBootstrap3(Form $form)
3535
$type = $control->getOption('type');
3636
if ($type === 'button') {
3737
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
38-
$usedPrimary = TRUE;
38+
$usedPrimary = true;
3939

40-
} elseif (in_array($type, ['text', 'textarea', 'select'], TRUE)) {
40+
} elseif (in_array($type, ['text', 'textarea', 'select'], true)) {
4141
$control->getControlPrototype()->addClass('form-control');
4242

43-
} elseif (in_array($type, ['checkbox', 'radio'], TRUE)) {
43+
} elseif (in_array($type, ['checkbox', 'radio'], true)) {
4444
$control->getSeparatorPrototype()->setName('div')->addClass($type);
4545
}
4646
}

examples/bootstrap4-rendering.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
function makeBootstrap4(Form $form)
2222
{
2323
$renderer = $form->getRenderer();
24-
$renderer->wrappers['controls']['container'] = NULL;
24+
$renderer->wrappers['controls']['container'] = null;
2525
$renderer->wrappers['pair']['container'] = 'div class="form-group row"';
2626
$renderer->wrappers['pair']['.error'] = 'has-danger';
2727
$renderer->wrappers['control']['container'] = 'div class=col-sm-9';
@@ -34,15 +34,15 @@ function makeBootstrap4(Form $form)
3434
$type = $control->getOption('type');
3535
if ($type === 'button') {
3636
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-secondary');
37-
$usedPrimary = TRUE;
37+
$usedPrimary = true;
3838

39-
} elseif (in_array($type, ['text', 'textarea', 'select'], TRUE)) {
39+
} elseif (in_array($type, ['text', 'textarea', 'select'], true)) {
4040
$control->getControlPrototype()->addClass('form-control');
4141

4242
} elseif ($type === 'file') {
4343
$control->getControlPrototype()->addClass('form-control-file');
4444

45-
} elseif (in_array($type, ['checkbox', 'radio'], TRUE)) {
45+
} elseif (in_array($type, ['checkbox', 'radio'], true)) {
4646
if ($control instanceof Nette\Forms\Controls\Checkbox) {
4747
$control->getLabelPrototype()->addClass('form-check-label');
4848
} else {

examples/custom-control.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ class DateInput extends Nette\Forms\Controls\BaseControl
2525
$year = '';
2626

2727

28-
public function __construct($label = NULL)
28+
public function __construct($label = null)
2929
{
3030
parent::__construct($label);
31-
$this->setRequired(FALSE)
31+
$this->setRequired(false)
3232
->addRule([__CLASS__, 'validateDate'], 'Date is invalid.');
3333
}
3434

3535

3636
public function setValue($value)
3737
{
38-
if ($value === NULL) {
38+
if ($value === null) {
3939
$this->day = $this->month = $this->year = '';
4040
} else {
4141
$date = Nette\Utils\DateTime::from($value);
@@ -48,13 +48,13 @@ public function setValue($value)
4848

4949

5050
/**
51-
* @return DateTimeImmutable|NULL
51+
* @return DateTimeImmutable|null
5252
*/
5353
public function getValue()
5454
{
5555
return self::validateDate($this)
5656
? (new DateTimeImmutable)->setDate((int) $this->year, (int) $this->month, (int) $this->day)->setTime(0, 0)
57-
: NULL;
57+
: null;
5858
}
5959

6060

@@ -88,7 +88,7 @@ public function getControl()
8888
'type' => 'number',
8989
'min' => 1,
9090
'max' => 31,
91-
'data-nette-rules' => Helpers::exportRules($this->getRules()) ?: NULL,
91+
'data-nette-rules' => Helpers::exportRules($this->getRules()) ?: null,
9292
])
9393

9494
. Helpers::createSelectBox(

examples/custom-rendering.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
// setup custom rendering
2424
$renderer = $form->getRenderer();
2525
$renderer->wrappers['form']['container'] = Html::el('div')->id('form');
26-
$renderer->wrappers['group']['container'] = NULL;
26+
$renderer->wrappers['group']['container'] = null;
2727
$renderer->wrappers['group']['label'] = 'h3';
28-
$renderer->wrappers['pair']['container'] = NULL;
28+
$renderer->wrappers['pair']['container'] = null;
2929
$renderer->wrappers['controls']['container'] = 'dl';
3030
$renderer->wrappers['control']['container'] = 'dd';
3131
$renderer->wrappers['control']['.odd'] = 'odd';

examples/localization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function __construct(array $table)
3333
/**
3434
* Translates the given string.
3535
*/
36-
public function translate($message, int $count = NULL): string
36+
public function translate($message, int $count = null): string
3737
{
3838
return $this->table[$message] ?? $message;
3939
}

examples/manual-rendering.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
$form->addText('age')
2626
->setRequired('Enter your age');
2727

28-
$form->addRadioList('gender', NULL, [
28+
$form->addRadioList('gender', null, [
2929
'm' => 'male',
3030
'f' => 'female',
3131
]);
3232

3333
$form->addText('email')
34-
->setRequired(FALSE)
34+
->setRequired(false)
3535
->addRule($form::EMAIL, 'Incorrect email address');
3636

3737
$form->addSubmit('submit');

src/Bridges/FormsLatte/FormMacros.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function install(Latte\Compiler $compiler)
3434
$me = new static($compiler);
3535
$me->addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));');
3636
$me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = $_form = end($this->global->formsStack)');
37-
$me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], NULL, self::AUTO_EMPTY);
37+
$me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY);
3838
$me->addMacro('input', [$me, 'macroInput']);
3939
$me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']);
4040
$me->addMacro('inputError', [$me, 'macroInputError']);
@@ -56,10 +56,10 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
5656
throw new CompileException('Did you mean <form n:name=...> ?');
5757
}
5858
$name = $node->tokenizer->fetchWord();
59-
if ($name === FALSE) {
59+
if ($name === false) {
6060
throw new CompileException('Missing form name in ' . $node->getNotation());
6161
}
62-
$node->replaced = TRUE;
62+
$node->replaced = true;
6363
$node->tokenizer->reset();
6464
return $writer->write(
6565
"/* line $node->startLine */\n"
@@ -79,7 +79,7 @@ public function macroFormContainer(MacroNode $node, PhpWriter $writer)
7979
throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
8080
}
8181
$name = $node->tokenizer->fetchWord();
82-
if ($name === FALSE) {
82+
if ($name === false) {
8383
throw new CompileException('Missing name in ' . $node->getNotation());
8484
}
8585
$node->tokenizer->reset();
@@ -120,7 +120,7 @@ public function macroLabel(MacroNode $node, PhpWriter $writer)
120120
*/
121121
public function macroLabelEnd(MacroNode $node, PhpWriter $writer)
122122
{
123-
if ($node->content != NULL) {
123+
if ($node->content != null) {
124124
$node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>';
125125
return $writer->write('if ($_label) echo $_label->endTag()');
126126
}
@@ -173,8 +173,8 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
173173
$name
174174
);
175175
return $writer->write(
176-
'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %0.var, FALSE)',
177-
array_fill_keys(array_keys($node->htmlNode->attrs), NULL)
176+
'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %0.var, false)',
177+
array_fill_keys(array_keys($node->htmlNode->attrs), null)
178178
);
179179
} else {
180180
$method = $tagName === 'label' ? 'getLabel' : 'getControl';
@@ -184,7 +184,7 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
184184
. ($node->htmlNode->attrs ? '->addAttributes(%2.var)' : '') . '->attributes()',
185185
$name,
186186
$method . 'Part(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')',
187-
array_fill_keys(array_keys($node->htmlNode->attrs), NULL)
187+
array_fill_keys(array_keys($node->htmlNode->attrs), null)
188188
);
189189
}
190190
}
@@ -204,7 +204,7 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer)
204204
{
205205
$tagName = strtolower($node->htmlNode->name);
206206
if ($tagName === 'form') {
207-
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), FALSE); ?>';
207+
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?>';
208208
} elseif ($tagName === 'label') {
209209
if ($node->htmlNode->empty) {
210210
$node->innerContent = "<?php echo \$_input->getLabelPart()->getHtml() ?>";

src/Bridges/FormsLatte/Runtime.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class Runtime
2525
/**
2626
* Renders form begin.
2727
*/
28-
public static function renderFormBegin(Form $form, array $attrs, bool $withTags = TRUE): string
28+
public static function renderFormBegin(Form $form, array $attrs, bool $withTags = true): string
2929
{
3030
$form->fireRenderEvents();
3131
foreach ($form->getControls() as $control) {
32-
$control->setOption('rendered', FALSE);
32+
$control->setOption('rendered', false);
3333
}
3434
$el = $form->getElementPrototype();
3535
$el->action = (string) $el->action;
@@ -45,7 +45,7 @@ public static function renderFormBegin(Form $form, array $attrs, bool $withTags
4545
/**
4646
* Renders form end.
4747
*/
48-
public static function renderFormEnd(Form $form, bool $withTags = TRUE): string
48+
public static function renderFormEnd(Form $form, bool $withTags = true): string
4949
{
5050
$s = '';
5151
if ($form->isMethod('get')) {
@@ -64,7 +64,7 @@ public static function renderFormEnd(Form $form, bool $withTags = TRUE): string
6464
}
6565
}
6666

67-
if (iterator_count($form->getComponents(TRUE, Nette\Forms\Controls\TextInput::class)) < 2) {
67+
if (iterator_count($form->getComponents(true, Nette\Forms\Controls\TextInput::class)) < 2) {
6868
$s .= "<!--[if IE]><input type=IEbug disabled style=\"display:none\"><![endif]-->\n";
6969
}
7070

0 commit comments

Comments
 (0)