for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ScayTrase\Api\Cruds\Adaptors\Symfony;
use ScayTrase\Api\Cruds\Exception\EntityProcessingException;
use ScayTrase\Api\Cruds\Exception\MapperException;
use ScayTrase\Api\Cruds\PropertyMapperInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
final class MappedEntityFormFactory
{
/** @var FormFactoryInterface */
private $factory;
/** @var PropertyMapperInterface */
private $mapper;
/**
* MappedEntityFormFactory constructor.
*
* @param FormFactoryInterface $factory
* @param PropertyMapperInterface $mapper
*/
public function __construct(FormFactoryInterface $factory, PropertyMapperInterface $mapper)
$this->factory = $factory;
$this->mapper = $mapper;
}
* @param $className
* @return FormInterface
* @throws EntityProcessingException
public function createFormForClass($className)
$form = $this->factory->create();
try {
foreach ($this->mapper->getApiProperties($className) as $apiProperty) {
$form->add(
$apiProperty,
$this->factory->createForProperty(
$this->factory->createFo...assName, $apiProperty))
object<Symfony\Component\Form\FormInterface>
string|null
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);
$className,
$this->mapper->getObjectProperty($className, $apiProperty)
)
);
} catch (\Exception $exception) {
throw new EntityProcessingException(
sprintf(
'Cannot create form for class %s: %s',
$exception->getMessage()
),
$exception->getCode(),
$exception
return $form;
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: