Skip to content

Add array|int and object-of-class|int types to stubs #6081

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

Closed
wants to merge 13 commits into from

Conversation

kocsismate
Copy link
Member

@kocsismate kocsismate commented Sep 4, 2020

After this PR, there is only ~270 parameters remaining whose type can't be added as a proper type declaration, not counting out parameters, parameters containing resource, and parameters in ext/dba, but including aliases.

Most of these are because of LSP violations (offset*() methods), but there are 70 funky GMP|int|bool|string param types in ext/gmp, so all in all, there is only a few cases where type validation is not exactly in line with the reported PHPDoc-based type. :)

@kocsismate kocsismate marked this pull request as draft September 4, 2020 23:10
@kocsismate kocsismate requested a review from derickr September 4, 2020 23:22
@kocsismate kocsismate marked this pull request as ready for review September 5, 2020 07:46
@carusogabriel
Copy link
Contributor

Can we have a ZPP label? I believe that will help us to group these PRs for future read :)

@kocsismate kocsismate force-pushed the more-accurate-types4 branch 3 times, most recently from a4f2b03 to 87d1ae4 Compare September 7, 2020 19:20
@kocsismate
Copy link
Member Author

kocsismate commented Sep 7, 2020

I've just rebased to current master since there was a conflict. Additionally, I synchronized the signature of mb_send_mail() and mail() after today's changes in the latter function.

@kocsismate kocsismate force-pushed the more-accurate-types4 branch 3 times, most recently from ad28dd8 to d507919 Compare September 11, 2020 09:50
Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there...

zval *options = NULL;
zval *option;
char *charset = NULL;

if (filter_args && Z_TYPE_P(filter_args) != IS_ARRAY) {
zend_long lval = zval_get_long(filter_args);
if (filter_args_long) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the check here rather the !filter_args_ht?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would make 3 tests fail:

  • in ext/filter/tests/039.phpt: var_dump(filter_var_array(array())); would become false rather than array()
  • in ext/filter/tests/057.php: a bunch of things would change, e.g. var_dump(filter_input_array(INPUT_POST, null)); would print false, rather than null
  • ext/filter/tests/filter_var_array_with_ref.phpt would print false in the first line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to figure this out now...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed some changes to ext/filter that hopefully make sense. I've also added a warning for the "unknown filter" case, which should make the changes in 057.phpt more obvious.

Any concerns about adding that warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes! This was a more bumpy road for me than what I imagined ^^

At first, I was a bit surprised about the new warnings (I thought that I accidentally removed them previously), but I agree that we should have them :)

@kocsismate kocsismate force-pushed the more-accurate-types4 branch 3 times, most recently from dace607 to 7c3ed6f Compare September 13, 2020 22:50
nikic and others added 3 commits September 14, 2020 09:50
<?php

try {
$perid = new DatePeriod("R4");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$perid = new DatePeriod("R4");
$period = new DatePeriod("R4");

Or drop the variable :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I don't even know why I added the variables in the first place... :) (I do know indeed: copy-pasted from date_interval_bad_format_leak.phpt)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You copied my typo :P

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed them during applying the changes in this PR :)

@php-pulls php-pulls closed this in 46c0c82 Sep 14, 2020
@kocsismate kocsismate deleted the more-accurate-types4 branch September 14, 2020 10:02
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

Successfully merging this pull request may close these issues.

3 participants