nystudio107 / craft-typogrify

Typogrify prettifies your web typography by preventing ugly quotes and 'widows' and more

Home Page:https://nystudio107.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Pass an empty field to the typogrify filter. (which is null)

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 to string|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:

public function typogrify($text, $isTitle = false)

And v4:

public function typogrify(string $text, bool $isTitle = false): string