Commit Graph

124825 Commits

Author SHA1 Message Date
Nikita Popov
dcc8463ae5 Deprecate IAP functions on objects
Deprecate use of key(), current(), next(), prev(), reset() and
end() on objects. Cast the object to array first.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:28:33 +02:00
Nikita Popov
5bb83b3778 Deprecate date_sunrise() and date_sunset()
date_sunrise() and date_sunset() are deprecated in favor of
date_sun_info().

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:27:08 +02:00
Kamil Tekiela
7bbc85f16a
Sccp new functions for ct (#7220)
* strstr

* explode
2021-07-08 10:00:26 +01:00
Marco Pivetta
6e16e1daa9 Make ReflectionProperty/Method always accessible
With this patch, it is no longer required to call
`ReflectionProperty#setAccessible()` or
`ReflectionMethod#setAccessible()` with `true`.

If a userland consumer already got to the point of accessing
object/class information via reflection, it makes little sense
for `ext/reflection` to disallow accessing `private`/`protected`
symbols by default.

After this patch, calling `ReflectionProperty#setAccessible(true)`
or `ReflectionMethod#setAccessible(true)` on newly instantiated
`ReflectionProperty` or `ReflectionMethod` respectively will have
no effect.

RFC: https://wiki.php.net/rfc/make-reflection-setaccessible-no-op

Closes GH-5412.
2021-07-08 10:55:38 +02:00
Nikita Popov
2763f14dee Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix constant update for shadowed private property
2021-07-08 10:14:21 +02:00
Nikita Popov
58699ffcf1 Fix constant update for shadowed private property
Updating based on the properties info HT will miss private parent
properties that have been shadowed in the child class. Instead,
perform updating directly on the default properties table.

We can't do the same for static properties, because those don't
have a convenient way to look up the property type from the
property offset. However, I don't believe the problem exists for
static properties, because we're always going to be using the
property on the class it was declared on, while children only hold
INDIRECT references. As such, this should be covered by parent
class const updating.

Fixes oss-fuzz #35906.
2021-07-08 10:12:40 +02:00
Benjamin Eberlei
bc39abe8c3 Fix #80097: Have ReflectionAttribute implement Reflector and __toString
Implement printing for ReflectionAttribute. Attributes aren't
printed as part of reflection output for other structures (classes
etc) yet.

Closes GH-6117.
2021-07-07 12:42:04 +02:00
Nikita Popov
ce3846cd87 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix use after free on compound division by zero
2021-07-07 09:38:57 +02:00
Nikita Popov
62ecf54f35 Fix use after free on compound division by zero
We can't destroy the result operand early, because the division
might fail, in which case we need to preserve the original value.
Place the division result in a temporary zval, and only copy it
on success.

Fixes oss-fuzz #35876.
2021-07-07 09:38:30 +02:00
Ben Morss
cee33bab16
AVIF support for getimagesize() and imagecreatefromstring()
Thanks to Joe Drago for help with the AVIF detection code.

Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-7091.
2021-07-07 00:02:57 +02:00
Máté Kocsis
a5360e80c2
Add support for final class constants
RFC: https://wiki.php.net/rfc/final_class_const

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-06 21:42:38 +02:00
Ben Ramsey
c6d4f60827
The master branch is now for 8.1.0beta1 2021-07-06 10:23:32 -05:00
Nikita Popov
f43a19ee94 Slightly clean up reflection constant printing
The basic formatting is always the same, the only thing that
differs is how the value is printed, so don't duplicate the rest.
2021-07-06 16:25:05 +02:00
Nikita Popov
5502910ed8 Fix phar test
Make getCurrentLine() return a string rather than an array.
2021-07-06 14:53:50 +02:00
Nikita Popov
8a67dfd16b Ensure correct return type from SplFileObject::getCurrentLine()
This is necessary to maintain return type consistency once
tentative return types are added.
2021-07-06 14:32:39 +02:00
Nikita Popov
188b1d4c7c SplFileObject::fgetcsv(): Consistently return false on failure
Both the documentation and the stubs state that this method is
supposed to return false on failure. However, if the line read
(rather than the getcsv operation) fails, it would incorrectly
return null instead.
2021-07-06 14:24:26 +02:00
Christoph M. Becker
2ad97f5cbd
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix new test for PHP 8.0
2021-07-06 13:30:05 +02:00
Christoph M. Becker
52a00fe776
Fix new test for PHP 8.0 2021-07-06 13:27:23 +02:00
Nikita Popov
ac7a28189a Add initialization checks to DirectoryIterator methods 2021-07-06 13:08:53 +02:00
Nikita Popov
e258f13fab Add test for weird fgetcsv behavior
I was trying to figure out when fgetcsv parsing can return false.
Apparently this can only happen if there is an unclosed enclosure
and no terminating newline -- why does the newline matter???
2021-07-06 12:37:22 +02:00
Nikita Popov
076fbd360a Minor fgetcsv cleanup
Reduce some variable scopes.
2021-07-06 12:37:22 +02:00
Nikita Popov
1a81251dbb Use some early returns in spl_directory 2021-07-06 12:37:22 +02:00
Christoph M. Becker
a3abcc063e
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81223: flock() only locks first byte of file
2021-07-06 12:03:55 +02:00
Christoph M. Becker
d776413f0b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81223: flock() only locks first byte of file
2021-07-06 12:00:09 +02:00
Christoph M. Becker
520c00a5bf
Fix #81223: flock() only locks first byte of file
`flock()` should lock the whole file, like on other systems which use
mandatory locking.  We cannot use `0` like for `flck.l_len`, so we use
the largest number, what is valid according to the documentation:
<https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfileex#remarks>.

Closes GH-7216.
2021-07-06 11:58:02 +02:00
Brent Roose
909e13459c Fix typo "without-pcre-jit" 2021-07-06 11:47:00 +02:00
Nikita Popov
bb97c947e3 Slightly clarify current_zval handling in spl_directory
This used COPY_DEREF in some places where references can't occur.
2021-07-06 11:37:42 +02:00
Máté Kocsis
65b96397b3
Declare tentative return types for ext/intl (#6986) 2021-07-06 10:55:43 +02:00
Nikita Popov
54c4c7d747 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ArrayObject::exchangeArray() return type
2021-07-06 10:52:46 +02:00
Nikita Popov
bcefc31e4e Fix ArrayObject::exchangeArray() return type
This method cannot return null.
2021-07-06 10:52:08 +02:00
Christoph M. Becker
097cae9d90
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74264: grapheme_strrpos() broken for negative offsets
2021-07-05 18:21:29 +02:00
Christoph M. Becker
8071bd2faf
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74264: grapheme_strrpos() broken for negative offsets
2021-07-05 18:15:24 +02:00
Christoph M. Becker
28c9376306
Fix #74264: grapheme_strrpos() broken for negative offsets
We must not assume that `usearch_last()` gives the proper result for
negative offsets.  Instead we'd need to continue to search backwards
(`usearch_previous`) until we find a proper match.  However, apparently
searching backwards is broken, so we work around by searching forward
from the start of the string until we pass the `offset_pos`, and then
use the previous result.

Closes GH-7189.
2021-07-05 18:11:30 +02:00
Alex Dowad
b626e893ff Fix conversion of ISO-2022-KR text (and add test suite)
- Truncated multi-byte characters are treated as an error
- Truncated or unrecognized escape sequences are treated as an error
- ASCII control characters are not allowed to appear in the middle
  of a multi-byte character
2021-07-05 16:28:16 +02:00
Alex Dowad
658db1f6ea Code cleanup in mbfilter_uhc.c 2021-07-05 16:28:16 +02:00
Alex Dowad
0a8c00755d Fix conversion of EUC-JP-2004 text (and add test suite)
- Truncated multi-byte characters are treated as an error now
- Invalid multi-byte characters are treated as an error rather than
  being quietly swallowed
- ASCII control characters are not allowed to appear in the middle
  of a multi-byte character
2021-07-05 16:28:16 +02:00
George Peter Banyard
069a9fa5e4
Pure Intersection types (#6799)
Implement pure intersection types RFC

RFC: https://wiki.php.net/rfc/pure-intersection-types

Co-authored-by: Nikita Popov <nikic@php.net>
Co-authored-by: Ilija Tovilo <ilutov@php.net>
2021-07-05 14:11:03 +02:00
Nikita Popov
629965c80f Handle promoted exception in int|string type
Fixes oss-fuzz #35790.
2021-07-05 10:48:20 +02:00
Christoph M. Becker
9a42d2b87b
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
2021-07-04 23:15:14 +02:00
Christoph M. Becker
d86c25d88e
Fix build
`accel_system_id` gas been renamed to `zend_system_id`.
2021-07-04 23:13:50 +02:00
Christoph M. Becker
b09134139e
Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:56:37 +02:00
Christoph M. Becker
948b83d7ea
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:54:48 +02:00
Christoph M. Becker
b1840737e2
Avoid OOB reads in create_name_with_username()
`accel_uname_id` and `zend_system_id` are MD5 buffers which are not
NUL terminated.  Thus, we must not pass them to `snprintf()`.

Closes GH-6968.
2021-07-04 22:51:55 +02:00
Nikita Popov
600dc57f24 Add ext/reflection to execute parser corpus 2021-07-04 12:31:14 +02:00
Anatol Belski
e7123ef569
phar: crc32: Extend and cleanup API for the new bulk crc32 functions
As suggested on the patch discussion, adding init/end macros. Plus,
prefixed the new functions with php_ to avoid possible symbol conflicts.

Signed-off-by: Anatol Belski <ab@php.net>
2021-07-03 21:03:47 +02:00
Ben Morss
fea437af56 Reduce girl.avif by 4x
This will make tests much faster, since one of our tests involves lossless conversion.
2021-07-03 09:41:30 +02:00
Nikita Popov
7bc0dd21c8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing error condition to stream_context_set_option()
2021-07-02 17:56:26 +02:00
Nikita Popov
1b01bf3a95 Add missing error condition to stream_context_set_option()
Previously this caused a null pointer dereference if the value
argument was not provided.
2021-07-02 17:55:31 +02:00
Nikita Popov
f7b1238f13 Handle out of order destruction of RecursiveIteratorIterator 2021-07-02 17:14:00 +02:00
Nikita Popov
29b82695b5 Fix leak of callable error if exception also thrown 2021-07-02 16:33:14 +02:00