Skip to content
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

DateTime::createFromFormat() parameter incorrect #2238

Closed
John-Betong opened this issue Sep 20, 2019 · 3 comments
Closed

DateTime::createFromFormat() parameter incorrect #2238

John-Betong opened this issue Sep 20, 2019 · 3 comments

Comments

@John-Betong
Copy link

DateTime::createFromFormat() expects string, integer given

file: system/HTTP/Response.php

// line # 717
-  $this->setDate( \DateTime::createFromFormat('U', time() ) );
+  $this->setDate( \DateTime::createFromFormat('U', (string) time() ) ); 
@pjsde
Copy link
Contributor

pjsde commented Sep 20, 2019

\DateTime::createFromFormat expects a string in the second parameter, but if an integer is passed, internally converts that integer to a string and gives no error.

@John-Betong
Copy link
Author

\DateTime::createFromFormat expects a string in the second parameter, but if an integer is passed, internally converts that integer to a string and gives no error.

The PHP 7 Manual expects a string and if it is not then has to test and convert for all possible parameter types.

Once the passed type is found ( array, bool, float, integer, etc) then a nearest match conversion is used and hopefully is correct. The additional processing takes time and can be eliminated by passing the correct type or casting the passed parameter.

Currently this is neither an error or a warning but could change in the near future or if an option arises to have a compiled version then this would surely be an error.

@pjsde
Copy link
Contributor

pjsde commented Sep 21, 2019

Ok. You're right.
I thought the function was throwing an error.
My mistake.

This was referenced Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants