Commit graph

534 commits

Author SHA1 Message Date
Tom Van Looy
04fb3f28ff Remove superfluous semicolons 2017-06-26 00:23:25 +02:00
Sara Golemon
81064cd045 Merge branch 'PHP-7.1'
* PHP-7.1:
  Remove typo from test header
2017-05-10 16:50:47 -07:00
Sara Golemon
90bd4be3f9 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Remove typo from test header
2017-05-10 16:50:37 -07:00
Sara Golemon
b8e0351978 Remove typo from test header 2017-05-10 16:50:19 -07:00
Nikita Popov
51b06aa86e Merge branch 'PHP-7.1' 2017-04-02 13:20:14 +02:00
Nikita Popov
c8034514ed Fixed bug #74361 2017-04-02 13:19:32 +02:00
Rowan Collins
1b565f1393 Change 'undefined constant' from E_NOTICE to E_WARNING and mention deprecation
Implements RFC "Deprecate and Remove Bareword (Unquoted) Strings"
[https://wiki.php.net/rfc/deprecate-bareword-strings]
2017-03-23 18:52:43 +01:00
Sara Golemon
c74bc87c74 Minor optimizations to array_keys()/array_values()
array_values():
When the input is an empty array or a packed array with no gaps,
return the original array.

array_keys():
When the input is an empty array, return the original array.
When the input is a packed array with no holes
(and no search key specified), populate the return with
a simple range(0, count($input) - 1)
2017-03-14 11:23:02 -07:00
Nikita Popov
06a0340162 Deprecate each() 2017-02-03 21:02:52 +01:00
Nikita Popov
eaeecc523b Deprecate create_function() 2017-02-03 18:52:57 +01:00
Nikita Popov
a8d901a80c Remove zend_version() checks from tests 2017-01-30 22:50:25 +01:00
Nikita Popov
79d918b3a6 Add test for buf #65251 2017-01-08 12:01:18 +01:00
Nikita Popov
5af586bec5 Remove more PHP 6 leftovers from tests 2016-11-24 22:39:39 +01:00
Pedro Magalhães
9c5af4e4cb Remove the b prefix from literals on unrelated tests 2016-11-20 21:11:53 +01:00
Craig Duncan
c1001d22d2 Add expectations for invalid count() warnings 2016-11-17 09:33:04 +00:00
Craig Duncan
b000f5c341 Add tests for invalid count() operations 2016-11-17 09:33:04 +00:00
Andrea Faulds
a0502b89a6 Convert numeric keys in object/array casts
RFC: https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts

This converts key types as appropriate in object to array and array to object
casts, as well as in get_object_vars().
2016-11-14 18:20:45 +00:00
Nikita Popov
736633310c Merge branch 'PHP-7.0' into PHP-7.1 2016-10-20 13:26:34 +02:00
Adam Saponara
55d17662cb Fix bug #71241: array_replace_recursive mutates ref params
`array_replace_recursive` can sometimes mutate its params if
references are nested within. This differs from the PHP 5 behavior.
2016-10-20 13:22:04 +02:00
Márcio Almada
cba560e67f add extra test to protected behavior of compact and array string key order 2016-09-01 13:01:42 +02:00
Márcio Almada
00c2c3a476 fix unintentional bc break with compact('this') behavior 2016-09-01 13:01:38 +02:00
Nikita Popov
11e050920d Fix memory unsafety in array_walk()
Fixes bugs #61967, #62607, #69068, #70713.

The primary changes are:
a) Use the ht_iterator mechanism to ensure safety not only if the
   iterated array itself changes, but also if it is replaced (and
   potentially destroyed) entirely. We use the same semantics for
   behavior under modification as foreach-by-reference. In
   particular, we advance to the next element before processing it.
   If the iterated entity is exchanged we iterate the new one from
   the start. If it is not an array/object we warn and abort.
b) Always create a reference to the current value. Previously the
   code kept the value as a non-reference and updated it to the
   reference value produced by the user callback. However this is
   unsafe, as the array may have been reallocated in the meantime,
   so the previous value pointer is no longer value.
c) Around a recursive walk, incref the reference containing the
   array. This ensures that the location where the currently
   iterated value is stored cannot be freed.

One problem I was not able to solve is that we cannot decrement
the apply count if the array is exchanged during a recursive walk.
2016-07-30 00:15:32 +02:00
Nikita Popov
261c436d8c Merge branch 'PHP-7.0' into PHP-7.1 2016-07-29 19:08:15 +02:00
Nikita Popov
8a442a33c3 Fix ref handling in array_merge/replace_recursive()
As usual, if the reference has rc=1 it really isn't a reference.
2016-07-29 19:07:04 +02:00
Xinchen Hui
c35dab005c Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72622 (array_walk + array_replace_recursive create references from nothing)
2016-07-20 16:12:49 +08:00
Xinchen Hui
3c3b8c8365 Fixed bug #72622 (array_walk + array_replace_recursive create references from nothing) 2016-07-20 16:12:37 +08:00
Leigh
06607993f6 Improve array_rand distribution 2016-07-06 12:35:13 +01:00
Xinchen Hui
eb65db0808 Use zend_sort in array_multisort (tests change is expected) 2016-06-23 20:58:45 +08:00
Dmitry Stogov
ff363e2e7c Implemented RFC: Replace "Missing argument" warning with "Too few arguments" exception
Squashed commit of the following:

commit 8b45fa2acb
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 01:52:50 2016 +0300

    Separate slow path of ZEND_RECV into a cold function.

commit 9e18895ee5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 23:26:28 2016 +0300

    Required argument can't be IS_UNDEF anymore.

commit 662db66e39
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 17:14:50 2016 +0300

    Replace "Missing argument" warning by "Too few arguments" exception.
2016-06-16 02:32:02 +03:00
Dmitry Stogov
bfcf32237e Fixed bug #72369 (array_merge() produces references in PHP7) 2016-06-09 15:07:44 +03:00
Thomas Punt
39052d4d75 Resolve bug #72017 2016-05-16 19:15:40 +02:00
Bob Weinand
74ef863f5d Fixed bug #72116 (7.0.6 array_fill optimization breaks implementation) 2016-04-28 11:02:47 +02:00
Nikita Popov
d8590940a1 Use symtable lookup for arrays in array_column 2016-04-16 09:59:01 +02:00
Nikita Popov
28801bf249 Respect property visibility in array_column 2016-04-16 09:59:01 +02:00
Nikita Popov
c0d8dc5bd7 Fixed bug #72031 2016-04-16 09:58:57 +02:00
Nikita Popov
b1e854f776 Fix bug #71334
Always duplicate the array before doing a sort with user-defined
comparison function, to avoid access to the intermediate
inconsistent state.

I've also dropped the "array modification" warning, as protection
against modifications is no longer relevant if we're always working
on a copy anyway.

This also required some changes to how SplArray forwards calls to
sorting functions.
2016-03-30 22:49:27 +02:00
Xinchen Hui
345ecd9822 Fixed #71837 (Wrong arrays behaviour) 2016-03-17 07:41:41 -07:00
Xinchen Hui
c299b272c7 Fixed bug #71660 (array_column behaves incorrectly after foreach by reference) 2016-02-25 16:07:22 +08:00
Xinchen Hui
0fccd154bd Fixed bug #71603 (compact() maintains references in php7) 2016-02-16 11:02:57 +08:00
Thomas Punt
3bbcd84e2f re-apply patch for github PR #1695 2016-01-12 07:07:51 +01:00
Anatol Belski
66d10fe085 Revert "patch for github PR #1695"
This reverts commit 58dd956b63.

crashes on travis
2016-01-11 22:03:36 +01:00
Thomas Punt
58dd956b63 patch for github PR #1695 2016-01-11 21:11:55 +01:00
Xinchen Hui
decb934e3a Fixed test (extract is no affected) 2015-12-25 21:31:42 -08:00
Xinchen Hui
c56efb848b Fixed bug #71220 (Null pointer deref (segfault) in compact via ob_start) 2015-12-25 21:25:53 -08:00
Xinchen Hui
801e46d8c0 Add test for bug (count on symbol table)
I should have do this ....
2015-11-23 06:21:30 -08:00
Xinchen Hui
fce44a5a13 Fixed bug #70910 (extract() breaks variable references) 2015-11-13 19:39:59 -08:00
Xinchen Hui
179fba3f38 Fixed bug #70808 (array_merge_recursive corrupts memory of unset items)
I knew, this fix seems ugly
2015-10-29 14:33:58 +08:00
Dmitry Stogov
3815e97136 Fixed bug #70668 (array_keys() doesn't respect references when $strict is true) 2015-10-08 14:59:02 +03:00
Dmitry Stogov
24e88348f3 Revert "Merge branch 'array_keys_strict_refs' of https://github.com/tony2001/php-src"
This reverts commit a6be0f3fd6.
2015-10-06 23:48:12 +03:00
Bob Weinand
a6be0f3fd6 Merge branch 'array_keys_strict_refs' of https://github.com/tony2001/php-src 2015-10-05 14:50:04 +02:00