for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace UniMan\Drivers\Redis\Forms;
use UniMan\Core\Forms\ItemForm\ItemFormInterface;
use Nette\Application\UI\Form;
use Nette\Utils\ArrayHash;
use RedisProxy\RedisProxy;
class RedisSortedSetMemberForm implements ItemFormInterface
{
private $connection;
private $key;
private $member;
public function __construct(RedisProxy $connection, $key, $member)
$this->connection = $connection;
$this->key = $key;
$this->member = $member;
}
public function addFieldsToForm(Form $form)
$form->addText('member', 'redis.sorted_set_member_form.member.label')
->setRequired('redis.sorted_set_member_form.member.required');
'redis.sorted_set_member_form.member.required'
string
boolean
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$form->addText('score', 'redis.sorted_set_member_form.score.label')
->setRequired('redis.sorted_set_member_form.score.required');
'redis.sorted_set_member_form.score.required'
if ($this->member !== null) {
$form->setDefaults([
'member' => $this->member,
'score' => $this->connection->zscore($this->key, $this->member),
]);
public function submit(Form $form, ArrayHash $values)
if ($this->member !== $values->member) {
$this->connection->zrem($this->key, $this->member);
$this->connection->zadd($this->key, [$values->member => str_replace(',', '.', $values->score)]);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: