ergebnis/composer-json-normalizer
Provides normalizers for normalizing composer.json.
Maintainers
Package info
github.com/ergebnis/composer-json-normalizer
pkg:composer/ergebnis/composer-json-normalizer
Requires
- php: ^7.1
- ext-json: *
- ergebnis/json-normalizer: ~0.10.1
- justinrainbow/json-schema: ^4.0.0 || ^5.0.0
Requires (Dev)
- ergebnis/php-cs-fixer-config: ~1.1.2
- ergebnis/phpstan-rules: ~0.14.2
- ergebnis/test-util: ~0.9.1
- infection/infection: ~0.13.6
- jangregor/phpstan-prophecy: ~0.5.0
- phpstan/extension-installer: ^1.0.3
- phpstan/phpstan: ~0.11.19
- phpstan/phpstan-deprecation-rules: ~0.11.2
- phpstan/phpstan-strict-rules: ~0.11.1
- phpunit/phpunit: ^7.5.18
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 0279214509baf22905c99fe5528e1b74533e6a42
- Andreas MΓΆller <am.woop@localheinz.com>
This package is auto-updated.
Last update: 2020-01-09 13:59:08 UTC
README
π Continuous Deployment
π Continuous Integration
π Code Coverage
π Type Coverage
π Latest Stable Version
π Total Downloads
Provides normalizers for normalizing composer.json.
Installation
Run
$ composer require ergebnis/composer-json-normalizer
Usage
Create an instance of Ergebnis\Composer\Json\Normalizer\ComposerJsonNormalizer
and use it to normalize the contents of a composer.json:
<?php use Ergebnis\Composer\Json\Normalizer\ComposerJsonNormalizer; use Ergebnis\Json\Normalizer\Json; $normalizer = new ComposerJsonNormalizer('https://getcomposer.org/schema.json'); $json = Json::fromEncoded(file_get_contents(__DIR__ . '/composer.json')); $normalized = $normalizer->normalize($json); echo $normalized->encoded();
π‘ Looking for the composer plugin? Head over to localheinz/composer-normalize.
Normalizers
The ComposerJsonNormalizer composes normalizers provided by localheinz/json-normalizer:
as well as the following normalizers provided by this package:
Ergebnis\Composer\Json\Normalizer\BinNormalizerErgebnis\Composer\Json\Normalizer\ConfigHashNormalizerErgebnis\Composer\Json\Normalizer\PackageHashNormalizerErgebnis\Composer\Json\Normalizer\VersionConstraintNormalizer
BinNormalizer
If composer.json contains an array of scripts in the bin section,
the BinNormalizer will sort the elements of the bin section by value in ascending order.
π‘ Find out more about the bin section at https://getcomposer.org/doc/04-schema.md#bin.
ConfigHashNormalizer
If composer.json contains any configuration in the
configextrascripts-descriptions
sections, the ConfigHashNormalizer will sort the content of these sections
by key in ascending order.
π‘ Find out more about the config section at https://getcomposer.org/doc/06-config.md.
PackageHashNormalizer
If composer.json contains any configuration in the
conflictprovidereplacerequirerequire-devsuggest
sections, the PackageHashNormalizer will sort the content of these sections.
π‘ This transfers the behaviour from using the --sort-packages or
sort-packages configuration flag to other sections. Find out more about
the --sort-packages flag and configuration at https://getcomposer.org/doc/06-config.md#sort-packages
and https://getcomposer.org/doc/03-cli.md#require.
VersionConstraintNormalizer
If composer.json contains version constraints in the
conflictprovidereplacerequirerequire-dev
sections, the VersionConstraintNormalizer will ensure that
- all constraints are trimmed
- and constraints are separated by a single space (
) or a comma (,) - or constraints are separated by double-pipe with a single space before and after (
||) - range constraints are separated by a single space (
)
π‘ Find out more about version constraints at https://getcomposer.org/doc/articles/versions.md.
Changelog
Please have a look at CHANGELOG.md.
Contributing
Please have a look at CONTRIBUTING.md.
Code of Conduct
Please have a look at CODE_OF_CONDUCT.md.
License
This package is licensed using the MIT License.
Credits
The algorithm for sorting packages in the PackageHashNormalizer has
been adopted from Composer\Json\JsonManipulator::sortPackages()
(originally licensed under MIT by Nils Adermann and Jordi Boggiano),
which I initially contributed to composer/composer with composer/composer#3549
and composer/composer#3872.
