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 tests with nette/component-model 3.1.0 #91

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"webchemistry/testing-helpers": "~2.0.0"
},
"conflict": {
"latte/latte": "<3.0.0"
"latte/latte": "<3.0.0",
"nette/component-model": "<3.1.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 7 additions & 7 deletions src/Multiplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@

private bool $attachedCalled = false;

/** @var ComponentResolver */

Check failure on line 69 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.1)

Property \Contributte\FormMultiplier\Multiplier::$resolver has useless @var annotation.
protected ComponentResolver $resolver;

Check failure on line 70 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.1)

The placement of "protected properties" group is invalid. Last group was "private properties" and one of these is expected after it: private properties, constructor, destructor, static constructors, public static abstract methods, public static final methods, public static methods, public abstract methods, public final methods, public methods, protected static abstract methods, protected static final methods, protected static methods, protected abstract methods, protected final methods, protected methods, private static methods, private methods, magic methods

public function __construct(callable $factory, int $copyNumber = 1, ?int $maxCopies = null)
{
Expand Down Expand Up @@ -170,7 +170,7 @@
public function validate(?array $controls = null): void
{
/** @var Control[] $components */
$components = $controls ?? iterator_to_array($this->getComponents());
$components = $controls ?? $this->getComponents();

foreach ($components as $index => $control) {
foreach ($this->noValidate as $item) {
Expand Down Expand Up @@ -213,7 +213,7 @@

public function createCopies(bool $forceValues = false): void
{
if ($this->created === true) {

Check failure on line 216 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.1)

Expected 1 line after "if", found 0.
return;
}
$this->created = true;
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 All @@ -307,14 +307,14 @@
}

/**
* @return Iterator<int|string,Container>
* @return array<int|string,Container>
*/
public function getContainers(): Iterator
public function getContainers(): iterable
{
$this->createCopies();

/** @var Iterator<int|string,Container> $containers */
$containers = $this->getComponents(false, Container::class);
/** @var array<int|string,Container> $containers */
$containers = array_filter($this->getComponents(), fn ($component) => $component instanceof Container);

Check failure on line 317 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $array of function array_filter expects array, Iterator<int|string, Nette\ComponentModel\IComponent> given.

return $containers;
}
Expand All @@ -338,7 +338,7 @@

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

Check failure on line 341 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.1)

Tabs must be used to indent lines; spaces are not allowed
$this->createCopies();
}

Expand Down Expand Up @@ -386,14 +386,14 @@
protected function loadHttpData(): void
{
if ($this->isFormSubmitted()) {
$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 / Codesniffer / Codesniffer (8.1)

Tabs must be used to indent lines; spaces are not allowed

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);

Check failure on line 390 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.1)

Tabs must be used to indent lines; spaces are not allowed
}
}

protected function createNumber(): int
{
$count = iterator_count($this->getComponents(false, Form::class));
$count = count(array_filter($this->getComponents(), fn ($component) => $component instanceof Form));

Check failure on line 396 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $array of function array_filter expects array, Iterator<int|string, Nette\ComponentModel\IComponent> given.
while ($this->getComponent((string) $count, false)) {
$count++;
}
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 All @@ -428,7 +428,7 @@
*/
protected function getFirstSubmit(): ?string
{
$submits = iterator_to_array($this->getComponents(false, SubmitButton::class));
$submits = array_filter($this->getComponents(), fn ($component) => $component instanceof SubmitButton);

Check failure on line 431 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $array of function array_filter expects array, Iterator<int|string, Nette\ComponentModel\IComponent> given.
if ($submits) {
return reset($submits)->getName();
}
Expand Down
Loading