Skip to content

2.0.0

Choose a tag to compare

@kafoso kafoso released this 10 Aug 10:48
· 16 commits to main since this release

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:
    1. castReflectionAttributeToString
    2. castReflectionClassToString
    3. castReflectionMethodToString
    4. castReflectionPropertyToString
    5. castReflectionTypeToString
    6. getSensitiveMessage
    7. getWrappingIndentationCharacters
    8. isConvertingASCIIControlCharactersToHexAnnotationInStrings
    9. isWrapping
    10. sprintf
    11. withIsConvertingASCIIControlCharactersToHexAnnotationInStrings
    12. withIsWrapping
  • ASCII control characters (i.e. \x00-\x1f and \x7f) will now be escaped by default, similar to how json_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\Formatter has been updated to handle this new behavior. This option is opt-out and thus is enabled by default.
  • Development: The versions of several require-dev dependencies 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.
    1. Function \Eboreum\Caster\functions\rglob has been removed. Use method \Eboreum\Caster\Functions::rglob instead. Notice the uppercase "F".
    2. Function \Eboreum\Caster\functions\is_enum has been removed. Use method \Eboreum\Caster\Functions::isEnum instead. Notice the uppercase "F" and change from snake case to camelcase.
  • In method \Eboreum\Caster\Contract\CasterInterface->cast, the argument $value is now properly typed hinted with mixed.
  • In method \Eboreum\Caster\Contract\CasterInterface->castTyped, the argument $value is now properly typed hinted with mixed.

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:
    1. castReflectionAttributeToString
    2. castReflectionClassToString
    3. castReflectionMethodToString
    4. castReflectionPropertyToString
    5. castReflectionTypeToString
  • New sprintf on \Eboreum\Caster\CasterInterface, which works similarly to the native sprintf function, however, all values will be formatted using the cast method.
  • 6 new object formatters have been introduced:
    1. ...\ReflectionAttributeFormatter: Formats instances of \ReflectionAttribute.
    2. ...\ReflectionClassFormatter: Formats instances of \ReflectionClass.
    3. ...\ReflectionMethodFormatter: Formats instances of \ReflectionMethod.
    4. ...\ReflectionParameterFormatter: Formats instances of \ReflectionParameter.
    5. ...\ReflectionPropertyFormatter: Formats instances of \ReflectionProperty.
    6. ...\ReflectionTypeFormatter: Formats instances of \ReflectionType.
  • Formatting a method argument using e.g. the ...\ReflectionParameterFormatter will respect #[\SensitiveParameter] (https://www.php.net/manual/en/class.sensitiveparameter.php) and will redact the value (i.e. showing ** REDACTED **).