Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a string value for extra.phpcodesniffer-search-depth #82

Closed
TravisCarden opened this issue Jun 18, 2019 · 3 comments
Closed

Allow a string value for extra.phpcodesniffer-search-depth #82

TravisCarden opened this issue Jun 18, 2019 · 3 comments

Comments

@TravisCarden
Copy link
Contributor

It's impossible to set the extra.phpcodesniffer-search-depth config value from the command line because it strictly enforces an integer type on it, whereas composer config cannot set integer values (see composer/composer#8195):

$ composer init -n
$ composer config extra.phpcodesniffer-search-depth 4
$ cat composer.json
{
    "require": {},
    "extra": {
        "phpcodesniffer-search-depth": "4"
    }
}
$ composer require --dev dealerdirect/phpcodesniffer-composer-installer
Using version ^0.5.0 for dealerdirect/phpcodesniffer-composer-installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing squizlabs/php_codesniffer (3.4.2): Loading from cache
  - Installing dealerdirect/phpcodesniffer-composer-installer (v0.5.0): Loading from cache
Writing lock file
Generating autoload files

Installation failed, reverting ./composer.json to its original content.


  [InvalidArgumentException]
  The value of "phpcodesniffer-search-depth" (in the composer.json "extra".section) must be an integer larger then 0, '4' given.


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

I currently use the following fairly ugly kludge as a workaround:

sed -i'.bak' 's|"phpcodesniffer-search-depth": "4"|"phpcodesniffer-search-depth": 4|' composer.json && rm composer.json.bak

For its part, I've requested that Composer provide the ability to typecast data on the commandline (again, see composer/composer#8195). On this side, it would be nice if phpcodesniffer-composer-installer would typecast string values to integers. Would the maintainers accept a pull request to that effect?

@Potherca
Copy link
Member

Potherca commented Sep 6, 2019

Hi! Thank you for reporting this issue!

We would definitely welcome such a contribution but (as you may have noticed from my late response) we don't have much time/energy to spend on this project currently.

So, if you do decide to open an MR, don't feel discouraged if our response is slow!

@TravisCarden
Copy link
Contributor Author

Thanks, @Potherca! #85 should do the trick. :)

@Potherca
Copy link
Member

The MR has been merged, will be part of the upcoming 0.5.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants