Allow empty Craft fields to be passed
rostockahoi opened this issue · comments
Describe the bug
Not necessarily a bug but it looks like the behaviour of all filters that accept a $text
param has been changed after converting the plugin to v4, maybe with Rector?
Before v4 it was typeless and now it is string $text
. When passing an empty Craft field (null
) a TypeError is thrown.
To reproduce
Steps to reproduce the behaviour:
- Pass an empty field to the
typogrify
filter. (which isnull
)
Expected behaviour
The filter should just return "nothing", like null
or an empty string.
Possible solutions
- omit type definition for the
$text
param - extend type definition for the
$text
param tostring|int|float|null
(Don't know if?string
would suffice due to type casting!?) - set type definition to
mixed
Any input on a possible solution?
Versions
- Plugin version: 4
- Craft version: 4
For reference the v1 code:
And v4:
Fixed in 4.0.0 -> https://github.com/nystudio107/craft-typogrify/releases/tag/4.0.0