-
Notifications
You must be signed in to change notification settings - Fork 189
[Core: SinglePointLogin] Add type declarations to function signatures #4048
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
Conversation
| function passwordAuthenticate( | ||
| string $username, | ||
| string $password, | ||
| bool $redirect = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should indicate @param bool|null in doc block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked the PHP documentation and I don't think this parameter is actually nullable, it's just optional. I think it's the difference between a variable being equal to null and a variable being unset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wright, when you give a default value (other than null), it is not null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objection lifted your honor. But Travis is still objecting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Leaving the below post up in case it helps someone else.
I'm not sure that I understand. What I'm saying is that this variable should never be null so I don't think the suggestion to add |null is correct. That change would make it seem like you are allowed to call the function like this:
passwordAuthenticate('user', 'pass', null);But this will give an error.
You are allowed to do this:
passwordAuthenticate('user', 'pass');but in this case $redirect is initially unset, not null. They're different in PHP. In this case the default argument will set it to a bool.
So there is no case where $redirect is allowed to be null (even though it is optional).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool $redirect = null would have required
@param bool|null .... and
?bool $redirect = null
giving a default value of true make it never to be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About Travis, it is just a note that Travis failed (possibly not related, I haven't check)
Sorry Travis hasn't finish working, not the same
|
For some reason this PR always times out on Travis although when I test it on my VM I have no trouble logging in. Any ideas? |
| @@ -1,4 +1,4 @@ | |||
| <?php | |||
| <?php declare(strict_types=1); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This declare causes the issue. If remove this line, it will pass the test.
https://belitsoft.com/php-development-services/php-7-review-new-features-scalar-type-declarations-and-return-type-declarations
Fatal error: Uncaught TypeError: DateTime::__construct() expects parameter 1 to be string, null given in /app/php/libraries/SinglePointLogin.class.inc:447 Stack trace: #0 /app/php/libraries/SinglePointLogin.class.inc(447): DateTime->__construct(NULL) #1 /app/php/libraries/SinglePointLogin.class.inc(322): SinglePointLogin->disabledDueToInactivity('UnitTester', 365) #2 /app/php/libraries/SinglePointLogin.class.inc(204): SinglePointLogin->passwordAuthenticate('UnitTester', '4test4') #3 /app/php/libraries/NDB_Client.class.inc(161): SinglePointLogin->authenticate() #4 /app/htdocs/index.php(22): NDB_Client->initialize() #5 /app/htdocs/router.php(74): include_once('/app/htdocs/ind...') #6 {main} thrown in /app/php/libraries/SinglePointLogin.class.inc on line 447
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll review the bug
See #3878 for a better description.