When trying to parse a specific date I get an error.
[2024-06-03 05:51:03] production.ERROR: Call to a member function format() on false {"exception":"[object] (Error(code: 0): Call to a member function format() on false at /app/vendor/kiwilan/php-audio/src/Models/AudioCore.php:543)
[stacktrace]
#0 /app/vendor/kiwilan/php-audio/src/Audio.php(420): Kiwilan\\Audio\\Models\\AudioCore::fromQuicktime()
#1 /app/vendor/kiwilan/php-audio/src/Audio.php(102): Kiwilan\\Audio\\Audio->parse()
The date_create_from_format() will return false when it can't parse the date according to the manual. In which case the null safe operator will not work because it's a boolean. I think this is not intended.
Up to now it only happened with quicktime format. Haven't dig the code in order to figure out why is that, so it might make sense to check if there are other snippets that could cause the same issue.
What happened?
When trying to parse a specific date I get an error.
How to reproduce the bug
Try a date that doesn't match the format specified in https://github.com/kiwilan/php-audio/blob/main/src/Models/AudioCore.php#L543
I get this with dates that don't include time like
2024-01-01
.The following snippet can simulate the issue:
Package Version
v3.0.06
PHP Version
8.3
Which operating systems does with happen with?
Linux
Notes
The
date_create_from_format()
will return false when it can't parse the date according to the manual. In which case the null safe operator will not work because it's a boolean. I think this is not intended.Up to now it only happened with quicktime format. Haven't dig the code in order to figure out why is that, so it might make sense to check if there are other snippets that could cause the same issue.