php Laravel- 遇到格式不正确的数值(在字符串上)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40057476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:36:54  来源:igfitidea点击:

php Laravel- A non well formed numeric value encountered (on string)

phplaravel

提问by Farzan Najipour

I have two function in my controller and service. I want to call a function in service. Here is my code :

我的控制器和服务中有两个功能。我想调用一个服务中的函数。这是我的代码:

Controller:

控制器:

public function findNeighborhoodGet(): array
{
    $regionCenter = Request::get('region_center');
    $distanceService = \App::make('App\web\one\Infrastructure\Service\Google\Map');
    try {
        $userPoint = $distanceService->getOriginPoint($regionCenter);
    }
 .
 .
 .
 return $result
}

my service (Map.php) :

我的服务(Map.php):

public function getOriginPoint(string $origin):Point
{
    dd($origin);

    return $this->getPointObject($origin);
}

Actually , I get an error :

实际上,我收到一个错误:

A non well formed numeric value encountered 

at this line: public function getOriginPoint(string $origin):Point

在这一行: public function getOriginPoint(string $origin):Point

How to solve it?

如何解决?

回答by dailysleaze

This is a bug in the symfony/var-dumper package when using PHP7.1. It was fixed in version 2.7.16, 2.8.9, 3.0.9 and 3.1.3. See the pull request: https://github.com/symfony/symfony/pull/19379

这是使用 PHP7.1 时 symfony/var-dumper 包中的一个错误。它在 2.7.16、2.8.9、3.0.9 和 3.1.3 版本中得到修复。查看拉取请求:https: //github.com/symfony/symfony/pull/19379

In my case, I needed to composer updatemy laravel framework packages, as my vendor directory copy of that package was at 2.7.9. (I'm using Laravel 5.1; later versions use 2.8 and 3.0 of symfony, which also had the bug)

就我而言,我需要composer update我的 laravel 框架包,因为我的供应商目录副本是该包的 2.7.9。(我使用的是 Laravel 5.1;更高版本使用 symfony 的 2.8 和 3.0,它们也有这个错误)

回答by Mouhamed Fadel Diagana

I had the same issue on Laravel 5.2 PHP 7.1. If you don't want to update the entire framework, you can do:

我在 Laravel 5.2 PHP 7.1 上遇到了同样的问题。如果你不想更新整个框架,你可以这样做:

composer update symfony/var-dumper

as stated here.

如规定在这里