Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 调试&x201C;spl_object_hash()期望参数1是给定的整数”;_Php_Symfony_Doctrine Orm - Fatal编程技术网

Php 调试&x201C;spl_object_hash()期望参数1是给定的整数”;

Php 调试&x201C;spl_object_hash()期望参数1是给定的整数”;,php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,在更新一些Symfony 2 bundle后,我突然发现这个错误spl\u object\u hash()希望参数1是object,如果给定空值。以前也发生过这种情况,但每次调试它都是一种冒险 只有当$entity的类型为Bla\OrmBundle\entity\taApplianceComponent时,才会调用$em->persist($ra)。对我来说,$ra对象包含的值看起来是有效的 有什么想法吗 $ra->getLocation()->addComponen

在更新一些Symfony 2 bundle后,我突然发现这个错误
spl\u object\u hash()希望参数1是object,如果给定空值
。以前也发生过这种情况,但每次调试它都是一种冒险

只有当
$entity
的类型为
Bla\OrmBundle\entity\taApplianceComponent
时,才会调用
$em->persist($ra)
。对我来说,
$ra
对象包含的值看起来是有效的

有什么想法吗

        $ra->getLocation()->addComponent($entity);
        $entity->setLocation($ra->getLocation());

        switch (get_class($entity)) {
            case 'Bla\OrmBundle\Entity\TapApplianceComponent':
                $ra->getTapsAndAppliances()->addTapApplianceComponent($entity);
                $entity->setTapsAndAppliances($ra->getTapsAndAppliances());
                break;
            default:
        }

        $em->persist($ra);
        $em->persist($entity);
        $em->flush();
我得到了一个类似贝娄的线索:

exception 'PHPUnit_Framework_Error_Warning' with message 'spl_object_hash() expects parameter 1 to be object, null given' in C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php:1602
Stack trace:
#0 [internal function]: PHPUnit_Util_ErrorHandler::handleError(2, 'spl_object_hash...', 'C:\\xampp\\htdocs...', 1602, Array)
#1 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1602): spl_object_hash(NULL)
#2 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2219): Doctrine\ORM\UnitOfWork->doPersist(NULL, Array)
#3 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1645): Doctrine\ORM\UnitOfWork->cascadePersist(Object(Bla\OrmBundle\Entity\TapApplianceComponent), Array)
#4 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2219): Doctrine\ORM\UnitOfWork->doPersist(Object(Bla\OrmBundle\Entity\TapApplianceComponent), Array)
#5 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1645): Doctrine\ORM\UnitOfWork->cascadePersist(Object(Bla\OrmBundle\Entity\TapsAndAppliances), Array)
#6 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2224): Doctrine\ORM\UnitOfWork->doPersist(Object(Bla\OrmBundle\Entity\TapsAndAppliances), Array)
#7 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1645): Doctrine\ORM\UnitOfWork->cascadePersist(Object(Bla\OrmBundle\Entity\AutoRa), Array)
#8 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(1583): Doctrine\ORM\UnitOfWork->doPersist(Object(Bla\OrmBundle\Entity\AutoRa), Array)
#9 C:\xampp\htdocs\TestServer\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(546): Doctrine\ORM\UnitOfWork->persist(Object(Bla\OrmBundle\Entity\AutoRa))
#10 C:\xampp\htdocs\TestServer\src\Bla\ApiBundle\Controller\DefaultController.php(217): Doctrine\ORM\EntityManager->persist(Object(Bla\OrmBundle\Entity\AutoRa))
#11 [internal function]: Bla\ApiBundle\Controller\DefaultController->postComponentAction(Object(Symfony\Component\HttpFoundation\Request), '1')
#12 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(3008): call_user_func_array(Array, Array)
#13 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(2970): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(3119): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 C:\xampp\htdocs\TestServer\app\bootstrap.php.cache(2364): Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 C:\xampp\htdocs\TestServer\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Client.php(81): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#17 C:\xampp\htdocs\TestServer\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Client.php(111): Symfony\Component\HttpKernel\Client->doRequest(Object(Symfony\Component\HttpFoundation\Request))
#18 C:\xampp\htdocs\TestServer\vendor\symfony\symfony\src\Symfony\Component\BrowserKit\Client.php(327): Symfony\Bundle\FrameworkBundle\Client->doRequest(Object(Symfony\Component\HttpFoundation\Request))
#19 C:\xampp\htdocs\TestServer\src\Bla\ApiBundle\Tests\Controller\ComponentControllerTest.php(57): Symfony\Component\BrowserKit\Client->request('POST', '/api2/analyses/...', Array, Array, Array)
#20 [internal function]: Bla\ApiBundle\Tests\Controller\ComponentControllerTest->testPostIssueES862()
#21 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestCase.php(962): ReflectionMethod->invokeArgs(Object(Bla\ApiBundle\Tests\Controller\ComponentControllerTest), Array)
#22 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestCase.php(826): PHPUnit_Framework_TestCase->runTest()
#23 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestResult.php(686): PHPUnit_Framework_TestCase->runBare()
#24 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestCase.php(760): PHPUnit_Framework_TestResult->run(Object(Bla\ApiBundle\Tests\Controller\ComponentControllerTest))
#25 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestSuite.php(699): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#26 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\Framework\TestSuite.php(699): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#27 C:\xampp\htdocs\TestServer\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(426): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#28 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(176): PHPUnit_TextUI_TestRunner->doRun(Object(NetBeansSuite), Array)
#29 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#30 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()

您是否检查了$entity本身?根据您的指示,Bla\OrmBundle\Entity\taApplianceComponent为空