Skip to content

Add ext/mysqli stubs - #4913

Closed
tvlooy wants to merge 1 commit into
php:masterfrom
tvlooy:106522_mysqli
Closed

Add ext/mysqli stubs#4913
tvlooy wants to merge 1 commit into
php:masterfrom
tvlooy:106522_mysqli

Conversation

@tvlooy

Copy link
Copy Markdown
Contributor

No description provided.

@carusogabriel

Copy link
Copy Markdown
Contributor

@tvlooy Thanks for your contribution man. Could you please rebase with master?

Comment threadext/mysqli/mysqli.stub.php Outdated
@tvlooy
tvlooyforce-pushed the 106522_mysqli branch 2 times, most recently from 27d252d to 45e91ebCompareNovember 15, 2019 14:57
Comment threadext/mysqli/mysqli.stub.php Outdated
@tvlooy
tvlooyforce-pushed the 106522_mysqli branch 2 times, most recently from 88073d9 to f04f03aCompareNovember 15, 2019 15:48
Comment threadext/mysqli/mysqli.stub.php Outdated
@tvlooytvlooy changed the title Add ext/mysqli stubsWIP Add ext/mysqli stubsNov 15, 2019
@tvlooytvlooy changed the title WIP Add ext/mysqli stubsWIP: Add ext/mysqli stubsNov 15, 2019
@tvlooytvlooy changed the title WIP: Add ext/mysqli stubsAdd ext/mysqli stubsNov 24, 2019
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated

@kocsismatekocsismate left a comment

Copy link
Copy Markdown
Member

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.

Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

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?

Copy link
Copy Markdown
Member

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"). :)

Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
@kocsismate

Copy link
Copy Markdown
Member

@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.

@tvlooy

tvlooy commented Dec 22, 2019

Copy link
Copy Markdown
ContributorAuthor

@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.

@kocsismate

kocsismate commented Dec 22, 2019

Copy link
Copy Markdown
Member

@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 RETVAL_* (e.g. RETVAL_BOOL) and RETURN_* (e.g. RETURN_BOOL) macros, or sometimes the return_value variable itself. The first ones set the return type of the function (by setting the value of the return_value variable), the second ones additionally return. In order to determine the exact return type of a function, you have to take the return value of all branches into account (and that's where union types come into play).

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.

@tvlooy

Copy link
Copy Markdown
ContributorAuthor

Okay. Then I will do a full review this week.

@tvlooytvlooy left a comment

Copy link
Copy Markdown
ContributorAuthor

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 😊

@cmb69

cmb69 commented Jan 3, 2020

Copy link
Copy Markdown
Member

@kocsismate

Copy link
Copy Markdown
Member

@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.

@nikic

Copy link
Copy Markdown
Member
* now that the null is gone, should this return true or bool in the signature?

For now, bool. We currently don't support true as a type, so these are typed as bool.

* if it will only return true, why not just make that return nothing and change the method?

In principle yes, but there's backwards compatibility considerations, so if we do this, it should be as a separate change.

@kocsismate

Copy link
Copy Markdown
Member

what does this return when cs_name is false?

By default, the return value is null.

@tvlooy

Copy link
Copy Markdown
ContributorAuthor

what does this return when cs_name is false?

By default, the return value is null.

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

@nikic

Copy link
Copy Markdown
Member

What's the state of this PR, is it ready for review?

@tvlooy

tvlooy commented Feb 15, 2020

Copy link
Copy Markdown
ContributorAuthor

What's the state of this PR, is it ready for review?

@nikic@kocsismate the PR is updated and ready for review.
Do check if __construct() of mysqli_warning, mysqli_result and mysqli_stmt can be improved.

@kocsismatekocsismate left a comment

Copy link
Copy Markdown
Member

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).

Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated

@kocsismatekocsismateFeb 17, 2020

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
ContributorAuthor

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?

Comment threadext/mysqli/mysqli.stub.php Outdated
@nikic

Copy link
Copy Markdown
Member

FYI I killed the mysqli reflection tests in 541f8b7. They are useless and just cause extra work.

Comment threadext/mysqli/mysqli.stub.php Outdated

Copy link
Copy Markdown
Member

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? 🤔

@tvlooytvlooyFeb 19, 2020

Copy link
Copy Markdown
ContributorAuthor

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()

Copy link
Copy Markdown
ContributorAuthor

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)

Comment threadext/mysqli/mysqli.stub.php Outdated
@tvlooy

Copy link
Copy Markdown
ContributorAuthor

FYI I killed the mysqli reflection tests in 541f8b7. They are useless and just cause extra work.

rebased. Thanks for zapping the files

@kocsismatekocsismate left a comment

Copy link
Copy Markdown
Member

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!

Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
Comment threadext/mysqli/mysqli.stub.php Outdated
@tvlooy

Copy link
Copy Markdown
ContributorAuthor

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!

@kocsismate

kocsismate commented Feb 22, 2020

Copy link
Copy Markdown
Member

@tvlooy There is one failing test left related to mysqli_insert_id(). The issue is that the MYSQLI_RETURN_LONG_INT() macro can return string as well, so please double check the return type everywhere where it is used.

@tvlooy

Copy link
Copy Markdown
ContributorAuthor

MYSQLI_RETURN_LONG_INT

Fixed! And rebased

@kocsismate

kocsismate commented Feb 24, 2020

Copy link
Copy Markdown
Member

The PR looks good to me but I think Nikita should have a look at it too before merging. :)

@nikic

Copy link
Copy Markdown
Member

I didn't comprehensively review this again, just added the missing mysqli_stmt::__construct signature and merged...

Thanks for your work on this!

@tvlooy
tvlooy deleted the 106522_mysqli branch February 27, 2020 21:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@tvlooy@carusogabriel@kocsismate@cmb69@nikic