Skip to content

Releases: eboreum/caster

2.1.1

09 Mar 17:07
Compare
Choose a tag to compare

Version 2.1.1

Bug fixes

  • Don't wrap empty arrays (403e9af).

2.1.0

14 Feb 20:45
Compare
Choose a tag to compare

Version 2.1.0

Changes

  • Introduced a special singleton class, \Eboreum\Caster\SensitiveValue, which is utilized to signal to Caster that the "sensitive message" (default being "** REDACTED **") should be returned. Notice that for this reason (by design) the type is not returned, either. This is done in order to reveal absolutely nothing of the original value.
  • Added Docker functionality. However, this is solely for development and testing purposes. Everything Docker related is in export-ignore in the .gitattributes file.
  • Added a build step checking for Composer strict PSR autoloading compliance.

Fixes

  • phpstan/phpstan was upgraded to ^2.1.5. This has resulted in a large number of code changes, however, none of which should have changed the existing behavior.

2.0.0

10 Aug 10:48
Compare
Choose a tag to compare

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 **).

1.1.2

10 Feb 09:20
Compare
Choose a tag to compare

phpcs and phpstan fixes.

1.1.1

10 May 18:13
Compare
Choose a tag to compare
  • Bug fix: ClosureFormatter: Corrected type resolving for composite types.

1.1.0

10 May 17:00
77d15c2
Compare
Choose a tag to compare
  • ClosureFormatter: Added return type to produced output

1.0.1

22 Apr 09:46
Compare
Choose a tag to compare
  • Bugfix: Code requires Enums, which means PHP must be ^8.1.

1.0.0

21 Apr 09:20
Compare
Choose a tag to compare

Version 1.0.0!

0.0.3

03 Jan 10:06
Compare
Choose a tag to compare
0.0.3 Pre-release
Pre-release

Getting ready for version 1.0.0.

  • Adaptations for full PHP 8 support.
  • Badges (license, unit tests, code coverage).
  • Various phpstan fixes.
  • Various unit test fixes.
  • Various CodeSniffer fixes.
  • Minor additions and changes (no backwards compatibility breakage).

0.0.2

09 Sep 10:04
Compare
Choose a tag to compare
  • Implemented \Eboreum\Caster\Formatter\Object_\ClosureFormatter.