Skip to content
Merged

5.6 #93

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
Expand All @@ -12,7 +10,7 @@ matrix:
- php: hhvm

include:
- php: 5.5
- php: 5.6
env: dependencies="--prefer-lowest --prefer-stable"

script:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=5.4.4",
"php": ">=5.6.0",
"nette/component-model": "~2.2",
"nette/http": "~2.2",
"nette/utils": "~2.2"
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/FormsLatte/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public static function renderFormEnd(Form $form, $withTags = TRUE)
}
}

foreach ($form->getComponents(TRUE, 'Nette\Forms\Controls\HiddenField') as $control) {
foreach ($form->getComponents(TRUE, Nette\Forms\Controls\HiddenField::class) as $control) {
if (!$control->getOption('rendered')) {
$s .= $control->getControl();
}
}

if (iterator_count($form->getComponents(TRUE, 'Nette\Forms\Controls\TextInput')) < 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
4 changes: 2 additions & 2 deletions src/Forms/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function addComponent(Nette\ComponentModel\IComponent $component, $name,
*/
public function getControls()
{
return $this->getComponents(TRUE, 'Nette\Forms\IControl');
return $this->getComponents(TRUE, IControl::class);
}


Expand All @@ -218,7 +218,7 @@ public function getControls()
*/
public function getForm($need = TRUE)
{
return $this->lookup('Nette\Forms\Form', $need);
return $this->lookup(Form::class, $need);
}


Expand Down
6 changes: 3 additions & 3 deletions src/Forms/Controls/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo
*/
public function __construct($caption = NULL)
{
$this->monitor('Nette\Forms\Form');
$this->monitor(Form::class);
parent::__construct();
$this->control = Html::el('input', ['type' => NULL, 'name' => NULL]);
$this->label = Html::el('label');
Expand Down Expand Up @@ -105,7 +105,7 @@ protected function attached($form)
*/
public function getForm($need = TRUE)
{
return $this->lookup('Nette\Forms\Form', $need);
return $this->lookup(Form::class, $need);
}


Expand Down Expand Up @@ -135,7 +135,7 @@ public function getHttpData($type, $htmlTail = NULL)
*/
public function getHtmlName()
{
return Nette\Forms\Helpers::generateHtmlName($this->lookupPath('Nette\Forms\Form'));
return Nette\Forms\Helpers::generateHtmlName($this->lookupPath(Form::class));
}


Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Controls/CsrfProtection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct($message)
{
parent::__construct();
$this->setOmitted()->addRule(self::PROTECTION, $message);
$this->monitor('Nette\Application\UI\Presenter');
$this->monitor(Nette\Application\UI\Presenter::class);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Controls/HiddenField.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct($persistentValue = NULL)
parent::__construct();
$this->control->type = 'hidden';
if ($persistentValue !== NULL) {
$this->unmonitor('Nette\Forms\Form');
$this->unmonitor(Nette\Forms\Form::class);
$this->persistValue = TRUE;
$this->value = (string) $persistentValue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Controls/SubmitButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getControl($caption = NULL)
{
$scope = [];
foreach ((array) $this->validationScope as $control) {
$scope[] = $control->lookupPath('Nette\Forms\Form');
$scope[] = $control->lookupPath(Nette\Forms\Form::class);
}
return parent::getControl($caption)->addAttributes([
'formnovalidate' => $this->validationScope !== NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Rendering/DefaultFormRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function renderEnd()
$s .= $control->getControl();
}
}
if (iterator_count($this->form->getComponents(TRUE, 'Nette\Forms\Controls\TextInput')) < 2) {
if (iterator_count($this->form->getComponents(TRUE, Nette\Forms\Controls\TextInput::class)) < 2) {
$s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
}
if ($s) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms.DI/FormsExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ Assert::exception(function () {
', 'neon'));

eval($compiler->compile($config, 'Container2'));
}, 'Nette\InvalidArgumentException', 'Constant Nette\Forms\Form::Foo\Bar or constant Foo\Bar does not exist.');
}, Nette\InvalidArgumentException::class, 'Constant Nette\Forms\Form::Foo\Bar or constant Foo\Bar does not exist.');
16 changes: 8 additions & 8 deletions tests/Forms.Latte/FormMacros.error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ FormMacros::install($latte->getCompiler());

Assert::exception(function () use ($latte) {
$latte->compile('<form n:form></form>');
}, 'Latte\CompileException', 'Did you mean <form n:name=...> ?');
}, Latte\CompileException::class, 'Did you mean <form n:name=...> ?');

Assert::exception(function () use ($latte) {
$latte->compile('<form n:name></form>');
}, 'Latte\CompileException', 'Missing name in n:name.');
}, Latte\CompileException::class, 'Missing name in n:name.');

Assert::exception(function () use ($latte) {
$latte->compile('<form n:inner-name></form>');
}, 'Latte\CompileException', 'Unknown attribute n:inner-name, use n:name attribute.');
}, Latte\CompileException::class, 'Unknown attribute n:inner-name, use n:name attribute.');


Assert::exception(function () use ($latte) {
$latte->compile('<html>{form /}');
}, 'Latte\CompileException', 'Missing form name in {form}.');
}, Latte\CompileException::class, 'Missing form name in {form}.');

Assert::exception(function () use ($latte) {
$latte->compile('<html>{formContainer /}');
}, 'Latte\CompileException', 'Missing name in {formContainer}.');
}, Latte\CompileException::class, 'Missing name in {formContainer}.');


Assert::exception(function () use ($latte) {
$latte->compile('<html>{label /}');
}, 'Latte\CompileException', 'Missing name in {label}.');
}, Latte\CompileException::class, 'Missing name in {label}.');

Assert::exception(function () use ($latte) {
$latte->compile('<html>{input /}');
}, 'Latte\CompileException', 'Missing name in {input}.');
}, Latte\CompileException::class, 'Missing name in {input}.');

Assert::exception(function () use ($latte) {
$latte->compile('<html>{name /}');
}, 'Latte\CompileException', 'Unknown macro {name}, use n:name attribute.');
}, Latte\CompileException::class, 'Unknown macro {name}, use n:name attribute.');
4 changes: 2 additions & 2 deletions tests/Forms/Controls.Button.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test(function () {
$input = $form->addButton('button', 'Caption');

Assert::null($input->getLabel());
Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<input type="button" name="button" value="Caption">', (string) $input->getControl());
Assert::same('<input type="button" name="button" value="Another caption">', (string) $input->getControl('Another caption'));
});
Expand Down Expand Up @@ -74,7 +74,7 @@ test(function () { // SubmitButton
$input = $form->addSubmit('button', 'Caption');

Assert::null($input->getLabel());
Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<input type="submit" name="button" value="Caption">', (string) $input->getControl());
Assert::same('<input type="submit" name="button" value="Another caption">', (string) $input->getControl('Another caption'));
});
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.Checkbox.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ test(function () { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue([]);
}, 'Nette\InvalidArgumentException', "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'.");
});
6 changes: 3 additions & 3 deletions tests/Forms/Controls.Checkbox.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ test(function () {

Assert::null($input->getLabel());

Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<label for="frm-on"><input type="checkbox" name="on" id="frm-on">Label</label>', (string) $input->getControl());

Assert::type('Nette\Utils\Html', $input->getLabelPart());
Assert::type(Nette\Utils\Html::class, $input->getLabelPart());
Assert::same('<label for="frm-on">Label</label>', (string) $input->getLabelPart());

Assert::type('Nette\Utils\Html', $input->getControlPart());
Assert::type(Nette\Utils\Html::class, $input->getControlPart());
Assert::same('<input type="checkbox" name="on" id="frm-on">', (string) $input->getControlPart());

$input->setValue(TRUE);
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.CheckboxList.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ test(function () use ($series) { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue('unknown');
}, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'list'.");
}, Nette\InvalidArgumentException::class, "Value 'unknown' are out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'list'.");
});


Expand Down
6 changes: 3 additions & 3 deletions tests/Forms/Controls.CheckboxList.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ test(function () {
0 => 'Second',
]);

Assert::type('Nette\Utils\Html', $input->getLabel());
Assert::type(Nette\Utils\Html::class, $input->getLabel());
Assert::same('<label>Label</label>', (string) $input->getLabel());
Assert::same('<label>Another label</label>', (string) $input->getLabel('Another label'));

Assert::type('Nette\Utils\Html', $input->getLabelPart(0));
Assert::type(Nette\Utils\Html::class, $input->getLabelPart(0));
Assert::same('<label for="frm-list-0">Second</label>', (string) $input->getLabelPart(0));

Assert::type('string', $input->getControl());
Assert::same('<label><input type="checkbox" name="list[]" value="a">First</label><br><label><input type="checkbox" name="list[]" value="0">Second</label>', $input->getControl());

