Php Can';t使用symfony表格在我的数据库中注册实体

Php Can';t使用symfony表格在我的数据库中注册实体,php,symfony,Php,Symfony,我是symphony的新手,我试着用表单在我的基础中注册一个实体。 表格如下: <?php namespace App\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\For

我是symphony的新手,我试着用表单在我的基础中注册一个实体。 表格如下:

<?php
namespace App\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;

class OfferType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('title', TextType::class, array('label' => '*Title: ' , 'attr' => array('class' => 'input2')))
        ->add('nameofgame', TextType::class, array('label' => 'Name of the Game:','attr' => array('class' => 'create button1')))
        ->add('description', TextType::class, array('label' => 'Description: ' , 'attr' => array('class' => 'input2')))
        ->add('price', MoneyType::class, array('label' => '*Price: ' , 'attr' => array('class' => 'input2')))
        ->add('numbertelephone', TelType::class, array('label' => 'Telephone Number:','attr' => array('class' => 'create button1')))
        ->add('save', SubmitType::class, array('label' => 'Post Offer','attr' => array('class' => 'create button1')))
    ;
}
}
当我试图注册一个报价时,它会说“预期参数类型”App\Entity\double,“double”given“,但问题是我认为实体的属性是正确的。 这里是酒店:

/**
 * @Assert\Type("double")
 * @Assert\NotBlank()
 */
private $price;
如果您想要错误的图像,它是。
那么问题出在哪里呢?

在PHP中,
double
float
的别名。使用标量类型提示或返回类型时,不支持此别名,必须使用实际类型。此行为与支持的
bool
类似,但与
boolean
不同


换句话说,在getter和setter中,您必须参考
float

在PHP中
double
float
的别名。使用标量类型提示或返回类型时,不支持此别名,必须使用实际类型。此行为与支持的
bool
类似,但与
boolean
不同


换句话说,在getter和setter中,您必须参考
float

PHP的类型系统似乎不允许使用
double
作为类型提示或返回类型。这可能是,因为它只是
float
的别名。在setter和getter中,尝试将
double
替换为
float
。如果使用
bcmath
-extension使用严格的类型和更安全的浮点计算,您可能还希望使用
string
。感谢float帮助编写了一个答案,因此我可以将其标记为solvedIt。PHP的类型系统似乎不允许使用
double
作为类型提示或返回类型。这可能是,因为它只是
float
的别名。在setter和getter中,尝试将
double
替换为
float
。如果使用
bcmath
扩展名使用严格的键入和更安全的浮点计算,您可能还希望使用
string
。感谢float帮助编写了一个答案,以便我可以将其标记为已解决
/**
 * @Assert\Type("double")
 * @Assert\NotBlank()
 */
private $price;