2.0.0
Version 2.0.0
Changes (from version 1.x)
- Minimum required PHP version is now 8.3.
- Breaking change: There are 12 new methods in
\Eboreum\Caster\CasterInterface. Notice: All said methods are indeed implemented in\Eboreum\Caster\Caster. If you have your own variant of the Caster class, and said class does extend\Eboreum\Caster\Caster, you will not have to update your own variant. The 12 new methods are:castReflectionAttributeToStringcastReflectionClassToStringcastReflectionMethodToStringcastReflectionPropertyToStringcastReflectionTypeToStringgetSensitiveMessagegetWrappingIndentationCharactersisConvertingASCIIControlCharactersToHexAnnotationInStringsisWrappingsprintfwithIsConvertingASCIIControlCharactersToHexAnnotationInStringswithIsWrapping
- ASCII control characters (i.e.
\x00-\x1fand\x7f) will now be escaped by default, similar to howjson_encode(https://www.php.net/manual/en/function.json-encode.php) does it. This is because certain code points, e.g.\x00(NULL byte) will cause the string to become binary and potentially unreadable by humans. Can be disabled by calling...->withIsConvertingASCIIControlCharactersToHexAnnotationInStrings(false). - Due to the introduction of wrapping (see details under New features), several formatters have been updated to handle and/or respect this new behavior. Wrapping is opt-in and thus is disabled by default.
- Due to the introduction of ASCII control character escaping (see details under New features),
\DefaultStringFormatter\Eboreum\Caster\Formatterhas been updated to handle this new behavior. This option is opt-out and thus is enabled by default. - Development: The versions of several
require-devdependencies have been increased. Some (e.g.phpunit/phpunit) have resulted in a great number of code changes. - Functions have been turned into static methods have been removed.
- Function
\Eboreum\Caster\functions\rglobhas been removed. Use method\Eboreum\Caster\Functions::rglobinstead. Notice the uppercase "F". - Function
\Eboreum\Caster\functions\is_enumhas been removed. Use method\Eboreum\Caster\Functions::isEnuminstead. Notice the uppercase "F" and change from snake case to camelcase.
- Function
- In method
\Eboreum\Caster\Contract\CasterInterface->cast, the argument$valueis now properly typed hinted withmixed. - In method
\Eboreum\Caster\Contract\CasterInterface->castTyped, the argument$valueis now properly typed hinted withmixed.
Fixes
None.
New features
- A new attribute,
#[\Eboreum\Caster\Attribute\SensitiveProperty], can now be supplied on class properties, which – when present – will redact the value of the respective property. This behavior is similar to that of the native attribute#[\SensitiveParameter](https://www.php.net/manual/en/class.sensitiveparameter.php). The redaction logic works similar to the existing** HIDDEN **replacement for sensitive strings. - Text wrapping: Messages may now get wrapped, but it is off by default. This will cause elements in arrays and properties to occur on seperate lines, increasing readability. To enable wrapping, simply call
...->withIsWrapping(true). The goal is to make these texts more readable to human eyes, as the produced syntax will be similar to that of the PHP language itself. - 5 new convenience methods directly on
\Eboreum\Caster\Caster(and\Eboreum\Caster\Contract\CasterInterface) for casting Reflection API objects to human readable strings. The 5 methods are:castReflectionAttributeToStringcastReflectionClassToStringcastReflectionMethodToStringcastReflectionPropertyToStringcastReflectionTypeToString
- New
sprintfon\Eboreum\Caster\CasterInterface, which works similarly to the nativesprintffunction, however, all values will be formatted using thecastmethod. - 6 new object formatters have been introduced:
...\ReflectionAttributeFormatter: Formats instances of\ReflectionAttribute....\ReflectionClassFormatter: Formats instances of\ReflectionClass....\ReflectionMethodFormatter: Formats instances of\ReflectionMethod....\ReflectionParameterFormatter: Formats instances of\ReflectionParameter....\ReflectionPropertyFormatter: Formats instances of\ReflectionProperty....\ReflectionTypeFormatter: Formats instances of\ReflectionType.
- Formatting a method argument using e.g. the
...\ReflectionParameterFormatterwill respect#[\SensitiveParameter](https://www.php.net/manual/en/class.sensitiveparameter.php) and will redact the value (i.e. showing** REDACTED **).