Assert::type('Nette\Utils\Html', $input->getControlPart(0));
Assert::type(Nette\Utils\Html::class, $input->getControlPart(0));
Assert::same('<input type="checkbox" name="list[]" id="frm-list-0" value="0">', (string) $input->getControlPart(0));
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.ChoiceControl.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ test(function () use ($series) { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue('unknown');
}, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
}, Nette\InvalidArgumentException::class, "Value 'unknown' is out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
});


Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.HiddenField.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test(function () { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue([]);
}, 'Nette\InvalidArgumentException', "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'.");
});


Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.HiddenField.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test(function () {
$input = $form->addHidden('hidden', 'value');

Assert::null($input->getLabel());
Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<input type="hidden" name="hidden" value="value">', (string) $input->getControl());
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.ImageButton.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test(function () {
$input = $form->addImage('button', 'image.gif');

Assert::null($input->getLabel());
Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<input type="image" name="button[]" src="image.gif">', (string) $input->getControl());
});

Expand Down
10 changes: 5 additions & 5 deletions tests/Forms/Controls.MultiChoiceControl.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ test(function () use ($series) { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue('unknown');
}, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
}, Nette\InvalidArgumentException::class, "Value 'unknown' are out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");

Assert::exception(function () use ($input) {
$input->setValue(new stdClass);
}, 'Nette\InvalidArgumentException', "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]);
}, 'Nette\InvalidArgumentException', "Values must be scalar, object given in field 'select'.");
}, Nette\InvalidArgumentException::class, "Values must be scalar, object given in field 'select'.");
});


Expand All @@ -181,11 +181,11 @@ test(function () use ($series) { // setValue() and disabled $checkAllowedValues

Assert::exception(function () use ($input) {
$input->setValue(new stdClass);
}, 'Nette\InvalidArgumentException', "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]);
}, 'Nette\InvalidArgumentException', "Values must be scalar, object given in field 'select'.");
}, Nette\InvalidArgumentException::class, "Values must be scalar, object given in field 'select'.");
});


Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.MultiSelectBox.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ test(function () use ($series) { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue('unknown');
}, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
}, Nette\InvalidArgumentException::class, "Value 'unknown' are out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
});


Expand Down
4 changes: 2 additions & 2 deletions tests/Forms/Controls.MultiSelectBox.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ test(function () {
0 => 'Second',
]);

Assert::type('Nette\Utils\Html', $input->getLabel());
Assert::type(Nette\Utils\Html::class, $input->getLabel());
Assert::same('<label for="frm-list">Label</label>', (string) $input->getLabel());
Assert::same('<label for="frm-list">Another label</label>', (string) $input->getLabel('Another label'));

Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<select name="list[]" id="frm-list" multiple><option value="a">First</option><option value="0">Second</option></select>', (string) $input->getControl());
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.RadioList.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ test(function () use ($series) { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue('unknown');
}, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'radio'.");
}, Nette\InvalidArgumentException::class, "Value 'unknown' is out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'radio'.");
});


Expand Down
8 changes: 4 additions & 4 deletions tests/Forms/Controls.RadioList.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ test(function () {
0 => 'Second',
]);

Assert::type('Nette\Utils\Html', $input->getLabel());
Assert::type(Nette\Utils\Html::class, $input->getLabel());
Assert::same('<label>Label</label>', (string) $input->getLabel());
Assert::same('<label>Another label</label>', (string) $input->getLabel('Another label'));

Assert::type('Nette\Utils\Html', $input->getLabelPart(0));
Assert::type(Nette\Utils\Html::class, $input->getLabelPart(0));
Assert::same('<label for="frm-list-0">Second</label>', (string) $input->getLabelPart(0));

Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<label><input type="radio" name="list" value="a">First</label><br><label><input type="radio" name="list" value="0">Second</label>', (string) $input->getControl());

Assert::type('Nette\Utils\Html', $input->getControlPart(0));
Assert::type(Nette\Utils\Html::class, $input->getControlPart(0));
Assert::same('<input type="radio" name="list" id="frm-list-0" value="0">', (string) $input->getControlPart(0));
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Controls.SelectBox.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ test(function () use ($series) { // setValue() and invalid argument

Assert::exception(function () use ($input) {
$input->setValue('unknown');
}, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
}, Nette\InvalidArgumentException::class, "Value 'unknown' is out of allowed set ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'.");
});


Expand Down
4 changes: 2 additions & 2 deletions tests/Forms/Controls.SelectBox.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ test(function () {
0 => 'Second',
]);

Assert::type('Nette\Utils\Html', $input->getLabel());
Assert::type(Nette\Utils\Html::class, $input->getLabel());
Assert::same('<label for="frm-list">Label</label>', (string) $input->getLabel());
Assert::same('<label for="frm-list">Another label</label>', (string) $input->getLabel('Another label'));

Assert::type('Nette\Utils\Html', $input->getControl());
Assert::type(Nette\Utils\Html::class, $input->getControl());
Assert::same('<select name="list" id="frm-list"><option value="a">First</option><option value="0">Second</option></select>', (string) $input->getControl());
});

Expand Down
Loading