0

I have PhpStorm and installed "squizlabs/php_codesniffer". When I try to use (e.g. modify the source code), PhpStorm sends me a little error every time, as

Referenced sniff "PHPCSUtils" does not exist

I tried to get that PHPCSUtils like that:

composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require phpcsstandards/phpcsutils:"^1.0"

from here: https://phpcsutils.com/

but it then says:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires phpcsstandards/phpcsutils ^1.0, found phpcsstandards/phpcsutils[dev-stable, dev-develop, 1.0.0-alpha1, ..., 1.x-dev (alias of dev-stable)] but it does not match your minimum-stability.

When I try composer require phpcsstandards/phpcsutils:"dev-stable" I get

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires phpcsstandards/phpcsutils dev-stable -> satisfiable by phpcsstandards/phpcsutils[dev-stable].
- phpcsstandards/phpcsutils dev-stable requires squizlabs/php_codesniffer ^3.7.1 || 4.0.x-dev@dev -> satisfiable by squizlabs/php_codesniffer[3.7.1] from composer repo (https://repo.packagist.org) but squizlabs/php_codesniffer is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.

but that's a lie, I got 3.7.1 phpcodesniffer version:

phpcs --version

PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)

my composer.json is:

{
    "require": {
        "squizlabs/php_codesniffer": "^3.7"
    }
}

the phpcs composer.json is:

{
    "name": "squizlabs/php_codesniffer",
    "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
    "type": "library",
    "keywords": [
        "phpcs",
        "standards"
    ],
    "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
    "license": "BSD-3-Clause",
    "authors": [
        {
            "name": "Greg Sherwood",
            "role": "lead"
        }
    ],
    "support": {
        "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
        "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki",
        "source": "https://github.com/squizlabs/PHP_CodeSniffer"
    },
    "extra": {
        "branch-alias": {
            "dev-master": "3.x-dev"
        }
    },
    "require": {
        "php": ">=5.4.0",
        "ext-tokenizer": "*",
        "ext-xmlwriter": "*",
        "ext-simplexml": "*"
    },
    "require-dev": {
        "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
    },
    "bin": [
        "bin/phpcs",
        "bin/phpcbf"
    ],
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true
        }
    }
}
John Smith
  • 6,129
  • 12
  • 68
  • 123
  • 1
    Aren't the versions of this package considered unstable by Composer ? Would it work if you change `minimum-stability` to `dev` ? – AymDev Dec 08 '22 at 09:03
  • sadly its already that value – John Smith Dec 08 '22 at 09:10
  • 1
    Well, according to the [documentation](https://getcomposer.org/doc/articles/versions.md#stabilities) it *should* work, but I never installed alpha packages. Have you tried to specify the exact version you want ? In my experience, making the choice yourself sometimes fixes it with Composer: `composer require phpcsstandards/phpcsutils:"1.0.0-alpha4"` – AymDev Dec 08 '22 at 09:14
  • "Root composer.json requires phpcsstandards/phpcsutils 1.0.0-alpha4 -> satisfiable by phpcsstandards/phpcsutils[1.0.0-alpha4]." |||| "phpcsstandards/phpcsutils 1.0.0-alpha4 requires squizlabs/php_codesniffer ^3.7.1 || 4.0.x-dev@dev -> satisfiable by squizlabs/php_codesniffer[3.7.1] from composer repo (https://repo.packagist.org) but squizlabs/php_codesniffer is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance." – John Smith Dec 08 '22 at 09:24
  • 2
    What do you have in your "composer.json" under the key "name"? Is it by any chance somehow "squizlabs/php_codesniffer"? Because the part "squizlabs/php_codesniffer is the root package" suggests that. – kuba Dec 09 '22 at 18:01
  • 2
    Add your full `composer.json` to your question. – hakre Dec 10 '22 at 13:12
  • 1
    Thanks for the edit, could you please elaborate about the sentence you make: _"the phpcs composer.json is:"_? What does it mean? Is `phpcs composer.json` the filename? Is it in the same directory as `composer.json`? Please provide all the details, why do you name that file in your question? Which role does it have? Who has created it? Did you curate it? etc. etc. Please elaborate. – hakre Dec 15 '22 at 00:32
  • 1
    And you were asked about minimum stability and wrote it's dev. but the compser.json you've posted shows it is with the default value which is not dev. Please clarify your earlier made statement and the discrepancy compared with the configuration file. – hakre Dec 15 '22 at 00:38

0 Answers0