Skip to content

Commit

Permalink
fixed typing errors reported by phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
uestla committed Sep 17, 2023
1 parent 25b4926 commit 141873d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/TwiGrid/Components/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public function addDictionary(array $dictionary): self
}


/** @param string ...$parameters */
/**
* @param string $message
* @param string ...$parameters
*/
public function translate($message, ...$parameters): string
{
assert(is_string($message));
Expand Down
18 changes: 16 additions & 2 deletions src/TwiGrid/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace TwiGrid;

use Nette\Utils\Arrays;
use Nette\Application\UI\Link;
use Nette\Http\SessionSection;
use TwiGrid\Components\Action;
Expand Down Expand Up @@ -293,7 +294,7 @@ public function setTranslator(ITranslator $translator): self

public function translate(string $s, int $count = null): string
{
return $this->getTranslator()->translate($s, $count);
return (string) $this->getTranslator()->translate($s, $count);
}


Expand Down Expand Up @@ -502,7 +503,20 @@ private function getRecordHandler(): RecordHandler
/** @param string|string[] $primaryKey */
public function setPrimaryKey($primaryKey): self
{
$this->getRecordHandler()->setPrimaryKey(is_array($primaryKey) ? $primaryKey : func_get_args());
if (is_array($primaryKey)) {
$keys = $primaryKey;

} else {
/** @var string[] $keys */
$keys = func_get_args();

assert(Arrays::every($keys, function ($s): bool {
return is_string($s);

}), 'Primary keys must be an array of strings.');
}

$this->getRecordHandler()->setPrimaryKey($keys);
return $this;
}

Expand Down

0 comments on commit 141873d

Please sign in to comment.