Skip to content

Commit

Permalink
coding style: TRUE/FALSE/NULL -> true/false/null
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 11, 2017
1 parent bd1d48f commit f59098e
Show file tree
Hide file tree
Showing 93 changed files with 722 additions and 722 deletions.
6 changes: 3 additions & 3 deletions examples/basic-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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');
Expand All @@ -112,7 +112,7 @@

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

Expand Down
6 changes: 3 additions & 3 deletions examples/bootstrap2-rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/bootstrap3-rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/bootstrap4-rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions examples/custom-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}


Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion examples/localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/manual-rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
22 changes: 11 additions & 11 deletions src/Bridges/FormsLatte/FormMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -54,10 +54,10 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
throw new CompileException('Did you mean <form n:name=...> ?');
}
$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"
Expand All @@ -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();
Expand Down Expand Up @@ -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()');
}
Expand Down Expand Up @@ -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';
Expand All @@ -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)
);
}
}
Expand All @@ -202,7 +202,7 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer)
{
$tagName = strtolower($node->htmlNode->name);
if ($tagName === 'form') {
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), FALSE); ?>';
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false); ?>';
} elseif ($tagName === 'label') {
if ($node->htmlNode->empty) {
$node->innerContent = "<?php echo \$_input->getLabelPart()->getHtml() ?>";
Expand Down Expand Up @@ -238,15 +238,15 @@ 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);
}


/** @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);
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/FormsLatte/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')) {
Expand All @@ -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 .= "<!--[if IE]><input type=IEbug disabled style=\"display:none\"><![endif]-->\n";
}

Expand Down
Loading

0 comments on commit f59098e

Please sign in to comment.