Skip to content

Commit bd74557

Browse files
committed
release: version 0.12.0
1 parent d3b1dcb commit bd74557

1 file changed

Lines changed: 97 additions & 1 deletion

File tree

docs/pages/changelog.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,100 @@ toc_depth: 2
88
All notable changes to this project will be documented in this file.
99
<!--- END HEADER -->
1010

11+
## [0.12.0](https://github.com/CuyZ/Valinor/compare/0.11.0...0.12.0) (2022-07-10)
12+
13+
### Notable changes
14+
15+
**SECURITY — Userland exception filtering**
16+
17+
See [advisory GHSA-5pgm-3j3g-2rc7] for more information.
18+
19+
[advisory GHSA-5pgm-3j3g-2rc7]: https://github.com/CuyZ/Valinor/security/advisories/GHSA-5pgm-3j3g-2rc7
20+
21+
Userland exception thrown in a constructor will not be automatically caught by
22+
the mapper anymore. This prevents messages with sensible information from
23+
reaching the final user — for instance an SQL exception showing a part of a
24+
query.
25+
26+
To allow exceptions to be considered as safe, the new method
27+
`MapperBuilder::filterExceptions()` must be used, with caution.
28+
29+
```php
30+
final class SomeClass
31+
{
32+
public function __construct(private string $value)
33+
{
34+
\Webmozart\Assert\Assert::startsWith($value, 'foo_');
35+
}
36+
}
37+
38+
try {
39+
(new \CuyZ\Valinor\MapperBuilder())
40+
->filterExceptions(function (Throwable $exception) {
41+
if ($exception instanceof \Webmozart\Assert\InvalidArgumentException) {
42+
return \CuyZ\Valinor\Mapper\Tree\Message\ThrowableMessage::from($exception);
43+
}
44+
45+
// If the exception should not be caught by this library, it
46+
// must be thrown again.
47+
throw $exception;
48+
})
49+
->mapper()
50+
->map(SomeClass::class, 'bar_baz');
51+
} catch (\CuyZ\Valinor\Mapper\MappingError $exception) {
52+
// Should print something similar to:
53+
// > Expected a value to start with "foo_". Got: "bar_baz"
54+
echo $exception->node()->messages()[0];
55+
}
56+
```
57+
58+
**Tree node API rework**
59+
60+
The class `\CuyZ\Valinor\Mapper\Tree\Node` has been refactored to remove access
61+
to unwanted methods that were not supposed to be part of the public API. Below
62+
are a list of all changes:
63+
64+
- New methods `$node->sourceFilled()` and `$node->sourceValue()` allow accessing
65+
the source value.
66+
67+
- The method `$node->value()` has been renamed to `$node->mappedValue()` and
68+
will throw an exception if the node is not valid.
69+
70+
- The method `$node->type()` now returns a string.
71+
72+
- The methods `$message->name()`, `$message->path()`, `$message->type()` and
73+
`$message->value()` have been deprecated in favor of the new method
74+
`$message->node()`.
75+
76+
- The message parameter `{original_value}` has been deprecated in favor of
77+
`{source_value}`.
78+
79+
**Access removal of several parts of the library public API**
80+
81+
The access to class/function definition, types and exceptions did not add value
82+
to the actual goal of the library. Keeping these features under the public API
83+
flag causes more maintenance burden whereas revoking their access allows more
84+
flexibility with the overall development of the library.
85+
86+
### ⚠ BREAKING CHANGES
87+
88+
* Filter userland exceptions to hide potential sensible data ([6ce1a4](https://github.com/CuyZ/Valinor/commit/6ce1a439adb1f6ee7e771fe02d454aa91e7b320f))
89+
* Refactor tree node API ([d3b1dc](https://github.com/CuyZ/Valinor/commit/d3b1dcb64ec561cdedffe5ca779341fc9452a858))
90+
* Remove API access from several parts of library ([316d91](https://github.com/CuyZ/Valinor/commit/316d91910d289780a7b791f17b958eae264a6296))
91+
* Remove node visitor feature ([63c87a](https://github.com/CuyZ/Valinor/commit/63c87a2cc4c28546f28d51998a93fe89f0885535))
92+
93+
### Bug Fixes
94+
95+
* Handle inferring methods with same names properly ([dc45dd](https://github.com/CuyZ/Valinor/commit/dc45dd8ac5ab1126a362350dbc5292a421254d54))
96+
* Process invalid type default value as unresolvable type ([7c9ac1](https://github.com/CuyZ/Valinor/commit/7c9ac1dd6d518e5e5f0fc02ee172b12084082d1d))
97+
* Properly display unresolvable type ([3020db](https://github.com/CuyZ/Valinor/commit/3020db20bfa8322e3cb198487851bb5d43ea9894))
98+
99+
### Other
100+
101+
* Ignore `.idea` folder ([84ead0](https://github.com/CuyZ/Valinor/commit/84ead04f84118d18ad0c557db909b0cd10b65252))
102+
103+
---
104+
11105
## [0.11.0](https://github.com/CuyZ/Valinor/compare/0.10.0...0.11.0) (2022-06-23)
12106

13107
### Notable changes
@@ -448,7 +542,9 @@ mandatory to explicitly register custom constructors that can be used by the
448542
mapper.
449543

450544
This decision was made because of a security issue reported by @Ocramius and
451-
described in advisory [GHSA-xhr8-mpwq-2rr2].
545+
described in advisory [advisory GHSA-xhr8-mpwq-2rr2].
546+
547+
[advisory GHSA-xhr8-mpwq-2rr2]: https://github.com/CuyZ/Valinor/security/advisories/GHSA-5pgm-3j3g-2rc7
452548

453549
As a result, existing code must list all named constructors that were previously
454550
automatically used by the mapper, and registerer them using the

0 commit comments

Comments
 (0)