0

我在 PhpStorm 中不断收到“类存在多个定义...”的警告,经过检查,我看到这些巨大的php-cs-fixer文件(100K+ 行)带有注释“此文件是 PHP CS Fixer 的一部分。”。

我发现由于某种原因,在各种库中存在多个名为phploc, composer,php-scoper等的其他文件的多个副本。vendor/library_name/tools/它们都是 PhpStorm 检测到的巨大编译文件。

我尝试在 PhpStorm 中一一忽略这些文件,一旦重新索引完成,这些文件就会消失,让我相信它们是 IDE 生成的文件。但是,IDE 会生成它们并反过来包含它们的提示代码是没有意义的。

在此处输入图像描述

在此处输入图像描述

composer.json

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "preferred-install": "dist",
        "sort-packages": true
    },
    "require": {
        "magento/composer-root-update-plugin": "~1.0",
        "magento/product-community-edition": "2.4.1"
    },
    "require-dev": {
        "allure-framework/allure-phpunit": "~1.2.0",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
        "friendsofphp/php-cs-fixer": "~2.16.0",
        "lusitanian/oauth": "~0.8.10",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^3.0",
        "pdepend/pdepend": "~2.7.1",
        "phpcompatibility/php-compatibility": "^9.3",
        "phpmd/phpmd": "^2.8.0",
        "phpstan/phpstan": ">=0.12.3 <=0.12.23",
        "phpunit/phpunit": "^9",
        "sebastian/phpcpd": "~5.0.0",
        "squizlabs/php_codesniffer": "~3.5.4"
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "autoload": {
        "psr-4": {
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/",
            "Magento\\": "app/code/Magento/",
            "Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
        },
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "files": [
            "app/etc/NonComposerComponentRegistration.php",
            "app/helper.php"
        ],
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
            "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/"
        }
    },
    "version": "2.4.0",
    "minimum-stability": "stable",
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],
    "extra": {
        "magento-force": "override"
    }
}

PhpStorm 忽略了文件(添加php-cs-fixerphploc在此处以某种方式从vendor目录中删除了所有/多个副本): 在此处输入图像描述

4

1 回答 1

0

这些文件位于您的供应商目录中,因为您必须从源安装依赖项,而不是分发。

让我们用sebastian/code-unit一个例子来看看它是如何工作的:

因此,您必须使用composer install --prefer-source(或者composer update --prefer-source因为它是具有该选项的另一个命令)安装您的依赖项,并且您想要使用--prefer-dist或实际上不使用这些标志中的任何一个,因为后者是默认设置。您可以在官方文档中找到有关它的更多信息:https ://getcomposer.org/doc/03-cli.md#install-i

删除您的供应商目录并再次安装依赖项而无需--prefer-source标记。

AFAIR 还有一个问题,当您没有curl安装扩展时,只需添加此扩展即可。

于 2021-04-02T21:20:53.627 回答