Bug description
When using \Statamic\Statamic::modify() in a Blade template with an integer value of 0, a PHP TypeError is thrown:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
How to reproduce
In any Blade template:
{{ \Statamic\Statamic::modify(0)->formatMoney() }}
This fails with the error above. Non-zero integers (e.g. 1, 100) or string representations of zero ('0') may behave differently depending on the modifier chain.
Expected behaviour
Statamic::modify(0)->formatMoney() should either return a properly formatted monetary value (€0,00 / $0.00 etc.) or gracefully handle the integer 0 input — not throw an exception.
Actual behaviour
Fatal error:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given at vendor/statamic/cms/src/Modifiers/Modify.php:93
Logs
Environment
Environment
Laravel Version: 13.8.0
PHP Version: 8.4.17
Composer Version: 2.9.7
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: redis
Database: mariadb
Logs: stack / single
Mail: smtp
Queue: redis
Session: redis
Storage
public/storage: LINKED
Locales
Installed: de, en
LaravelLang\Actions\Plugin: 1.12.2
LaravelLang\Attributes\Plugin: 2.15.6
LaravelLang\HttpStatuses\Plugin: 3.12.1
LaravelLang\Lang\Plugin: 15.29.5
LaravelLang\MoonShine\Plugin: INCORRECT
LaravelLang\StarterKits\Plugin: 1.13.2
Locales Version: 2.11.0
Protected: en
Publisher Version: 16.8.0
Statamic
Addons: 3
License Key: Set
Sites: 2 (AdWise DE, AdWise EN)
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.18.1 PRO
Statamic Addons
duncanmcclean/statamic-cargo: 1.6.1
jacksleight/statamic-bard-texstyle: 4.1.0
mitydigital/sitemapamic: 3.5.0
Cargo
Carts: file
Orders: file
Payment Gateways: Stripe
Installation
Existing Laravel app
Additional details
See more/same details in Cargo Issue report here
Bug description
When using
\Statamic\Statamic::modify()in a Blade template with an integer value of 0, a PHP TypeError is thrown:method_exists(): Argument #1 ($object_or_class) must be of type object|string, int givenHow to reproduce
In any Blade template:
{{ \Statamic\Statamic::modify(0)->formatMoney() }}This fails with the error above. Non-zero integers (e.g. 1, 100) or string representations of zero ('0') may behave differently depending on the modifier chain.
Expected behaviour
Statamic::modify(0)->formatMoney()should either return a properly formatted monetary value (€0,00 / $0.00 etc.) or gracefully handle the integer 0 input — not throw an exception.Actual behaviour
Fatal error:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given at vendor/statamic/cms/src/Modifiers/Modify.php:93Logs
Environment
Installation
Existing Laravel app
Additional details
See more/same details in Cargo Issue report here