Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coding style issues #95

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
12 changes: 6 additions & 6 deletions src/Multiplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@
/** @var Container[] */
protected array $noValidate = [];

protected ComponentResolver $resolver;

private ?Form $form = null;

private bool $attachedCalled = false;

/** @var ComponentResolver */
protected ComponentResolver $resolver;

public function __construct(callable $factory, int $copyNumber = 1, ?int $maxCopies = null)
{
$this->factory = $factory;
Expand Down Expand Up @@ -216,6 +215,7 @@
if ($this->created === true) {
return;
}

$this->created = true;

if (!isset($this->resolver)) {
Expand All @@ -236,7 +236,7 @@
$this->totalCopies >= $this->minCopies &&
!$this->resolver->reachedMinLimit()
) {
$this->form->setSubmittedBy($this->removeButton->create($this));

Check failure on line 239 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Cannot call method create() on Contributte\FormMultiplier\Buttons\RemoveButton|null.

$this->resetFormEvents();

Expand Down Expand Up @@ -281,7 +281,7 @@
* @return object|mixed[]
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint
*/
public function getValues($returnType = null, ?array $controls = null): object|array

Check failure on line 284 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Method Contributte\FormMultiplier\Multiplier::getValues() has parameter $returnType with no type specified.
{
if (!$this->resetKeys) {
return parent::getValues($returnType, $controls);
Expand All @@ -291,7 +291,7 @@
$values = parent::getValues('array', $controls);
$values = array_values($values);

$returnType = $returnType === true ? 'array' : $returnType; // @phpstan-ignore-line nette backwards compatibility

Check failure on line 294 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

No error to ignore is reported on line 294.

return $returnType === 'array' ? $values : ArrayHash::from($values);
}
Expand Down Expand Up @@ -338,7 +338,7 @@

$this->created = false;
$this->detachCreateButtons();
$this->resolver = new ComponentResolver($this->values, $this->maxCopies, $this->minCopies);
$this->resolver = new ComponentResolver($this->values, $this->maxCopies, $this->minCopies);
$this->createCopies();
}

Expand Down Expand Up @@ -386,8 +386,8 @@
protected function loadHttpData(): void
{
if ($this->isFormSubmitted()) {
$httpData = Arrays::get($this->form->getHttpData(), $this->getHtmlName(), []);
$this->resolver = new ComponentResolver($httpData ?? [], $this->maxCopies, $this->minCopies);
$httpData = Arrays::get($this->form->getHttpData(), $this->getHtmlName(), []);

Check failure on line 389 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Cannot call method getHttpData() on Nette\Forms\Form|null.
$this->resolver = new ComponentResolver($httpData ?? [], $this->maxCopies, $this->minCopies);
}
}

Expand All @@ -411,7 +411,7 @@
*/
protected function getHtmlName(): array
{
return explode('-', $this->lookupPath(Form::class) ?? '');

Check failure on line 414 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Expression on left side of ?? is not nullable.
}

protected function createContainer(): Container
Expand Down
Loading