Valinor/composer.json
Romain Canon b2e810e3ce feat!: allow mapping to any type
Previously, the method `TreeMapper::map` would allow mapping only to an
object. It is now possible to map to any type handled by the library.

It is for instance possible to map to an array of objects:

```php
$objects = (new \CuyZ\Valinor\MapperBuilder())->mapper()->map(
    'array<' . SomeClass::class . '>',
    [/* … */]
);
```

For simple use-cases, an array shape can be used:

```php
$array = (new \CuyZ\Valinor\MapperBuilder())->mapper()->map(
    'array{foo: string, bar: int}',
    [/* … */]
);

echo strtolower($array['foo']);
echo $array['bar'] * 2;
```

This new feature changes the possible behaviour of the mapper, meaning
static analysis tools need help to understand the types correctly. An
extension for PHPStan and a plugin for Psalm are now provided and can be
included in a project to automatically increase the type coverage.
2022-01-02 00:48:01 +01:00

59 lines
1.8 KiB
JSON

{
"name": "cuyz/valinor",
"type": "library",
"description": "Library that helps to map any input into a strongly-typed value object structure.",
"keywords": [
"object", "tree", "mapper", "mapping", "hydrator", "array", "conversion", "json", "yaml"
],
"homepage": "https://github.com/CuyZ/Valinor",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Romain Canon",
"email": "romain.hydrocanon@gmail.com",
"homepage": "https://github.com/romm"
}
],
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"composer-runtime-api": "^2.0",
"psr/simple-cache": "^1.0 || ^2.0",
"doctrine/annotations": "^1.11",
"symfony/polyfill-php80": "^1.22"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"infection/infection": "^0.25.0",
"phpstan/phpstan": "^1.3",
"phpstan/phpstan-strict-rules": "^1.0",
"friendsofphp/php-cs-fixer": "^3.4",
"marcocesarato/php-conventional-changelog": "^1.12"
},
"autoload": {
"psr-4": {
"CuyZ\\Valinor\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"CuyZ\\Valinor\\Tests\\": "tests",
"CuyZ\\Valinor\\QA\\": "qa"
}
},
"scripts": {
"check": [
"phpunit",
"php-cs-fixer fix --dry-run",
"phpstan"
],
"fix": [
"php-cs-fixer fix"
],
"mutation": [
"@putenv XDEBUG_MODE=coverage",
"phpunit --coverage-xml='var/cache/phpunit/coverage' --log-junit='var/cache/phpunit/coverage/junit.xml'",
"infection --threads=12 --skip-initial-tests --coverage='var/cache/phpunit/coverage'"
]
}
}