Commit Graph

290 Commits

Author SHA1 Message Date
Nikita Popov
8356da600b Remove dynamic defs from methods as well
We need to remove DECLARE_FUNCTION + dynamic_defs for functions
defined in methods as well, not just for those declared in the
main script.
2021-08-02 10:29:58 +02:00
Nikita Popov
67b5d8fcdc Don't reverse class order during preloading
We don't guarantee any particular order, but this reduces test
failures under --preload that are sensitive to class order.

Add some ZEND_HASH_FOREACH_*_FROM macros to allow skipping the
persistent classes while iterating in forward direction.
2021-07-30 15:14:17 +02:00
Levi Morrison
ae8647d9d3
Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Patrick Allaert
ceb6fa6dc0 Convert some recently introduced zend_bool to bool
As well as `scripts/dev/check_parameters.php` utility.

Cfr. 3e01f5afb1
2021-06-18 15:21:39 +01:00
Dmitry Stogov
e86bea8d45 Extend ZEND_HASH_FILL_* API with ZEND_HASH_FILL_GROW and use it to optimize get_declared_classes() 2021-04-06 16:18:47 +03:00
Dmitry Stogov
340013ad01 Add zend_hash_lookup() and zend_hash_index_lookup() functions.
Thet search for an element with given key/index and add an empty one (NULL), if no found.
2021-03-19 22:36:24 +03:00
Dusk
13c430b1db Add array_is_list(array $array) function
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 #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>

Closes GH-6070
2021-01-20 18:53:48 -05:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Remi Collet
8710429283 fix zend_hash_get_current_key_type_ex proto 2020-09-10 12:40:47 +02:00
Remi Collet
7be70c6bfc fix zend_hash_get_current_key_ex proto 2020-09-10 12:36:44 +02:00
twosee
40e5238a00 Flesh out ZEND_HASH_REVERSE_FOREACH_* macros
Closes GH-6080.
2020-09-09 15:12:18 +08:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Nikita Popov
d3eeeb6882 Don't leak attributes on internal classes
Also add zend_hash_release() API to complement zend_array_release(),
because the latter is specific to non-persistent zval arrays.
2020-06-05 10:29:49 +02:00
Nikita Popov
718e55c3e0 Add zend_array_release() function
To complement zend_string_release() and zend_object_release().
2020-05-06 11:27:20 +02:00
Levi Morrison
90db6f2cc5 Add case insensitive find_ptr hash functions
- zend_hash_find_ptr_lc(ht, zend_string *key)
 - zend_hash_str_find_ptr_lc(ht, const char *str, size_t len)

Note that zend_hash_str_find_ptr_lc used to exist in zend_compile.c
as        zend_hash_find_ptr_lc. When exporting this I figured it
was best to use the same conventions as the rest of zend_hash.h.
2020-04-26 23:29:41 +02:00
Nikita Popov
7352213b38 Early return if variadic type check fails
Don't check all the remaining arguments after one check failed.
I don't think this makes an observable behavior difference,
because we already suppress duplicate exceptions in argument
type error reporting.
2020-04-17 14:24:44 +02:00
Nikita Popov
33ef3d64da Use separate typedef for bucket comparison function
Avoid performing the same casting dance inside each sort compare
function.
2020-03-04 12:46:06 +01:00
Andrey Gromov
84c4a4f17d Make zend_hash_rehash() a void function
It always succeeds.

Closes GH-4304.
2019-06-27 09:48:19 +02:00
Nikita Popov
036b0a1d4d Merge branch 'PHP-7.4' 2019-06-11 12:30:11 +02:00
Nikita Popov
51fb8dc422 Add specialized pair construction API
Closes GH-3990.
2019-06-11 12:29:55 +02:00
Dmitry Stogov
c64fe84f8b Merge branch 'PHP-7.4'
* PHP-7.4:
  Avoid double copying
2019-05-28 13:35:29 +03:00
Dmitry Stogov
b2cb6a4a27 Avoid double copying 2019-05-28 13:35:00 +03:00
Nikita Popov
39724f4645 Merge branch 'PHP-7.4' 2019-04-16 12:21:48 +02:00
Nikita Popov
2bdd212887 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-16 12:21:16 +02:00
Nikita Popov
f9a755d0d2 Fix HT flags copying wrt iterator count
HT_FLAGS() includes the full flag word, including the iterator
count. When we're fully reassigning it, we need to make sure that
we either really do want to copy the iterator count (as in some
cases in array.c) or we need to mask only the actual flag byte.

Add an assert to hash_iterators_del() to make sure the iterator
count is non-zero (which is how I ran into this) and make sure that
the iterator count is correctly preserved during array splicing.
2019-04-16 12:14:45 +02:00
rjhdby
e86cdce549 Make zend_hash_sort() return void
This function always succeeds, so remove the success indicator
return value.
2019-03-22 09:51:47 +01:00
Tyson Andre
da3316ff0f Fix typos in code comments in Zend/ [skip ci] 2019-02-18 17:56:28 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Dmitry Stogov
76d8f3923e Revert HASH_FLAG_INITIALIZED into HASH_FLAG_UNINITIALIZED. 2018-12-28 11:22:18 +03:00
Dmitry Stogov
675a8a64c3 Use HT_IS_INITIALIZED() and HT_INVALIDATE() macros instead of hackish HT_FLAGS assumtions. 2018-12-27 22:48:25 +03:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Dmitry Stogov
27b0fecd2e Turn zend_hash_exists() into inline function 2018-09-19 13:55:53 +03:00
Dmitry Stogov
cd9f0a22fc Perform run-time binding reusing HashTable bucket (without new bucket insertion). 2018-08-29 00:35:07 +03:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
ebd1f5af3e API cleanup.
Removed useless filename and lineno arguments, used in DEBUG build.
The patch doesn't break source compatibility of public API (only binary compatibility).
2018-07-23 15:24:07 +03:00
Dmitry Stogov
3b6e1ee4ee Improved "Fast Shutdown". 2018-07-17 17:31:04 +03:00
Dmitry Stogov
0b90cf85a6 Removed "dead" code (zend_hash_update() never fails) 2018-06-01 11:58:57 +03:00
Dmitry Stogov
0d72bb8fcb Optimize zend_new_array() for special case, when size <= HT_MIN_SIZE 2018-05-31 01:17:55 +03:00
Dmitry Stogov
4df89a31b0 Eliminate useless checks 2018-04-04 02:12:26 +03:00
Dmitry Stogov
a795bd8265 Optimize zend_hash_real_init() 2018-03-23 00:13:45 +03:00
Dmitry Stogov
d7f2dc4ec6 Improve HashTable iterators handling:
- Avoid iterators check/update on each HashTable update opration
- Keep position equal (or above) nNumUsed instead of HT_INVALID_IDX
- Fixed iterators handling in array_unshift()
2018-03-22 02:41:49 +03:00
Dmitry Stogov
a4109e1f4c Added expectation 2018-03-06 23:22:01 +03:00
Dmitry Stogov
6fb5568b2d Merge HashTable.u.v.consistency into HashTable.u.v.flags 2018-01-22 15:32:34 +03:00
Dmitry Stogov
ebf900a9eb Introduce mcros to access HashTable iterators counter 2018-01-22 14:14:35 +03:00
Dmitry Stogov
9cbb521094 Access HashTable.u.flags through HT_FLAGS() macro. 2018-01-22 13:36:15 +03:00
Dmitry Stogov
742d5a01ed Get rid of IS_TYPE_COPYABLE. 2018-01-19 17:47:26 +03:00
Dmitry Stogov
c533396ce4 Strength reduction 2018-01-10 14:23:43 +03:00