Commit graph

1008 commits

Author SHA1 Message Date
Máté Kocsis
aadd3aaed9
Use RETURN_THROWS() in various places 2020-01-03 21:10:24 +01:00
Máté Kocsis
01a50778d1
Use RETURN_THROWS() after zend_throw_exception() in most of the extensions 2020-01-02 10:56:18 +01:00
Máté Kocsis
349a286461
Use RETURN_THROWS() after zend_throw_error() 2020-01-01 16:42:30 +01:00
Máté Kocsis
9099dbd961
Use RETURN_THROWS() after zend_type_error() 2020-01-01 14:23:21 +01:00
Máté Kocsis
12ce73a5bb
Use RETURN_THROWS() after zend_value_error() 2019-12-31 16:58:15 +01:00
Máté Kocsis
31cf9a7ea9
Use RETURN_THROWS() when an exception is thrown
Closes GH-5036
2019-12-30 17:38:10 +01:00
Tyson Andre
366713d250 Speed up array_intersect/array_diff/array_filter
Use zend_hash_update instead of zend_hash_add.

These are taking a subset of keys from an array with unique keys,
so the result should also have unique keys.
(this is already done for array_map())

Also, speed up array_intersect and array_diff slightly by
using ZEND_HASH_FOREACH macros.
This way, it doesn't need to load the same buckets and array counts
from memory every time (compiler previously couldn't infer they won't change)

```php
<?php
// $n=10000 now takes 0.095 seconds instead of 0.102
function test_bench(int $n) {
    $values = range(0,1000);
    $other = range(0,1000);
    unset($other[500]);
    unset($values[400]);

    $total = 0;
    for ($i = 0; $i < $n; $i++) {
        $total += count(array_intersect_key($values, $other));
    }
    return $total;
}
```
2019-12-10 19:29:49 -05:00
George Peter Banyard
f03d311f1a Capitalize first character of error message. 2019-12-05 14:22:53 +01:00
George Peter Banyard
5fbd49f9ab Convert Errors to ValueErrors
Closes GH-4930
2019-12-05 14:22:54 +01:00
Nikita Popov
0027ad4801 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78759
2019-11-07 11:17:38 +01:00
Nikita Popov
aed4f6e849 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78759
2019-11-07 11:17:14 +01:00
Nikita Popov
8d2a9d8859 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #78759
2019-11-07 11:16:24 +01:00
Nikita Popov
5fa6dcd972 Fixed bug #78759
Handle INDIRECT values in array.
2019-11-07 11:15:29 +01:00
Máté Kocsis
14bdb0cfc7 Fix consistency issues with array accesses warnings/exceptions
* Change a number of "resource used as offset" notices to warnings,
   which were previously missed.
 * Throw the "resource used as offset" warning for isset() as well.
 * Make array_key_exists() behavior with regard to different key
   types consistent with isset() and normal array accesses. All key
   types now use the usual coercions and array/object keys throw
   TypeError.

Closes GH-4887.
2019-11-06 12:56:47 +01:00
Nikita Popov
c46b2ed677 Remove support for array_key_exists() with objects 2019-11-04 13:10:03 +01:00
Tyson Andre
96f361dca0 Update documentation/comment for GH-4860
Fix folding for the new helper method.

Clarify comment in UPGRADING:
The performance on associative arrays would also improve,
as long as no offsets were unset (no gaps).
Packed arrays can have gaps.

Closes GH-4873.
[ci skip]
2019-10-30 10:26:56 +01:00
Tyson Andre
e7ff590d0d Optimize array_slice for packed arrays with large offsets
If the offset is 100000, and there are no gaps in the packed/unpacked array,
then advance the pointer once by 100000,
instead of looping and skipping 100000 times.

Add a new test of array_slice handling unset offsets.

