Amasty Stock Status PHP 8.1 bug

Amasty Stock Status PHP 8.1 bug

We're in the process to upgrade our site to M2.4.5 with PHP8.1, and looks like the module throws an error on the category page.

Exception #0 (Exception): Deprecated Functionality: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in .../vendor/magento/framework/Stdlib/DateTime/Timezone.php on line 301

From our dev partner: 

Having investigated it, we discovered that it's coming from Amasty Stock Status, and it occurs if a product's custom stock status includes the variable {expected_date}, which is not set (see attached). It is a bug in the Amasty module working with PHP 8.1.

We temporarily fixed it in vendor/amasty/stockstatus/Model/Stockstatus/Formatter.php but you'd better report it to the vendor.

----

Just FYI