Skip to content

Commit b7fe4d1

Browse files
committed
removed prefix I from interfaces
1 parent 184407a commit b7fe4d1

15 files changed

+99
-59
lines changed

examples/custom-control.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function getControl()
9999
}
100100

101101

102-
public static function validateDate(Nette\Forms\IControl $control): bool
102+
public static function validateDate(Nette\Forms\Control $control): bool
103103
{
104104
return ctype_digit($control->day)
105105
&& ctype_digit($control->month)

src/Forms/Container.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function setValues($data, bool $erase = false)
7979
}
8080

8181
foreach ($this->getComponents() as $name => $control) {
82-
if ($control instanceof IControl) {
82+
if ($control instanceof Control) {
8383
if (array_key_exists($name, $values)) {
8484
$control->setValue($values[$name]);
8585

@@ -117,7 +117,7 @@ public function getValues($returnType = null)
117117

118118
foreach ($this->getComponents() as $name => $control) {
119119
$name = (string) $name;
120-
if ($control instanceof IControl && !$control->isOmitted()) {
120+
if ($control instanceof Control && !$control->isOmitted()) {
121121
$obj->$name = $control->getValue();
122122
} elseif ($control instanceof self) {
123123
$type = $isArray && !$control->mappedType
@@ -158,12 +158,12 @@ public function isValid(): bool
158158

159159
/**
160160
* Performs the server side validation.
161-
* @param IControl[]|null $controls
161+
* @param Control[]|null $controls
162162
*/
163163
public function validate(array $controls = null): void
164164
{
165165
foreach ($controls === null ? $this->getComponents() : $controls as $control) {
166-
if ($control instanceof IControl || $control instanceof self) {
166+
if ($control instanceof Control || $control instanceof self) {
167167
$control->validate();
168168
}
169169
}
@@ -236,7 +236,7 @@ public function addComponent(Nette\ComponentModel\IComponent $component, ?string
236236
*/
237237
public function getControls(): \Iterator
238238
{
239-
return $this->getComponents(true, IControl::class);
239+
return $this->getComponents(true, Control::class);
240240
}
241241

242242

src/Forms/IControl.php renamed to src/Forms/Control.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Defines method that must be implemented to allow a component to act like a form control.
1515
*/
16-
interface IControl
16+
interface Control
1717
{
1818
/**
1919
* Sets control's value.
@@ -40,3 +40,6 @@ function getErrors(): array;
4040
*/
4141
function isOmitted(): bool;
4242
}
43+
44+
45+
interface_exists(IControl::class);

src/Forms/ControlGroup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct()
3636
public function add(...$items)
3737
{
3838
foreach ($items as $item) {
39-
if ($item instanceof IControl) {
39+
if ($item instanceof Control) {
4040
$this->controls->attach($item);
4141

4242
} elseif ($item instanceof Container) {
@@ -48,14 +48,14 @@ public function add(...$items)
4848

4949
} else {
5050
$type = is_object($item) ? get_class($item) : gettype($item);
51-
throw new Nette\InvalidArgumentException("IControl or Container items expected, $type given.");
51+
throw new Nette\InvalidArgumentException("Control or Container items expected, $type given.");
5252
}
5353
}
5454
return $this;
5555
}
5656

5757

58-
public function remove(IControl $control): void
58+
public function remove(Control $control): void
5959
{
6060
$this->controls->detach($control);
6161
}
@@ -71,7 +71,7 @@ public function removeOrphans(): void
7171
}
7272

7373

74-
/** @return IControl[] */
74+
/** @return Control[] */
7575
public function getControls(): array
7676
{
7777
return iterator_to_array($this->controls);

src/Forms/Controls/BaseControl.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
namespace Nette\Forms\Controls;
1111

1212
use Nette;
13+
use Nette\Forms\Control;
1314
use Nette\Forms\Form;
14-
use Nette\Forms\IControl;
1515
use Nette\Forms\Rules;
1616
use Nette\Utils\Html;
1717

@@ -36,7 +36,7 @@
3636
* @property-read array $options
3737
* @property-read string $error
3838
*/
39-
abstract class BaseControl extends Nette\ComponentModel\Component implements IControl
39+
abstract class BaseControl extends Nette\ComponentModel\Component implements Control
4040
{
4141
/** @var string */
4242
public static $idMask = 'frm-%s';
@@ -149,7 +149,7 @@ public function getHtmlName(): string
149149
}
150150

151151

152-
/********************* interface IControl ****************d*g**/
152+
/********************* interface Control ****************d*g**/
153153

154154

155155
/**
@@ -445,7 +445,7 @@ public function addCondition($validator, $value = null): Rules
445445
* Adds a validation condition based on another control a returns new branch.
446446
* @return Rules new branch
447447
*/
448-
public function addConditionOn(IControl $control, $validator, $value = null): Rules
448+
public function addConditionOn(Control $control, $validator, $value = null): Rules
449449
{
450450
return $this->rules->addConditionOn($control, $validator, $value);
451451
}

src/Forms/Controls/SubmitButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @property-read bool $submittedBy
1919
*/
20-
class SubmitButton extends Button implements Nette\Forms\ISubmitterControl
20+
class SubmitButton extends Button implements Nette\Forms\SubmitterControl
2121
{
2222
/** @var callable[]&(callable(SubmitButton): void)[]; Occurs when the button is clicked and form is successfully validated */
2323
public $onClick;
@@ -69,7 +69,7 @@ public function setValidationScope(?iterable $scope)
6969
} else {
7070
$this->validationScope = [];
7171
foreach ($scope ?: [] as $control) {
72-
if (!$control instanceof Nette\Forms\Container && !$control instanceof Nette\Forms\IControl) {
72+
if (!$control instanceof Nette\Forms\Container && !$control instanceof Nette\Forms\Control) {
7373
throw new Nette\InvalidArgumentException('Validation scope accepts only Nette\Forms\Container or Nette\Forms\IControl instances.');
7474
}
7575
$this->validationScope[] = $control;

src/Forms/Form.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @property-read array $errors
2020
* @property-read array $ownErrors
2121
* @property-read Html $elementPrototype
22-
* @property-read IFormRenderer $renderer
22+
* @property-read FormRenderer $renderer
2323
* @property string $action
2424
* @property string $method
2525
*/
@@ -105,7 +105,7 @@ class Form extends Container implements Nette\Utils\IHtmlString
105105
/** @var Html element <form> */
106106
private $element;
107107

108-
/** @var IFormRenderer */
108+
/** @var FormRenderer */
109109
private $renderer;
110110

111111
/** @var Nette\Localization\ITranslator */
@@ -326,7 +326,7 @@ public function isAnchored(): bool
326326

327327
/**
328328
* Tells if the form was submitted.
329-
* @return ISubmitterControl|bool submittor control
329+
* @return SubmitterControl|bool submittor control
330330
*/
331331
public function isSubmitted()
332332
{
@@ -351,7 +351,7 @@ public function isSuccess(): bool
351351
* @return static
352352
* @internal
353353
*/
354-
public function setSubmittedBy(?ISubmitterControl $by)
354+
public function setSubmittedBy(?SubmitterControl $by)
355355
{
356356
$this->submittedBy = $by ?? false;
357357
return $this;
@@ -391,7 +391,7 @@ public function fireEvents(): void
391391
$this->validate();
392392
}
393393

394-
if ($this->submittedBy instanceof ISubmitterControl) {
394+
if ($this->submittedBy instanceof SubmitterControl) {
395395
if ($this->isValid()) {
396396
if ($handlers = $this->submittedBy->onClick) {
397397
if (!is_iterable($handlers)) {
@@ -483,7 +483,7 @@ protected function receiveHttpData(): ?array
483483
public function validate(array $controls = null): void
484484
{
485485
$this->cleanErrors();
486-
if ($controls === null && $this->submittedBy instanceof ISubmitterControl) {
486+
if ($controls === null && $this->submittedBy instanceof SubmitterControl) {
487487
$controls = $this->submittedBy->getValidationScope();
488488
}
489489
$this->validateMaxPostSize();
@@ -568,7 +568,7 @@ public function getElementPrototype(): Html
568568
* Sets form renderer.
569569
* @return static
570570
*/
571-
public function setRenderer(?IFormRenderer $renderer)
571+
public function setRenderer(?FormRenderer $renderer)
572572
{
573573
$this->renderer = $renderer;
574574
return $this;
@@ -578,7 +578,7 @@ public function setRenderer(?IFormRenderer $renderer)
578578
/**
579579
* Returns form renderer.
580580
*/
581-
public function getRenderer(): IFormRenderer
581+
public function getRenderer(): FormRenderer
582582
{
583583
if ($this->renderer === null) {
584584
$this->renderer = new Rendering\DefaultFormRenderer;

src/Forms/IFormRenderer.php renamed to src/Forms/FormRenderer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
/**
1414
* Defines method that must implement form renderer.
1515
*/
16-
interface IFormRenderer
16+
interface FormRenderer
1717
{
1818
/**
1919
* Provides complete form rendering.
2020
*/
2121
function render(Form $form): string;
2222
}
23+
24+
25+
interface_exists(IFormRenderer::class);

src/Forms/Helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ public static function exportRules(Rules $rules): array
128128
if (is_array($rule->arg)) {
129129
$item['arg'] = [];
130130
foreach ($rule->arg as $key => $value) {
131-
$item['arg'][$key] = $value instanceof IControl
131+
$item['arg'][$key] = $value instanceof Control
132132
? ['control' => $value->getHtmlName()]
133133
: $value;
134134
}
135135
} elseif ($rule->arg !== null) {
136-
$item['arg'] = $rule->arg instanceof IControl
136+
$item['arg'] = $rule->arg instanceof Control
137137
? ['control' => $rule->arg->getHtmlName()]
138138
: $rule->arg;
139139
}

src/Forms/Rendering/DefaultFormRenderer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Converts a Form into the HTML output.
1919
*/
20-
class DefaultFormRenderer implements Nette\Forms\IFormRenderer
20+
class DefaultFormRenderer implements Nette\Forms\FormRenderer
2121
{
2222
use Nette\SmartObject;
2323

@@ -213,7 +213,7 @@ public function renderEnd(): string
213213
/**
214214
* Renders validation errors (per form or per control).
215215
*/
216-
public function renderErrors(Nette\Forms\IControl $control = null, bool $own = true): string
216+
public function renderErrors(Nette\Forms\Control $control = null, bool $own = true): string
217217
{
218218
$errors = $control
219219
? $control->getErrors()
@@ -361,7 +361,7 @@ public function renderControls($parent): string
361361
/**
362362
* Renders single visual row.
363363
*/
364-
public function renderPair(Nette\Forms\IControl $control): string
364+
public function renderPair(Nette\Forms\Control $control): string
365365
{
366366
$pair = $this->getWrapper('pair container');
367367
$pair->addHtml($this->renderLabel($control));
@@ -379,13 +379,13 @@ public function renderPair(Nette\Forms\IControl $control): string
379379

380380
/**
381381
* Renders single visual row of multiple controls.
382-
* @param Nette\Forms\IControl[] $controls
382+
* @param Nette\Forms\Control[] $controls
383383
*/
384384
public function renderPairMulti(array $controls): string
385385
{
386386
$s = [];
387387
foreach ($controls as $control) {
388-
if (!$control instanceof Nette\Forms\IControl) {
388+
if (!$control instanceof Nette\Forms\Control) {
389389
throw new Nette\InvalidArgumentException('Argument must be array of Nette\Forms\IControl instances.');
390390
}
391391
$description = $control->getOption('description');
@@ -422,7 +422,7 @@ public function renderPairMulti(array $controls): string
422422
/**
423423
* Renders 'label' part of visual row of controls.
424424
*/
425-
public function renderLabel(Nette\Forms\IControl $control): Html
425+
public function renderLabel(Nette\Forms\Control $control): Html
426426
{
427427
$suffix = $this->getValue('label suffix') . ($control->isRequired() ? $this->getValue('label requiredsuffix') : '');
428428
$label = $control->getLabel();
@@ -441,7 +441,7 @@ public function renderLabel(Nette\Forms\IControl $control): Html
441441
/**
442442
* Renders 'control' part of visual row of controls.
443443
*/
444-
public function renderControl(Nette\Forms\IControl $control): Html
444+
public function renderControl(Nette\Forms\Control $control): Html
445445
{
446446
$body = $this->getWrapper('control container');
447447
if ($this->counter % 2) {

src/Forms/Rule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Rule
1919
{
2020
use Nette\SmartObject;
2121

22-
/** @var IControl */
22+
/** @var Control */
2323
public $control;
2424

2525
/** @var mixed */

src/Forms/Rules.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class Rules implements \IteratorAggregate
3636
/** @var array */
3737
private $toggles = [];
3838

39-
/** @var IControl */
39+
/** @var Control */
4040
private $control;
4141

4242

43-
public function __construct(IControl $control)
43+
public function __construct(Control $control)
4444
{
4545
$this->control = $control;
4646
}
@@ -137,7 +137,7 @@ public function addCondition($validator, $arg = null)
137137
* Adds a validation condition on specified control a returns new branch.
138138
* @return static new branch
139139
*/
140-
public function addConditionOn(IControl $control, $validator, $arg = null)
140+
public function addConditionOn(Control $control, $validator, $arg = null)
141141
{
142142
$rule = new Rule;
143143
$rule->control = $control;
@@ -189,7 +189,7 @@ public function addFilter(callable $filter)
189189
{
190190
$this->rules[] = $rule = new Rule;
191191
$rule->control = $this->control;
192-
$rule->validator = function (IControl $control) use ($filter): bool {
192+
$rule->validator = function (Control $control) use ($filter): bool {
193193
$control->setValue($filter($control->getValue()));
194194
return true;
195195
};
@@ -281,7 +281,7 @@ public static function validateRule(Rule $rule): bool
281281
{
282282
$args = is_array($rule->arg) ? $rule->arg : [$rule->arg];
283283
foreach ($args as &$val) {
284-
$val = $val instanceof IControl ? $val->getValue() : $val;
284+
$val = $val instanceof Control ? $val->getValue() : $val;
285285
}
286286
return $rule->isNegative
287287
xor self::getCallback($rule)($rule->control, is_array($rule->arg) ? $args : $args[0]);

src/Forms/ISubmitterControl.php renamed to src/Forms/SubmitterControl.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
/**
1414
* Defines method that must be implemented to allow a control to submit web form.
1515
*/
16-
interface ISubmitterControl extends IControl
16+
interface SubmitterControl extends Control
1717
{
1818
/**
1919
* Gets the validation scope. Clicking the button validates only the controls within the specified scope.
2020
*/
2121
function getValidationScope(): ?array;
2222
}
23+
24+
25+
interface_exists(ISubmitterControl::class);

0 commit comments

Comments
 (0)