for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\AdminApiBundle\Form\ChoiceList\Loader;
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
final class LazyCustomerLoader implements ChoiceLoaderInterface
{
/** @var CustomerRepositoryInterface */
private $customerRepository;
public function __construct(CustomerRepositoryInterface $customerRepository)
$this->customerRepository = $customerRepository;
}
public function loadChoiceList($value = null): ChoiceListInterface
return new ArrayChoiceList([], $value);
array()
array
object<Symfony\Component...rm\ChoiceList\iterable>
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);
public function loadChoicesForValues(array $values, $value = null): array
return $this->customerRepository->findBy(['email' => $values]);
public function loadValuesForChoices(array $choices, $value = null): array
/** Intentionally left blank, as in the only usage of this loader is in the context of api, where we don't need to load choices */
return [];
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: