{{ message }}
Add array_is_list(array $array) function (rebased)#6070
Closed
TysonAndre wants to merge 1 commit into
Closed
Conversation
twose
reviewed
Sep 9, 2020
|
I am concerned about the name because lists do not always contain sequential integers as indices https://www.php.net/manual/en/spl.datastructures.php
|
Sorry, something went wrong.
Closed
Contributor
Author
|
Sorry, something went wrong.
This function tests if an array contains only sequential integer keys. While list isn't an official type, this usage is consistent with the community usage of "list" as an annotation type, cf. https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists Rebased and modified version of php#4886 - Use .stub.php files - Add opcache constant evaluation when argument is a constant - Change from is_list(mixed $value) to array_is_list(array $array) RFC: https://wiki.php.net/rfc/is_list Co-Authored-By: Tyson Andre <tysonandre775@hotmail.com> Co-Authored-By: Dusk <dusk@woofle.net>
nikic
reviewed
Jan 6, 2021
Contributor
|
This new function is not listed on php.net https://www.php.net/manual-lookup.php?pattern=array_is_list&scope=quickref |
Sorry, something went wrong.
Totktonada
pushed a commit
to mikhainin/tarantool-php
that referenced
this pull request
Apr 11, 2022
The `nNextFreeElement` field is initialized with `ZEND_LONG_MIN` instead of zero since PHP 8.0. Adjust our `php_mp_is_hash()` check accordingly. See [1] and [2] for details. NB: PHP 8.1 introduces `zend_array_is_list()`, which may be used here. See [3] and [4] for details. [1]: https://wiki.php.net/rfc/negative_array_index [2]: php/php-src#3772 [3]: https://wiki.php.net/rfc/is_list [4]: php/php-src#6070 Since I don't observe any other problems on PHP 8.1, closing the relevant issue. Fixes tarantool#171
Totktonada
pushed a commit
to tarantool/tarantool-php
that referenced
this pull request
Apr 11, 2022
The `nNextFreeElement` field is initialized with `ZEND_LONG_MIN` instead of zero since PHP 8.0. Adjust our `php_mp_is_hash()` check accordingly. See [1] and [2] for details. NB: PHP 8.1 introduces `zend_array_is_list()`, which may be used here. See [3] and [4] for details. [1]: https://wiki.php.net/rfc/negative_array_index [2]: php/php-src#3772 [3]: https://wiki.php.net/rfc/is_list [4]: php/php-src#6070 Since I don't observe any other problems on PHP 8.1, closing the relevant issue. Fixes #171
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.
Rebased version of #4886
RFC: https://wiki.php.net/rfc/is_list
An earlier version of this returned false for non-arrays instead of throwing a TypeError - this was updated to prevent confusion with list-like object types
This accepts any type, and deliberately returns false (with no notices) for all non-arrays, e.g. see the test output in the files changed. This is similar to is_callable(), is_numeric(), is_iterable(), etc, which also accept any type: