-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add ext/mysqli stubs #4913
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
Add ext/mysqli stubs #4913
Conversation
@tvlooy Thanks for your contribution man. Could you please rebase with |
27d252d
to
45e91eb
Compare
88073d9
to
f04f03a
Compare
f04f03a
to
288f95f
Compare
7aadcd9
to
9b8b714
Compare
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.
@tvlooy I could only review very few functions/methods.
ext/mysqli/mysqli.stub.php
Outdated
* | ||
* @return bool | ||
*/ | ||
public function commit(?int $flags = 0, ?string $name = ''); |
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.
these are not nullable parameters (there is no !
in the ZPP). That said, the $name
parameter's default value should be UNKNOWN
AFAIK.
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.
how can I know that it should be UNKNOWN?
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.
There is some information written about it by Nikita: https://externals.io/message/106522 (the whole thread is interesting, but you should search for "UNKNOWN"). :)
@tvlooy Do you plan to continue working on these stubs in the foreseeable future? If so, I'll try to help you by reviewing the code, otherwise I can also continue it. |
I changed the docblocks like you asked. I rebased and sqashed commits. Tests still pass. I might have underestimated this a bit. I have trouble figuring out the return types and need help with it. Maybe it is better if I hand it over to you. |
3f46e9f
to
66fff28
Compare
@tvlooy You feel right, the return types are usually (much) more difficult to find out than parameter types. What you have to look for in most cases is There are lots of functions in mysqli, so I can understand that you feel it's too much. I'd suggest you to make smaller changes next time (by splitting the work) so it's easier for you when you try to learn how all these things work, and it's easier for the reviewers as well. 😎 My plan is to first work on the SPL (probably after the holidays) so that you have some extra time to decide if you want to proceed with the work. |
Okay. Then I will do a full review this week. |
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.
@kocsismate I'm curious how the return_value actually works. ps: I'm reviewing but not done yet. Learning a lot. Thank you for your patience 😊
@tvlooy Take your time, I have plenty other stuffs to do :) You could have a look at this too https://github.com/php/php-src/blob/master/docs/parameter-parsing-api.md (if you haven't seen it yet), it also helped me a lot. |
questions about close():
question about character_set_name():
|
For now, bool. We currently don't support
In principle yes, but there's backwards compatibility considerations, so if we do this, it should be as a separate change. |
7d57b8e
to
1f389d2
Compare
By default, the return value is |
I will change the signature for character_set_name() and also for get_client_info(), get_server_info() which seems to have the same case |
640ca1f
to
56814d8
Compare
What's the state of this PR, is it ready for review? |
@nikic @kocsismate the PR is updated and ready for review. |
56814d8
to
847ec98
Compare
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.
Really nice job! I could only find a few issues so far (I reached to mysqli_warning).
ext/mysqli/mysqli.stub.php
Outdated
class mysqli_warning | ||
{ | ||
/** | ||
* mysqli_link|mysqli_stmt $mysqli_link |
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.
it's invalid PHPDoc (+ there is no parameter added in the param list), but as no exception is thrown in case a wrong object is provided, you should fallback to the object
type declaration
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.
Fixed docblock but didn't change method signature (things break if I do). What should be in the signature?
a9fd613
to
e7f3aeb
Compare
FYI I killed the mysqli reflection tests in 541f8b7. They are useless and just cause extra work. |
ext/mysqli/mysqli.stub.php
Outdated
* | ||
* @return object|false | ||
*/ | ||
public function __construct(); |
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.
what kind of errors are thrown when you add the parameters in the definition? 🤔
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.
changed and it works with object for mysqli_result::__construct and mysqli_warning::__construct()
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 get a "Fatal error: Arginfo / zpp mismatch during call of mysqli_stmt::__construct() in Unknown on line 0" when I change the signature to (object $mysqli_link, string $statement)
e7f3aeb
to
17f11b8
Compare
rebased. Thanks for zapping the files |
17f11b8
to
7820eab
Compare
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.
That's all the issues I could find. Mostly just a category issue with nullable return types. Huge work, @tvlooy!
I should have spotted those return types. Thanks for the review! |
@tvlooy There is one failing test left related to |
5c79107
to
fc0be7c
Compare
Fixed! And rebased |
The PR looks good to me but I think Nikita should have a look at it too before merging. :) |
I didn't comprehensively review this again, just added the missing Thanks for your work on this! |
No description provided.