Closes GH-4860.
2019-10-28 11:30:59 +01:00
Colin O'Dell
e7335eb420 Allow array_splice() length to be null 2019-10-23 11:22:12 +02:00
Colin O'Dell
8ccd58baca Add Z_PARAM_LONG_OR_NULL macro 2019-10-22 12:09:04 +02:00
Dmitry Stogov
b02b81299c Comparison cleanup:
- introduce zend_compare() that returns -1,0,1 dirctly (without intermediate zval)
- remove compare_objects() object handler, and keep only compare() handler
2019-10-07 17:57:49 +03:00
Nikita Popov
5f80eb7842 Fix required number of arguments in stubs
* get_parent_class() argument is optional
* Mark array_filter() $callback as optional
* The $base of gmp_strval() is optional
* DateTime constructor also accepts zero arguments
* hash_update_file() stream context is optional
* xmlwriter_write_dtd_entity() $isparam argument is optional
2019-10-07 16:33:41 +02:00
Nikita Popov
647b1c7fcf Remove most uses of ZEND_PARSE_PARAMETERS_END_EX()
As ZPP now throws, it makes no sense to specify an explicit return
value.
2019-10-07 10:02:18 +02:00
George Peter Banyard
d5e9ef8f0f Promote warnings to error in array_flip()
Closes GH-4576.
2019-10-02 12:31:02 +02:00
George Peter Banyard
1ca4ab09a5 Promote warnings to errors in array_push()
This is in line with the engine change from
https://wiki.php.net/rfc/engine_warnings.
2019-10-02 10:38:23 +02:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
George Peter Banyard
f816171240 Indicate entry is skipped in error message 2019-09-18 22:30:12 +02:00
Nikita Popov
2cafaab885 Merge branch 'PHP-7.4' 2019-09-17 13:15:01 +02:00
Nikita Popov
d266ba4f2d Check for exception after calling count_values()
To avoid a duplicate error if count_values() throws.
2019-09-17 13:13:44 +02:00
George Peter Banyard
62751b0d45
Promote warnings to errors in array_walk(_recursive)() 2019-08-29 16:02:59 +02:00
George Peter Banyard
81277a104c
Promote warnings to errors in compact() 2019-08-29 16:02:20 +02:00
George Peter Banyard
20edea5a85
Promote warnings to errors in array_merge(_recursive)() and array_replace() 2019-08-29 16:01:39 +02:00
George Peter Banyard
70e604ee46 Promote warnings to errors in extract() 2019-08-28 23:15:01 +02:00
George Peter Banyard
9fc3d5da11 Promote warnings to errors in max() 2019-08-27 23:41:22 +02:00
George Peter Banyard
b91a881b32 Promote warnings to errors in min() 2019-08-27 23:38:22 +02:00
Nikita Popov
a47f170a75 Assert that symbol table is available in compact()
I believe NULL here is no longer possible due to the dynamic call
check. A similar assumption already exists in the extract()
implementation.
2019-08-26 14:25:48 +02:00
George Peter Banyard
c1c8538f95 Promote warnings to errors in array_rand() 2019-08-26 13:31:02 +02:00
Theodore Brown
d5f42d68c8 Convert remaining array function arginfo to PHP stubs 2019-08-26 12:53:00 +02:00
George Peter Banyard
c1fcf2d616 Promote warnings to errors in array_pad() 2019-08-22 19:30:20 +02:00
George Peter Banyard
7dcbcd4ca5 Promote warnings to errors in array_column() 2019-08-22 19:27:47 +02:00
George Peter Banyard
7d4e3dc32d Promote warnings to errors in array_combine() 2019-08-21 18:12:56 +02:00
George Peter Banyard
eaf66df517 Promote warnings to errors in array_multisort() 2019-08-21 18:10:13 +02:00
George Peter Banyard
c70f92caf8 Promote warning to error in array_chunk() 2019-08-21 18:07:35 +02:00
George Peter Banyard
7c6acc2eef Promote warnings to errors in range() 2019-08-21 18:05:08 +02:00
Nikita Popov
36db71df47 Merge branch 'PHP-7.4' 2019-07-22 12:28:40 +02:00
Nikita Popov
0ba7c3eadf Deprecate array_key_exists() on objects 2019-07-22 11:39:52 +02:00
Nikita Popov
57a385db09 Merge branch 'PHP-7.4' 2019-07-05 11:21:43 +02:00
Nikita Popov
ea86a9209c Optimize integer in_array with strict=true
It doesn't make sense that using in_array with strict=false is
much faster for this case, due to lack of a specialized codepath.
2019-07-05 11:20:29 +02:00
Peter Kokot
7f994990ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove HAVE_STRCOLL check
2019-06-28 00:13:25 +02:00
Peter Kokot
638c21765c Remove HAVE_STRCOLL check
The strcoll function is defined in the C89 standard and should be
on today's systems always available via the <string.h> header.

https://port70.net/~nsz/c/c89/c89-draft.html#4.11.4.3

- Remove also SKIPIF strcoll check in test
2019-06-28 00:05:55 +02:00
Nikita Popov
3645292235 Merge branch 'PHP-7.4' 2019-06-19 15:09:39 +02:00