Commit graph

972 commits

Author SHA1 Message Date
Pedro Magalhães
6732028273 Implement the negative_array_index RFC 2019-02-08 16:08:32 +00:00
Nikita Popov
53d8fa5af7 Fix signedness in comparison in array_slice 2019-02-07 15:38:43 +01:00
Dmitry Stogov
91ef4124e5 Refactor zend_object_handlers API to pass zend_object* and zend_string* insted of zval(s). 2019-02-04 13:20:25 +03:00
Nikita Popov
0476d55827 Make array_slice $length param a nullable integer
Instead of having custom parameter handling.
2019-02-04 10:38:42 +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
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Nikita Popov
e219ec144e Implement typed properties
RFC: https://wiki.php.net/rfc/typed_properties_v2

This is a squash of PR #3734, which is a squash of PR #3313.

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
Co-authored-by: Joe Watkins <krakjoe@php.net>
Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2019-01-11 15:49:06 +01:00
Nikita Popov
7ac3c2fa65 Fix ZEND_NORMALIZE_BOOL usage
Typo introduced in cdd8368d6f.
2019-01-02 09:56:40 +01:00
Xinchen Hui
c5c76fbd61 Merge branch 'PHP-7.3'
* PHP-7.3:
  Update NEWS
  Fixed bug #77395 (segfault about array_multisort)
2019-01-02 12:10:41 +08:00
Xinchen Hui
e527626d9f Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #77395 (segfault about array_multisort)
2019-01-02 12:10:04 +08:00
Xinchen Hui
8ebae84674 Fixed bug #77395 (segfault about array_multisort) 2019-01-02 12:09:47 +08:00
Dmitry Stogov
05f3706588 Split php_array_merge_or_replace_wrapper() into php_array_merge_wrapper() and php_array_replace_wrapper().
Avoid array duplication when merging with an empty array.
2018-12-11 15:59:44 +03:00
Gabriel Caruso
cdd8368d6f Clean up unnecessary ternary expressions and simplify some returns
- Simplify conditions
- Use ZEND_HASH_APPLY_* instead of hard-coded booleans
- Use ZEND_NORMALIZE_BOOL
- Drop sign in favor of ZEND_NORMALIZE_BOOL
2018-12-03 01:22:14 +01:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
67e0138c0d Future-proof email addresses... 2018-11-01 18:30:28 +02:00
Nikita Popov
1cfbb21790 Classify object handlers are required/optional 2018-10-16 20:53:59 +02:00
Nikita Popov
0b6063f331 Restore array_key_exists() compatibility for ArrayObject
Doing this by special-casing array_key_exists() for ArrayObject.
2018-10-11 16:10:22 +02:00
Nikita Popov
cdde07d059 Merge branch 'PHP-7.3' 2018-09-18 20:51:50 +02:00
Nikita Popov
c2da50bc41 Merge branch 'PHP-7.2' into PHP-7.3 2018-09-18 20:51:28 +02:00
Nikita Popov
6bf681249f Merge branch 'PHP-7.1' into PHP-7.2 2018-09-18 20:50:37 +02:00
Manabu Matsui
ab6c45f524 Fix bug #75533: array_reduce is slow when $carry is large array 2018-09-18 20:49:59 +02:00
Peter Kokot
d3ca28f569 Remove HAVE_STRING_H
The C89 standard and later defines the `<string.h>` header as part of
the standard headers [1] and on current systems it is always present.

Code included also `<strings.h>` header as an alterinative in some
files. This kind of check was relevant on some older systems where the
`<strings.h>` file included definitions for the C89 compliant
`<string.h>`. Today such alternative check is not required anymore. The
`<strings.h>` file is part of the POSIX definition these days.

Also Autoconf suggests doing this and relying on C89 or above [2] and [3].

This patch also cleans few unused `<strings.h>` inclusions in the libmbfl.

[1]: https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2]: http://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
[3]: https://www.gnu.org/software/autoconf/manual/autoconf-2.69/autoconf.html
2018-09-18 05:32:08 +02:00
Nikita Popov
dfa166e7ed Remove unused ZEND_FILE_LINE in i_zval_ptr_dtor 2018-09-16 17:16:26 +02:00
Christoph M. Becker
1de17428f6 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #76778: array_reduce leaks memory if callback throws exception
2018-08-22 13:51:16 +02:00
Christoph M. Becker
cdd9eb8c4a Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix #76778: array_reduce leaks memory if callback throws exception
2018-08-22 13:49:35 +02:00
Christoph M. Becker
70b2fca220 Fix #76778: array_reduce leaks memory if callback throws exception
We have to release the result variable in the error case, too.
2018-08-22 13:40:24 +02:00
Gabriel Caruso
efbf846fd2
Make array parsing parameters error messages consistency with ZPP failure 2018-08-19 21:27:57 -03:00
Xinchen Hui
2b1d79ce66 Fixed bug #76713 (Segmentation fault caused by property corruption) 2018-08-07 12:36:36 +08:00
Dmitry Stogov
c42f0ba4f7 Removed useless IS_UNDEF checks 2018-07-31 12:23:46 +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
Xinchen Hui
1638a6e118 Give a meaningful name 2018-07-24 12:51:36 +08:00
Xinchen Hui
4aada3993c Micro-optmization 2018-07-24 12:16:35 +08:00
Xinchen Hui
3ca9aaf24e Merge branch 'PHP-7.2'
* PHP-7.2:
  Update NEWs
  Fixed bug #68553 (array_column: null values in $index_key become incrementing keys in result)

Conflicts:
	ext/standard/array.c
2018-07-24 11:37:09 +08:00
Xinchen Hui
2a181b5ea0 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #68553 (array_column: null values in $index_key become incrementing keys in result)
2018-07-24 11:35:22 +08:00
Xinchen Hui
38d97557da Fixed bug #68553 (array_column: null values in $index_key become incrementing keys in result) 2018-07-24 11:34:57 +08:00
Dmitry Stogov
d4e60a1ffd Avoid code duplication 2018-07-23 16:53:44 +03:00
Christoph M. Becker
9f957fd303 Improve implementation of array_key_first() and array_key_last()
Firstly, we must not separate the $stack argument for performance
reasons.  Secondly, we prefer `Z_ARRVAL_P` over `HASH_OF` to clarify
our intention.

Thanks to Nikita, for catching these issues!
2018-07-17 11:53:06 +02:00
Enno Woortmann
50516a6e1f Add implementation and tests for new methods - array_key_first(array $a) Returns the key of the first element or null - array_key_last(array $a) Returns the key of the last element or null 2018-07-17 11:31:00 +02:00
Dmitry Stogov
67b4c3379a Uze ZVAL_COPY_DEREF() instead of ZVAL_DEREF() and ZVAL_COPY() 2018-07-09 12:46:46 +03:00
Dmitry Stogov
af341213f7 se zval_ptr_dtor_str() instead of zend_string_release_ex(Z_STR(*), 0) 2018-07-04 12:08:07 +03:00
Nikita Popov
e080fb6d92 Do not continue extract()ing after an exception has been thrown
Make behavior consistent with a loop of normal assignments.

This is not a big issue now, because $this is the only case that
may generate an error. However typed references introduce additional
error conditions, which would be silenced by this kind of behavior.
2018-07-03 22:45:35 +02:00
Xinchen Hui
8b2f40724b Merge branch 'PHP-7.2'
* PHP-7.2:
  Update NEWS
  Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys)
2018-06-21 17:26:57 +08:00
Xinchen Hui
939e1095f2 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys)
2018-06-21 17:26:27 +08:00
Xinchen Hui
6531719da5 Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys) 2018-06-21 17:26:05 +08:00
Gabriel Caruso
fc775f6915 Report unknown variables passed to compact() 2018-06-19 12:50:15 +02:00
Nikita Popov
777187cbaf Don't use UNREFs during array operations
Perform DEREFs instead. We were already doing this in some, but not
all places.

While UNREFs are supposed to be transparent, in practice they have
rare observable side effects. Calling array_merge() on an array
should never change how that array behaves.
2018-06-09 13:20:13 +02:00
Xinchen Hui
0a0f6c495f Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed bug #76410 (SIGV in zend_mm_alloc_small)
  Fix bug #76390 - do not allow invalid strings in range()

Conflicts:
	ext/standard/array.c
2018-06-05 17:16:45 +08:00
Xinchen Hui
951e29f66e Fixed bug #76410 (SIGV in zend_mm_alloc_small) 2018-06-05 17:15:57 +08:00
Stanislav Malyshev
c12fc77bdf Fix bug #76390 - do not allow invalid strings in range() 2018-06-04 22:54:03 -07:00
Stanislav Malyshev
5fbb0988d1 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix bug #76390 - do not allow invalid strings in range()
2018-06-04 22:51:38 -07:00