Releases: eboreum/caster
Releases · eboreum/caster
2.1.1
2.1.0
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
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:castReflectionAttributeToString
castReflectionClassToString
castReflectionMethodToString
castReflectionPropertyToString
castReflectionTypeToString
getSensitiveMessage
getWrappingIndentationCharacters
isConvertingASCIIControlCharactersToHexAnnotationInStrings
isWrapping
sprintf
withIsConvertingASCIIControlCharactersToHexAnnotationInStrings
withIsWrapping
- ASCII control characters (i.e.
\x00-\x1f
and\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\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.
- Function
\Eboreum\Caster\functions\rglob
has been removed. Use method\Eboreum\Caster\Functions::rglob
instead. Notice the uppercase "F". - 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.
- Function
- In method
\Eboreum\Caster\Contract\CasterInterface->cast
, the argument$value
is now properly typed hinted withmixed
. - In method
\Eboreum\Caster\Contract\CasterInterface->castTyped
, the argument$value
is 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:castReflectionAttributeToString
castReflectionClassToString
castReflectionMethodToString
castReflectionPropertyToString
castReflectionTypeToString
- New
sprintf
on\Eboreum\Caster\CasterInterface
, which works similarly to the nativesprintf
function, however, all values will be formatted using thecast
method. - 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
...\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
1.1.1
1.1.0
1.0.1
1.0.0
0.0.3
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).