php - 带有PHPStorm 10的PHP7

原文 标签 php phpstorm php-7

PHP7 with PHPStorm 10

I met some problems while testing new PHP 7 with PHPStorm 10. Is it a bug?

File1.php

    namespace Game\Fields;


abstract class Field
{
    protected $resources = [];

    protected $requirements = [];

    protected $destruction;

    public function __construct (array $resources, array $requirements, int $destruction)
    {
        $this->resources = $resources;
        $this->requirements = $requirements;
        $this->destruction = $destruction;
    }

    public function getResources (): array
    {
        return $this->resources;
    }

    public function getRequirements (): int
    {
        return $this->requirements;
    }

    public function getDestruction (): int
    {
        return $this->destruction;
    }
}

class DeepDeath extends Field {}

class MysteryDark extends Field {}

class SunEnd extends Field {}

File2.php

declare(strict_types=1);

require_once __DIR__ . '/Fields/Fields.php';

$level = new \Game\Fields\DeepDeath([], [], 30);

echo($level->getDestruction());

In browser everything is OK but PHPStorm give me errors (visible in the picture).

enter image description here

I think that it is a bug. Is there any way to solve this problem? I tried to use EAP from this Site but it didn't solve problem.

Answer

To enable PHP 7 in PHP Storm, go to

Settings > Languages & Frameworks > PHP

And change the PHP language level to "7" in the development environment section.

翻译

在使用PHPStorm 10测试新的PHP 7时遇到了一些问题。这是一个错误吗?

File1.php

    namespace Game\Fields;


abstract class Field
{
    protected $resources = [];

    protected $requirements = [];

    protected $destruction;

    public function __construct (array $resources, array $requirements, int $destruction)
    {
        $this->resources = $resources;
        $this->requirements = $requirements;
        $this->destruction = $destruction;
    }

    public function getResources (): array
    {
        return $this->resources;
    }

    public function getRequirements (): int
    {
        return $this->requirements;
    }

    public function getDestruction (): int
    {
        return $this->destruction;
    }
}

class DeepDeath extends Field {}

class MysteryDark extends Field {}

class SunEnd extends Field {}


File2.php

declare(strict_types=1);

require_once __DIR__ . '/Fields/Fields.php';

$level = new \Game\Fields\DeepDeath([], [], 30);

echo($level->getDestruction());


在浏览器中,一切正常,但是PHPStorm给我错误(在picture中可见)。

enter image description here

我认为这是一个错误。有什么办法解决这个问题?我尝试从此Site使用EAP,但是它不能解决问题。
最佳答案
要在PHP Storm中启用PHP 7,请转到

设置>语言和框架> PHP

在开发环境部分中,将PHP语言级别更改为“ 7”。
相关推荐

php - 如何防止第二个正则表达式重新替换?

php - 如何在PHP的$ _SESSION中保存值并进行检索

php - 与特质的定义顺序和内容有关的“未找到特质错误”

php - 按费用和名称对数组进行排序

php - WAMP上的Mysqli,错误-连接尝试失败

php - laravel查询返回奇怪的顺序

php - Silverstripe 3.2-如何在不同选项卡的ModelAdmin中管理同一数据对象的不同列表

php - 在SQL或脚本中排除ID

php - 将多个查询字符串转换为php中的seo友好url

php - Wordpress插件表,尽管sql正确,但无法使用dbDelta创建