-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Carbon v3 #185
Allow Carbon v3 #185
Conversation
Seems like the tests are failing for Carbon v3. Could you have a look? |
checking |
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
Hi @freekmurze, done on fixing test, also added matrix for canbon v2 and v3 to make sure all works, thank you |
Perfect, thanks! |
This is a breaking change. With spatie/ssl-certificate v2.6.4 (which installs Carbon 2.72.3) With spatie/ssl-certificate v2.6.5 (which installs Carbon 3.2.1) Which, within a real world app, is interpreted as the SSL being expired and has caused me to email 1000s of users - doh... With spatie/ssl-certificate v2.6.5 (with FORCED Carbon 2.72.3) Reproducer: <?php
use Spatie\SslCertificate\SslCertificate;
require 'vendor/autoload.php';
$certificate = SslCertificate::createForHostName(parse_url('https://mySites.guru/', \PHP_URL_HOST));
var_dump($certificate->expirationDate()->diffInDays()); My workaround is to not use |
related comments briannesbitt/Carbon#2971 (comment) |
In the case of a certificate expiration, I think it's good not to hide the fact that it's actually already expired. I think the Carbon v2 behavior was actually dangerous because using So I think having a negative number when expired is a safe move. Depending on the feature need some other possible behaviors for when value < 0 could be:
|
(I misread the code, so I edited my message above, sorry for the noise) |
As discussions in #185 , change the sample codes and comments in README.md
Just to note on the implementation here casting using (int) will still return a negative integer? Is this expected? I would consider intval(abs($x)); |
I dont mind progress, but this was and is a backward compatibility change that broke implementations and was released in a minor release, not a major release. |
I didn't check when was tagged the previous minor but: return (int) Carbon::now()->diffInDays($endDate); using Carbon 3 is equivalent to what was apparently the previous code: $interval = Carbon::now()->diff($endDate);
return (int) $interval->format('%r%a'); I.E. negative number when expired, positive before expiration. |
|
For me personally I just accepted the change and modified my code for future proofing as stated above 3 months ago. Others were also discussing this change in other places at the same time briannesbitt/Carbon#2971 (comment) - |
BTW, |
No description provided.