-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiplier: Add missing param typehint to getValues
This fixes the following PHPStan errors: 280 Method Contributte\FormMultiplier\Multiplier::getValues() has parameter $returnType with no type specified. 290 No error to ignore is reported on line 290. Let’s also deprecate passing bool `$returnType` deprecated like `nette/forms` 3.2.0 does: nette/forms@0a812bd Also use Array constant made public in 3.1.12: nette/forms@0be7b3d
- Loading branch information
Showing
2 changed files
with
9 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,9 +277,9 @@ public function resetFormEvents(): void | |
} | ||
|
||
/** | ||
* @param string|object|bool|null $returnType 'array' for array | ||
* @param Control[]|null $controls | ||
* @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 GitHub Actions / Codesniffer / Codesniffer (8.1)
|
||
{ | ||
|
@@ -288,12 +288,15 @@ public function getValues($returnType = null, ?array $controls = null): object|a | |
} | ||
|
||
/** @var mixed[] $values */ | ||
$values = parent::getValues('array', $controls); | ||
$values = parent::getValues(self::Array, $controls); | ||
$values = array_values($values); | ||
|
||
$returnType = $returnType === true ? 'array' : $returnType; // @phpstan-ignore-line nette backwards compatibility | ||
if ($returnType === true) { | ||
trigger_error(static::class . '::' . __FUNCTION__ . "(true) is deprecated, use getValues('array').", E_USER_DEPRECATED); | ||
$returnType = self::Array; | ||
} | ||
|
||
return $returnType === 'array' ? $values : ArrayHash::from($values); | ||
return $returnType === self::Array ? $values : ArrayHash::from($values); | ||
} | ||
|
||
/** | ||
|
@@ -453,7 +456,7 @@ protected function removeComponentProperly(IComponent $component): void | |
private function createComponents(bool $forceValues = false): void | ||
{ | ||
$containers = []; | ||
$containerDefaults = $this->createContainer()->getValues('array'); | ||
$containerDefaults = $this->createContainer()->getValues(self::Array); | ||
|
||
// Components from httpData | ||
if ($this->isFormSubmitted() && !$forceValues) { | ||
|