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

Add more specific array return type hints for various extensions - part 6 #7474

Merged
merged 3 commits into from
Oct 7, 2021

Conversation

kocsismate
Copy link
Member

ext/oci8, ext/openssl, ext/sockets, ext/libsodium

@kocsismate kocsismate changed the base branch from master to PHP-8.1 September 7, 2021 08:06
@kocsismate kocsismate added the Type Information Label should be used whenever a pull request is working to improve type information for core or o+ label Sep 7, 2021
@@ -70,9 +70,16 @@ function socket_recvfrom(Socket $socket, &$data, int $length, int $flags, &$addr

function socket_sendto(Socket $socket, string $data, int $length, int $flags, string $address, ?int $port = null): int|false {}

/**
* @return array<string, int>|int|false
Copy link
Member

Choose a reason for hiding this comment

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

At least string is also a possible array value, for SO_ACCEPTFILTER. I haven't tracked down what exactly php_do_getsockopt_ipv6_rfc3542 returns.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like php_do_getsockopt_ipv6_rfc3542 returns array<string, null> due to to_zval_read_in6_pktinfo?

I can remove this type hint though, if we feel unsafe about it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it's safer to just make this array<string, mixed>.

@@ -71,6 +75,10 @@ function openssl_csr_sign(OpenSSLCertificateSigningRequest|string $csr, OpenSSLC
/** @param OpenSSLAsymmetricKey $private_key */
function openssl_csr_new(array $distinguished_names, &$private_key, ?array $options = null, ?array $extra_attributes = null): OpenSSLCertificateSigningRequest|false {}

/**
* @return array<int, string|array>|false
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right ... shouldn't the keys be string?

Copy link
Member

Choose a reason for hiding this comment

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

You might want to build with CFLAGS="-DZEND_VERIFY_FUNC_INFO=1".

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, you are right!

ext/oci8/oci8.stub.php Outdated Show resolved Hide resolved
@kocsismate
Copy link
Member Author

@nikic Could you have another look at this PR (and possibly at the other similar ones)? I believe I addressed your comments.

function socket_get_option(Socket $socket, int $level, int $option): array|int|false {}

/** @alias socket_get_option */
/**
* @return array<string, int>|int|false
Copy link
Member

Choose a reason for hiding this comment

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

Does not match alias?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you're right. Fixed.

@kocsismate kocsismate merged commit d9e5e63 into php:PHP-8.1 Oct 7, 2021
@kocsismate kocsismate deleted the stub-array-7 branch October 7, 2021 12:29
nikic added a commit that referenced this pull request Oct 7, 2021
* PHP-8.1:
  Set opline before calling undef op helper
  Add more specific array return type hints for various extensions - part 6 (#7474)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type Information Label should be used whenever a pull request is working to improve type information for core or o+
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants