Carbon\Carbon::addUnit(): Argument #4 ($anchorDay) must be of type ?int, true given

#3361 · closed · 2 comments

View on GitHub ↗

streamingsystems

**Describe the bug** A clear and concise description of what the bug is. **To Reproduce** A stand-alone chunk of code (with no dependences to other packages, user-land function nor variables with unknow values), for example: ```php echo Carbon::parse('2018-06-01')->subDay()->month; ``` **Expected behavior** A clear and concise description of what you expected to happen. **Actual behavior** Show the value(s) you get. If you get an error or exception, provide the whole stack trace of it. **Versions** - PHP: [e.g. 8.4.11] (use `echo phpversion();` to get it) - Carbon: [e.g. 3.10.2] (run `composer show nesbot/carbon` to find it) **Additional context** Add any other context about the problem here. If some default timezone or other php.ini settings are in use for instance.

Comments

streamingsystems

I am running the latest version of Carbon within Laravel. Lately I am seeing this in my logs: Carbon\Carbon::addUnit(): Argument #4 ($anchorDay) must be of type ?int, true given, called in /home/ss/application/vendor/nesbot/carbon/src/Carbon/Traits/Date.php on line 2973 I can't consistently reproduce it but I am seeing it. PHP Version: PHP 8.4.25 (cli) (built: Aug 25 2026 18:15:03) (NTS gcc x86_64) Copyright (c) The PHP Group Built by Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine #NoAI Zend Engine v4.4.25, Copyright (c) Zend Technologies with Zend OPcache v8.4.25, Copyright (c), by Zend Technologies Carbon Version: 3.14.0 Thanks!

kylekatarnls

Hello, this error means your code or a dependency of your code call a Carbon method (addDays, subHours or the like) and is passing `true` instead of a number to the `$anchorDay`. You need to inspect the rest of the stack trace from your log to see what is making this faulty call.