什么意思是以下PHP语法:`$ this-> {$ this-> name}`?
我是Magento 2的新手。我正在与Phpunit一起测试一堂课。
当我运行测试时,我会获得此错误:
ArgumentCountError : Too few arguments to function Magenio\Todo\Test\Unit\Service\TaskRepositoryTest::testGetList(), 0 passed in /opt/project/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1414 and exactly 1 expected
我检查了testcase.php
文件和行1414和相关行是:
protected function runTest()
{
if (\trim($this->name) === '') {
throw new Exception(
'PHPUnit\Framework\TestCase::$name must be a non-blank string.'
);
}
$testArguments = \array_merge($this->data, $this->dependencyInput);
$this->registerMockObjectsFromTestArguments($testArguments);
try {
$testResult = $this->{$this->name}(...\array_values($testArguments));
} catch (\Throwable $exception) {
if (!$this->checkExceptionExpectations($exception)) {
throw $exception;
}
我不理解此行中的语法:
$testResult = $this->{$this->name}(...\array_values($testArguments));
任何人都可以向我解释我什么上一行意味着?
我忘了问另一件事:在array_values之前是什么意思... \?
I am new to Magento 2. I am testing a class with PhpUnit.
When I run the test I obtain this error:
ArgumentCountError : Too few arguments to function Magenio\Todo\Test\Unit\Service\TaskRepositoryTest::testGetList(), 0 passed in /opt/project/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1414 and exactly 1 expected
I checked the TestCase.php
file and the line 1414 and related lines are those:
protected function runTest()
{
if (\trim($this->name) === '') {
throw new Exception(
'PHPUnit\Framework\TestCase::$name must be a non-blank string.'
);
}
$testArguments = \array_merge($this->data, $this->dependencyInput);
$this->registerMockObjectsFromTestArguments($testArguments);
try {
$testResult = $this->{$this->name}(...\array_values($testArguments));
} catch (\Throwable $exception) {
if (!$this->checkExceptionExpectations($exception)) {
throw $exception;
}
I didn't understand the syntax in this line:
$testResult = $this->{$this->name}(...\array_values($testArguments));
Can anyone explain me what the previous line means, please?
I forgot to ask another thing: what does mean ...\ before array_values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论