Commit Graph

1223 Commits

Author SHA1 Message Date
Nikita Popov
73ab7b30ca Allow array_diff() and array_intersect() with single array argument
Both of these functions are well-defined when used with a single
array argument -- rejecting this case was an artificial limitation.
This is not useful when called with explicit arguments, but removes
edge-cases when used with argument unpacking:

    // OK even if $excludes is empty.
    array_diff($array, ...$excludes);

    // OK even if $arrays contains a single array only.
    array_intersect(...$arrays);

This matches the behavior of functions like array_merge() and
array_push(), which also allow calls with no array or a single
array respectively.

Closes GH-6097.
2020-09-09 11:03:17 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Nikita Popov
3e14942756 Require $method parameter in openssl_seal/openssl_open
RC4 is considered insecure, and it's not possible to change the
default of these functions. As such, require the method to be
passed explicitly.

Closes GH-6093.
2020-09-08 14:21:01 +02:00
Nikita Popov
032f862133 Drop support for crypt() without explicit salt
crypt() without salt generates a weak $1$ MD5 hash. It has been
throwing a notice since 2013 and we provide a much better alternative
in password_hash() (which can auto-generate salts for strong
password hashes), so keeping this is just a liability.
2020-09-07 15:43:26 +02:00
Benjamin Eberlei
842be67b60 Update NEWS, UPGRADING 2020-09-02 20:32:52 +02:00
Christoph M. Becker
e6044d4455 Fix #55847: DOTNET .NET 4.0 GAC new location
If we do not specify the exact version of the .NET framework to use,
the default CLR is loaded, which is typically CLR 2, which is very old.
Therefore, we introduce a `PHP_INI_SYSTEM` setting, which allows users
to choose the desired .NET framework version.  The value of the setting
are the first three parts of the framework's version number, separated
by dots, and prefixed with "v", e.g. "v4.0.30319".  If the value of the
INI setting is `NULL` (the default) or an empty string, the default CLR
is used.

Internally, we switch from the most generic `CoCreateInstance()` to
`CorBindToRuntime()` which is implemented in mscoree.dll.  To avoid the
hard dependency to that library, we load dynamically.

So this fix is supposed to be fully backwards compatible.

Closes GH-5949
2020-08-22 12:42:34 +02:00
Christopher Jones
ff66e4945e OCI8 classes were already renamed in 8; this now follows the new-new standard 2020-08-21 17:46:16 +10:00
Tyson Andre
9883fec99f Fix more basic function stubs
User-defined functions can't have multiple parameters with the same name.
Don't do that for var_dump/debug_zval_dump.

Consistently use array $array to match docs

Fix typo in UPGRADING

Fixes GH-6015
2020-08-18 20:23:42 -04:00
Christoph M. Becker
4514afc187 Fix #79988: new reserved keyword match is a backward incompatible change 2020-08-18 12:39:18 +02:00
Nikita Popov
e81ad4089e Expand upgrading note for namespaced name change
Mention the case from bug #79942.

[ci skip]
2020-08-10 11:20:07 +02:00
Nikita Popov
0d836a39a7 Revert "Prepare for PHP 8.1"
This reverts commit 1ab4d0e6b7.
This reverts commit a359635cb1.
2020-08-04 22:24:44 +02:00
Gabriel Caruso
a359635cb1
Prepare for PHP 8.1 2020-08-04 18:46:14 +02:00
Máté Kocsis
71bfa5344a
Add upgrading note for the resource to object migration in ext/sockets 2020-08-03 23:41:00 +02:00
Theodore Brown
e2b4687403 Minor grammar/consistency fixes in upgrade guide
[ci skip]
2020-08-03 15:34:10 -06:00
Dik Takken
e0fa48f69d Deprecate libxml_disable_entity_loader()
This method was used to protect code against XXE processing attacks.
Since PHP now requires libxml >= 2.9.0 external entity loading no longer
needs to be disabled to prevent these attacks. It is disabled by default.
Also, the method has an unwanted side effect that causes a lot of
confusion: Parsing XML data from resources like files is no longer possible.

Closes GH-5867.
2020-08-03 21:53:29 +02:00
Dik Takken
691a09f291 Bump libxml version requirement 2.7.6 => 2.9.0
Since libxml version 2.9.0 external entity loading is disabled by default.
Bumping the version requirement means that XML processing in PHP is no
longer vulnerable to XXE processing attacks by default.
2020-08-03 21:51:10 +02:00
Jakub Zelenka
44c7128fb7 FPM: Add pm.status_listen option
This option allows getting status from different endpoint (e.g. port
or UDS file) which is useful for getting status when all children are
busy with serving long running requests.

Internally a new shared pool with ondemand process manager is used. It
means that the status requests have reserved resources and should not
be blocked by other requests.
2020-08-03 19:14:13 +01:00
Tyson Andre
0c238ede01 [RFC] Only unserialize Phar metadata when getMetadata() is called
In other words, don't automatically unserialize when the magic
phar:// stream wrappers are used.
RFC: https://wiki.php.net/rfc/phar_stop_autoloading_metadata

Also, change the signature from `getMetadata()`
to `getMetadata(array $unserialize_options = [])`.
Start throwing earlier if setMetadata() is called and serialization threw.

See https://externals.io/message/110856 and
https://bugs.php.net/bug.php?id=76774

This was refactored to add a phar_metadata_tracker for the following reasons:
- The way to properly copy a zval was previously implicit and undocumented
  (e.g. is it a pointer to a raw string or an actual value)
- Avoid unnecessary serialization and unserialization in the most common case
- If a metadata value is serialized once while saving a new/modified phar file,
  this allows reusing the same serialized string.
- Have as few ways to copy/clone/lazily parse metadata (etc.) as possible,
  so that code changes can be limited to only a few places in the future.
- Performance is hopefully not a concern - copying a string should be faster
  than unserializing a value, and metadata should be rare in most cases.

Remove unnecessary skip in a test(Compression's unused)

Add additional assertions about usage of persistent phars

Improve robustness of `Phar*->setMetadata()`

- Add sanity checks for edge cases freeing metadata, when destructors
  or serializers modify the phar recursively.
- Typical use cases of php have phar.readonly=1 and would not be affected.

Closes GH-5855
2020-08-03 13:28:51 -04:00
Rowan Tommins
f9f769d4b9 Make http stream wrapper advertise HTTP/1.1 by default
In practice, we always act as an HTTP/1.1 client, for compatibility
with servers which ignore protocol version. Sending the version in
the request will avoid problems with servers which don't ignore it.

HTTP/1.0 can still be forced using a stream context option.

Closes GH-5899.
2020-08-03 16:30:09 +02:00
Levi Morrison
9b975fe98e Merge branch 'levim/assert-throw'
This changes assert.exception to default to 1, or on by default.
Closes GH-5925.
2020-08-03 08:04:48 -06:00
Nikita Popov
c48b745f00 Promote "undefined array key" notice to warning
This implements the last remaining part of the
https://wiki.php.net/rfc/engine_warnings RFC.

Closes GH-5927.
2020-08-03 14:40:50 +02:00
Gregor Harlan
a6e3ce4fd6 datetime: new format "p", same as "P" but returning "Z" for UTC 2020-08-03 10:44:48 +02:00
Levi Morrison
853eb8373f Default assert.exception to 1 2020-08-02 13:39:35 -06:00
Gabriel Caruso
e3d06fc79d
Ensure correct signatures for magic methods 2020-08-02 01:29:56 +02:00
Tyson Andre
650801ce45 [skip ci] Fix grammar/typo nits in docs
The PHP error message says "well-formed", not "well formed"

Fixes GH-5920
2020-08-01 18:03:45 -04:00
Máté Kocsis
9f44eca6b6
Convert resources to objects in ext/openssl
Closes GH-5860

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-08-01 22:47:20 +02:00
Tyson Andre
97f10fc341 Allow overriding completion in auto_prepend_file
Currently, it's possible to override `php -a`s completion
functionality to provide an alternative to the C implementation,
with `readline_completion_function()`.

However, that surprisingly gets overridden when called from
`auto_prepend_file`, because those scripts get run before the interactive shell
is started. I believe that not overriding it would be more consistent
with what happens when you override the completion function **after** the
interactive shell.

CLI is the only built-in API that uses this (See discussion in GH-5872).
I believe MINIT and RINIT will only run once when invoked with `php -a`.

Add documentation about the architecture of how php uses readline/libedit

Closes GH-5872
2020-08-01 11:39:08 -04:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Theodore Brown
e8c4ae83cb Improve wording and spelling consistency in UPGRADING
[ci skip]
2020-07-29 17:40:02 -06:00
George Peter Banyard
b2248789ed Implement 'Saner Numeric Strings' RFC:
RFC: https://wiki.php.net/rfc/saner-numeric-strings

This removes the -1 allow_error mode from is_numeric_string functions and replaces it by
a trailing boolean out argument to preserve BC in a couple of places.

Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit
a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError.

This mostly affects:
 - String offsets
 - Arithmetic operations
 - Bitwise operations

Closes GH-5762
2020-07-29 02:51:09 +01:00
Theodore Brown
470d1696d9 Implement Shorter Attribute Syntax
RFC: https://wiki.php.net/rfc/shorter_attribute_syntax

Closes GH-5796.

Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2020-07-28 15:28:57 +02:00
Tyson Andre
85d4b560df [skip ci] Add zend.exception_string_param_max_len to UPGRADING
For GH-5769 (mentioned in 07db64156e)
2020-07-27 09:40:24 -04:00
Nikita Popov
d65d3f5298 Fix bug #79108
Don't expose references in debug_backtrace() or exception traces.
This is regardless of whether the argument is by-reference or not.

As a side-effect of this change, exception traces may now acquire
the interior value of a reference, which may be unexpected for
some internal functions. This is what necessitated the change in
the spl_array sort implementation.
2020-07-24 12:23:34 +02:00
Nikita Popov
7eec281b5e Avoid UNKNOWN default in PDO::query() 2020-07-24 11:44:47 +02:00
Nikita Popov
0a5b7c81b7 Make nested ternary without parentheses a compile error
This was deprecated in PHP 7.4.
2020-07-24 10:35:42 +02:00
Ilija Tovilo
9bf119832d
Implement nullsafe ?-> operator
RFC: https://wiki.php.net/rfc/nullsafe_operator

Closes GH-5619.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-07-24 10:05:03 +02:00
Nikita Popov
7a3dcc3e33 Treat namespaced names as single token
Namespace names are now lexed as single tokens of type
T_NAME_QUALIFIED, T_NAME_FULLY_QUALIFIED or T_NAME_RELATIVE.

RFC: https://wiki.php.net/rfc/namespaced_names_as_token

Closes GH-5827.
2020-07-22 12:36:05 +02:00
Nikita Popov
acbf7802af Improved number to string comparison semantics
RFC: https://wiki.php.net/rfc/string_to_number_comparison

Closes GH-3886.
2020-07-22 12:23:49 +02:00
Nikita Popov
e3827cea4e Fix bug #79857: Add upgrading note for exit dtor change
[ci skip]
2020-07-20 15:30:20 +02:00
Pedro Magalhães
272b887b7b Ignore inheritance rules on private methods
Closes GH-5401
2020-07-15 17:09:57 +01:00
Martin Schröder
547d98b81d Support socketpairs in proc_open()
Closes GH-5777.
2020-07-14 10:35:45 +02:00
Nikita Popov
2edc5e00ac Add user upgrading note for no_separation change
I added this to UPGRADING.INTERNALS, but it should also be
mentioned in UPGRADING, as it affects user-visible behavior.

[ci skip]
2020-07-13 14:50:25 +02:00
Nikita Popov
0cab3fa10e Add upgrading note for crypt change
[ci skip]
2020-07-13 14:44:17 +02:00
Máté Kocsis
6cf22529b9
Addd upgrading notes about OCI8 2020-07-11 20:04:40 +02:00
Christoph M. Becker
340e2ead77 Export php_gd_libgdimageptr_from_zval_p()
Some extension may need to retrieve the `gdImagePtr` from an `GdImage`
object; thus, we export the respective function.  To not being forced
to include gd.h in php_gd.h, we use the opaque `struct gdImageStruct *`
as return type.

We also rename php_gd2.dll to php_gd.dll, since there's not really much
point in giving the DLL a version number, since there is no php_gd.dll
for years (if there ever has been).  Renaming, on the other hand,
matches the name on other systems (gd.so), and allows to actually use
`ADD_EXTENSION_DEP()`.
2020-07-11 19:33:20 +02:00
Ilija Tovilo
9fa1d13301
Implement match expression
RFC: https://wiki.php.net/rfc/match_expression_v2

Closes GH-5371.
2020-07-09 23:52:17 +02:00
Ondřej Mirtes
b4dc8901c7 UPGRADING - note about ReflectionType::isBuiltin()
Closes GH-5822.
2020-07-08 17:15:29 +02:00
Paweł Tomulik
915abeb699 Add ldap_count_references()
Closes GH-5784
2020-07-01 09:29:46 +02:00
Christoph M. Becker
3516a9c8f0 Replace ISO_8859-* with ISO8859-* aliases for MBString
We also remove the mbregex ISO 8859 aliases with underscores.
2020-06-30 18:43:40 +02:00
Paweł Tomulik
b3698ed9eb
Promote warning to exception in ldap_set_rebind_proc()
From now on, ldap_set_rebind_proc() will only accept callable or null
as argument 2.

Closes GH-5763
2020-06-30 16:08:34 +02:00
Nikita Popov
41d9423988 Add upgrading note for apache module name
[ci skip]
2020-06-30 15:53:55 +02:00
Eddie Kohler
ada776c84c Make HashContexts serializable.
* Modify php_hash_ops to contain the algorithm name and
  serialize and unserialize methods.

* Implement __serialize and __unserialize magic methods on
  HashContext.

Note that serialized HashContexts are not necessarily portable
between PHP versions or from architecture to architecture.
(Most are, though Keccak and slow SHA3s are not.)

An exception is thrown when an unsupported serialization is
attempted.

Because of security concerns, HASH_HMAC contexts are not
currently serializable; attempting to serialize one throws
an exception.

Serialization exposes the state of HashContext memory, so ensure
that memory is zeroed before use by allocating it with a new
php_hash_alloc_context function. Performance impact is
negligible.

Some hash internal states have logical pointers into a buffer,
or sponge, that absorbs input provided in bytes rather than
chunks. The unserialize functions for these hash functions
must validate that the logical pointers are all within bounds,
lest future hash operations cause out-of-bounds memory accesses.

* Adler32, CRC32, FNV, joaat: simple state, no buffer positions
* Gost, MD2, SHA3, Snefru, Tiger, Whirlpool: buffer positions
  must be validated
* MD4, MD5, SHA1, SHA2, haval, ripemd: buffer positions encoded
  bitwise, forced to within bounds on use; no need to validate
2020-06-30 14:30:33 +02:00
Nikita Popov
6e1990dea6 Don't accept objects instead of arrays in curl
This properly addresses the issue from bug #79741. Silently
interpreting objects as mangled property tables is almost
always a bad idea.

Closes GH-5773.
2020-06-29 15:56:22 +02:00
Martin Schröder
053ef28b8d Implement Attribute Amendments.
RFC: https://wiki.php.net/rfc/attribute_amendments

Support for attribute grouping is left out, because the short
attribute syntax RFC will likely make it obsolete.

Closes GH-5751.
2020-06-29 10:45:51 +02:00
Ayesh Karunaratne
d114812faf [ci skip] Various typo fixes in stub comments and CHANGES file 2020-06-25 23:32:40 +02:00
Nikita Popov
47cf18ba4e Don't include trailing newline in comment token
Don't include a trailing newline in T_COMMENT tokens, instead leave
it for a following T_WHITESPACE token. The newline does not belong
to the comment logically, and this makes for an ugly special case,
as other tokens do not include trailing newlines.

Whitespace-sensitive tooling will want to either forward or backward
emulate this change.

Closes GH-5182.
2020-06-25 11:25:22 +02:00
Nikita Popov
e12b9df05d Make sorting stable
Make user-exposed sorts stable, by storing the position of elements
in the original array, and using those positions as a fallback
comparison criterion. The base sort is still hybrid q/insert.

The use of true/false comparison functions is deprecated (but still
supported) and should be replaced by -1/0/1 comparison functions,
driven by the <=> operator.

RFC: https://wiki.php.net/rfc/stable_sorting

Closes GH-5236.
2020-06-25 10:49:34 +02:00
Nikita Popov
ff19ec2df3 Introduce InternalIterator
Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal classes: They can implement the internal
get_iterator mechanism, without exposing either the Iterator or
IteratorAggregate APIs. This makes them usable in get_iterator(),
but incompatible with any Iterator based APIs.

A lot of internal classes do this, because exposing the userland
APIs is simply a lot of work. This patch alleviates this issue by
providing a generic InternalIterator class, which acts as an
adapater between get_iterator and Iterator, and can be easily
used by many internal classes. At the same time, we extend the
requirement that Traversable implies Iterator or IteratorAggregate
to internal classes as well.

Closes GH-5216.
2020-06-24 15:31:41 +02:00
Nikita Popov
4730b06f1d Make SimpleXMLElement a RecursiveIterator
Context: https://externals.io/message/108789

This essentially moves the functionality of SimpleXMLIterator into
SimpleXMLElement, and makes SimpleXMLIterator a no-op extension.

Ideally SimpleXMLElement would be an IteratorAggregate, whose
getIterator() method returns SimpleXMLIterator. However, because
SimpleXMLIterator extends SimpleXMLElement (and code depends on
this in non-trivial ways), this is not possible.

The only way to not keep SimpleXMLElement as a magic Traversable
(that implements neither Iterator nor IteratorAggregate) is to
move the SimpleXMLIterator functionality into it.

Closes GH-5234.
2020-06-24 15:09:21 +02:00
Christoph M. Becker
18f58080dc Convert shmop resources to opaque objects
We make `shmop_close()` a NOP, and deprecate the function right away;
detaching from SHM now happens when the wrapper object is freed.
2020-06-24 13:59:29 +02:00
Nikita Popov
d579b10c84 Remove deprecated DES fallback in crypt() 2020-06-24 12:57:04 +02:00
Máté Kocsis
f3b1f342c8
Deprecate the procedural API of ext/zip
Closes GH-5746
2020-06-23 17:39:29 +02:00
Máté Kocsis
a43fd3bbef
Remove the deprecated parameter of curl_version() 2020-06-18 13:26:32 +02:00
Máté Kocsis
314eedbc35
Convert resources to objects in ext/zlib
Closes GH-5680
2020-06-17 16:50:00 +02:00
Máté Kocsis
b516566b84
Convert CURL resources to objects
Closes GH-5402

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-06-17 16:11:57 +02:00
Máté Kocsis
2e18b30d44
Convert resource to object in Sysvshm extension
Closes GH-5499
2020-06-16 16:36:11 +02:00
Jakub Zelenka
367c55ff1d Update NEWS and UPGRADING for the OpenSSL ext CMS addition 2020-06-07 21:11:09 +01:00
Gabriel Caruso
7439941d55
Add $filter parameter for ReflectionClass::(getConstants|getReflectionConstants)
This solves [#79628](https://bugs.php.net/79628).

Similar to `ReflectionClass::getMethods()` and `ReflectionClass::getProperties()`,
this new `$filter` argument allows the filtering of constants defined in a class by
their visibility.

For that, we create three new constants for `ReflectionClassConstant`:

  * `IS_PUBLIC`
  * `IS_PROTECTED`
  * `IS_PRIVATE`

Closes GH-5649.
2020-06-07 15:57:48 +02:00
Nikita Popov
064b464448 Implement "Constructor Promotion" RFC
RFC: https://wiki.php.net/rfc/constructor_promotion

Closes GH-5291.
2020-06-05 15:15:51 +02:00
Benjamin Eberlei
1622d22c62 Add upgrading note for Attributes RFC
[ci-skip]
2020-06-04 18:21:18 +02:00
Nikita Popov
eeb7a7cd7a Add UPGRADING note for pty support
[ci skip]
2020-05-31 17:14:41 +02:00
Nikita Popov
393cd89ffb Add UPGRADING note for xmlrpc unbundling
And drop other UPGRADING references to xmlrpc. I don't think it
makes sense to have those for extensions that are no longer
shipped...

[ci skip]
2020-05-31 16:57:37 +02:00
Nikita Popov
d7f17ea44d Fix some line overruns in UPGRADING
[ci skip]
2020-05-31 16:55:46 +02:00
Nikita Popov
805e3e3af4 Move upgrading note for mixed
This should be in the "new features" section.

[ci skip]
2020-05-31 16:48:14 +02:00
George Peter Banyard
2302b14aab Use ZPP callable check for spl_autoload_register.
This makes it always throw a TypeError, moreover this makes the
error message consistent.

Added a warning mentioning that the second parameter is now ignored
when passed false.

Closes GH-5301
2020-05-30 13:59:06 +02:00
Máté Kocsis
444aa2636e
Add upgrading notes about the deprecated functionality in ext/enchant
[skip ci]
2020-05-29 15:15:27 +02:00
Máté Kocsis
cd3e04dff3
Convert enchant resources to opaque objects
Additionally, deprecate ENCHANT_MYSPELL and ENCHANT_ISPELL constants.
Closes GH-5577

Co-authored-by: Remi Collet <remi@php.net>
2020-05-29 14:51:41 +02:00
Tyson Andre
cc27781f40 [RFC] Always enable JSON support in php 8.0
Currently, it's possible to disable the json extension with
`./configure --disable-json` (for historical reasons that no longer apply).
However, JSON is widely used in many use cases - web sites, logging output,
and as a data format that can be used to share data with many applications
and programming languages,
so I'd personally find it useful if it was always enabled.

Examples of where this would be useful:

- For internal classes to be able to implement `JsonSerializable`
  which currently requires a hard dependency on the JSON extension.
- For PHP users to publish single-file scripts that use json_encode and
  json_decode and don't require polyfills or less readable var_export output.
  (polyfills are less efficient and may have issues with recursive data
  structures)
- So that php-src's own modules, tools and test cases can start using JSON
  if it's a good choice for encoding a value. (same for PECLs)

https://wiki.php.net/rfc/jsond mentions that in PHP 5,

> The current Json Parser in the json extension does not have a free license
> which is a problem for many Linux distros.
> This has been referenced at Bug #63520.
> That results in not packaging json extension in the many Linux distributions.

Starting in php 7.0 with the switch to jsond,
It looks like licensing is no longer an issue.

Changes:

- Remove all flags related to JSON such as `configure --disable-json`
- Require that JSON be compiled statically instead of as a shared library

Examples of uses of JSON in various distros
(backwards incompatible changes such as changing packaging are typically
reserved for major versions, and 8.0 is a major version)

- JSON is required by `php-cli` or `php` in ubuntu:
  https://packages.ubuntu.com/focal/php/
- The php-json package has to be installed separately
  from the PHP binary in Fedora repos.

Closes GH-5495
2020-05-27 09:08:43 -04:00
Nikita Popov
0221b8b2ab Add support for * width and precision in printf()
If * is used for width/precision in printf, then the width/precision
is provided by a printf argument instead of being part of the format
string. Semantics generally match those of printf in C.

This can be used to easily reproduce PHP's float printing behavior:

    // Locale-sensitive using precision ini setting.
    // Used prior to PHP 8.0.
    sprintf("%.*G", (int) ini_get('precision'), $float);

    // Locale-insensitive using precision ini setting.
    // Used since to PHP 8.0.
    sprintf("%.*H", (int) ini_get('precision'), $float);

    // Locale-insensitive using serialize_precision ini setting.
    // Used in serialize(), json_encode() etc.
    sprintf("%.*H", (int) ini_get('serialize_precision'), $float);

Closes GH-5432.
2020-05-27 10:42:25 +02:00
Nikita Popov
b6000b7e0e Add support for %h and %H in printf()
These are locale-independent variants of %g and %G.

Closes GH-5436.
2020-05-27 10:19:23 +02:00
Nikita Popov
a01b6e5787 Return empty array instead of null from enchant APIs
Closes GH-5566.
2020-05-27 10:12:21 +02:00
Max Semenik
23ee4d4b57 Support catching exceptions without capturing them to variables
RFC: https://wiki.php.net/rfc/non-capturing_catches

Closes GH-5345.
2020-05-26 15:12:18 +02:00
Máté Kocsis
cbf86efc21
Fix ZPP of v*printf() 2020-05-25 17:29:46 +02:00
Christoph M. Becker
ce668c0ec6 PGSQL and POD_SQL: don't include pg_config.h
Even if that header file is available, we better consider it private,
and don't include it.  The information about whether SSL support is
enabled is now missing (`USE_(OPEN)SSL`), and it seems there is no
alternative way to get it (`PQinitSSL()` is always defined), so we
remove it from the PHP info.  Furthermore, the `PG_VERSION` and
`PG_VERSION_STR` macros are no longer available, but as of libpq 9.1
there is `PQlibVersion()` which allows us to construct `PG_VERSION` in
a most likely backwards compatible manner.  The additional information
available through `PG_VERSION_STR` is lost, though, so we define
`PGSQL_LIBPQ_VERSION_STR` basically as alias of `PGSQL_LIBPQ_VERSION`,
and deprecate it right away.

Since we are now requiring at least libpq 9.1, we can remove some
further compatibility code and additional checks.

Regarding the raised requirements: official support for PostGreSQL 9.0
ended on 2015-10-08, and even CentOS 7 already has PostGreSQL 9.2, so
this is not supposed to be too much of an issue.
2020-05-25 10:48:35 +02:00
George Peter Banyard
bc3ee2eeea [skip-ci] Update UPGRADING
Add upgrading note for mixed type and removal of curly braces offset syntax
2020-05-22 17:02:30 +02:00
Christoph M. Becker
4bc1d8333a Raise ext/pgsql requirements to PostGreSQL 7.4
We can safely assume that users have at the very least libpq 7.4, for
which official support ended on 2010-10-01; even CentOS 6 has 8.4 now.
It is also noteworthy that PDO_PGSQL already requires libpq 7.4 or
later.
2020-05-22 15:56:24 +02:00
Nikita Popov
0a74da385d Add support for replaying warnings in opcache
If opcache.record_warnings is enabled, opcache will record
compilation warnings and replay them when the file is included
again. The primary use case I have in mind for this is automated
testing of the opcache file cache.

This resolves bug #76535.
2020-05-20 11:20:21 +02:00
Máté Kocsis
9198faa67f
Convert resource to object in Sysvmsg
Closes GH-5546
2020-05-14 12:56:06 +02:00
Remi Collet
30077100a4 Revert "doc for enchant Object move"
This reverts commit 2c63324a4e.
2020-05-13 15:56:18 +02:00
Remi Collet
2c63324a4e doc for enchant Object move 2020-05-13 15:23:07 +02:00
Máté Kocsis
256b7da356
Convert resource to object in XML-RPC extension
Closes GH-5457
2020-05-13 14:49:13 +02:00
Nikita Popov
28af364d2a Deprecate old ReflectionParameter type declaration APIs
This deprecates:

    ReflectionParameter::isArray()
    ReflectionParameter::isCallable()
    ReflectionParameter::getClass()

These APIs have been superseded by ReflectionParameter::getType()
since PHP 7.0. Types introduced since that time are not available
through the old APIs, and their behavior is getting increasingly
confusing. This is how they interact with PHP 8 union types:

 * isArray() will return true if the type is array or ?array,
   but not any other union type
 * Same for isCallable().
 * getClass() will return a class for T|int etc, as long as the
   union only contains a single type. T1|T2 will return null.

This behavior is not particularly reasonable or useful, and will
get more confusing as new type system extensions are added.

Closes GH-5209.
2020-05-11 17:01:40 +02:00
Nikita Popov
a0abc26ef7 Add get_resource_id() function
Behavior is same as for (int) $resource, just under a clearer
name. Also type-safe, in that the parameter actually needs to
be a resource.

Closes GH-5427.
2020-05-11 12:04:16 +02:00
Máté Kocsis
4a816584a4
Make float to string casts locale-independent
From now on, float to string casting will always behave locale-independently.
RFC: https://wiki.php.net/rfc/locale_independent_float_to_string
Closes GH-5224

Co-authored-by: George Peter Banyard <girgias@php.net>
2020-05-08 10:52:23 +02:00
Máté Kocsis
b67f699dcd
Rename the recently introduced Sysvsem class to SysvSemaphore 2020-05-07 10:21:58 +02:00
Máté Kocsis
eab54d2382
Convert resource to object in ext/sysvsem
Closes GH-5508
2020-05-06 15:42:41 +02:00
Nikita Popov
5bc1e224db Make numeric operations on resources, arrays and objects type errors
RFC: https://wiki.php.net/rfc/arithmetic_operator_type_checks

Closes GH-5331.
2020-05-05 16:11:13 +02:00
William Hudgins
31fb6a08b3 Add str_starts_with() and str_ends_with()
RFC: https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions

Closes GH-5300.
2020-05-05 16:03:47 +02:00
AllenJB
50752401a7 Change the default PDO error mode to exceptions
According to <https://www.php.net/manual/en/pdo.error-handling.php>.
2020-05-04 22:51:47 +02:00
Remi Collet
3427545752 Use libenchant-2 when available 2020-05-04 08:27:31 +02:00
Christoph M. Becker
69888c3ff1 Fix #79467: data:// wrappers are writable
Despite the docs claiming that data: wrappers would not be writable[1],
they are implemented as writing to a memory stream.  That does not seem
to be particularly sensible, so we disallow writing altogether.

[1] <https://www.php.net/manual/en/wrappers.data.php#refsect1-wrappers.data-options>
2020-05-03 12:19:37 +02:00
Tyson Andre
1dbf923866
[skip ci] Fix a typo in UPGRADING
Confirmed that php_zip.c checks for `"enc_password"`

Closes GH-5503
2020-05-01 12:22:24 +02:00
Nikita Popov
c4ad8beaa8 Do not inherit LC_CTYPE locale from environment
Treatment of locales in PHP is currently inconsistent: The LC_ALL
locale is set to "C", as is standard behavior on program startup.
The LC_CTYPE locale is set to "", which will inherit it from the
environment. However, the inherited LC_CTYPE locale will only be
used in some cases, while in other cases it is necessary to perform
an explicit setlocale() call in PHP first. This is the case for
the locale-sensitive handling in the PCRE extension.

Make things consistent by *never* inheriting any locales from the
environment. LC_ALL, including LC_CTYPE will be "C" on startup.
A locale can be set or inherited through an explicit setlocale()
call, at which point the behavior will be fully consistent and
predictable.

Closes GH-5488.
2020-04-30 10:22:51 +02:00
Nikita Popov
53eee290b6 Completely remove disabled functions from function table
Currently, disabling a function only replaces the internal
function handler with one that throws a warning, and a few
places in the engine special-case such functions, such as
function_exists. This leaves us with a Schrödinger's function,
which both does not exist (function_exists returns false) and
does exist (you cannot define a function with the same name).
In particular, this prevents the implementation of robust
polyfills, as reported in https://bugs.php.net/bug.php?id=79382:

    if (!function_exists('getallheaders')) {
        function getallheaders(...) { ... }
    }

If getallheaders() is a disabled function, this code will break.

This patch changes disable_functions to remove the functions from
the function table completely. For all intents and purposes, it
will look like the function does not exist.

This also renders two bits of PHP functionality obsolete and thus
deprecated:

 * ReflectionFunction::isDisabled(), as it will no longer be
   possible to construct the ReflectionFunction of a disabled
   function in the first place.
 * get_defined_functions() with $exclude_disabled=false, as
   get_defined_functions() now never returns disabled functions.

Fixed bug #79382.

Closes GH-5473.
2020-04-30 09:53:57 +02:00
Remi Collet
1b98151734 doc enchant changes 2020-04-30 09:40:46 +02:00
Nikita Popov
f545ee2c6c Allow optional trailing comma in parameter list
RFC: https://wiki.php.net/rfc/trailing_comma_in_parameter_list

Closes GH-5306.
2020-04-28 16:11:08 +02:00
Ilija Tovilo
0810fcd0d0 Make throw statement an expression
RFC: https://wiki.php.net/rfc/throw_expression

This has an open issue with temporaries that are live at the time
of the throw being leaked. Landing this now for easier testing and
will revert if we cannot resolve the issue.

Closes GH-5279.
2020-04-23 12:51:23 +02:00
Jacob Dreesen
64d30c1976 Fix typo in UPGRADING [ci skip] 2020-04-23 11:54:18 +02:00
Your Name
ef0e4478c5 Add get_debug_type() function
RFC: https://wiki.php.net/rfc/get_debug_type
2020-04-23 10:45:08 +02:00
Nikita Popov
8597ec00d4 Remove support for libmysqlclient 5.0
Closes GH-5391.
2020-04-23 10:38:20 +02:00
Nicolas Grekas
657f756ccd Skip non-existing properties returned by __sleep() 2020-04-22 16:41:04 +02:00
Tyson Andre
630897f996 Document change to ReflectionMethod->isConstructor/isDestructor
See https://externals.io/message/109377
This prevented PHPUnit's test doubles from being created for interfaces.

The reason this changed is
https://github.com/php/php-src/pull/3846/files#diff-3a8139128d4026ce0cb0c86beba4e6b9L5549-R5605
(ReflectionMethod::isConstruct checks if the method is the zend_class_entry's
constructor, etc.)
2020-04-22 15:24:35 +02:00
Nikita Popov
661c0ac7f3 Remove support for EBCDIC
Closes GH-5390.
2020-04-20 16:39:39 +02:00
Máté Kocsis
3709e74b5e
Store default parameter values of internal functions in arg info
Closes GH-5353. From now on, PHP will have reflection information
about default values of parameters of internal functions.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-04-08 18:37:51 +02:00
Remi Collet
319c21b1f6 news / UPGRADING for zip 1.19.0 2020-04-02 14:58:13 +02:00
Nikita Popov
5a09b9fb0f Add PhpToken class
RFC: https://wiki.php.net/rfc/token_as_object

Relative to the RFC, this also adds a __toString() method,
as discussed on list.

Closes GH-5176.
2020-03-26 11:09:18 +01:00
Nikita Popov
f74e30c07c Check abstract method signatures coming from traits
RFC: https://wiki.php.net/rfc/abstract_trait_method_validation

Closes GH-5068.
2020-03-26 10:07:22 +01:00
Máté Kocsis
782f7e2ad8
Fix #75958 Return void instead of true 2020-03-25 15:04:33 +01:00
Remi Collet
d12b4c3c24 bump zip version 2020-03-20 14:08:57 +01:00
Remi Collet
a4d12f46d1 ZipArchive::open(): Using empty file as ZipArchive is deprecated 2020-03-20 11:27:42 +01:00
Nikita Popov
df79277de3 Revert "Fetch for read in nested property assignments"
This reverts commit bb43a3822e.

After thinking about this a bit more, this is now going to be
a complete solution for the "readonly properties" case, for example:

    unset($foo->readOnly->bar);

should also be legal and

    $foo->readOnly['bar'] = 42;

should also be legal if $foo->readOnly is not an array but an
ArrayAccess object.

I think it may be better to distinguish better on the BP_VAR flag
level. Reverting for now.
2020-03-18 14:54:43 +01:00
Remi Collet
a5f136b855 bump zp to 1.18.1 + doc 2020-03-18 14:09:50 +01:00
Nikita Popov
bb43a3822e Fetch for read in nested property assignments
$a->b->c = 'd';

is now compiled the same way as

    $b = $a->b;
    $b->c = 'd';

That is, we perform a read fetch on $a->b, rather than a write
fetch.

This is possible, because PHP 8 removed auto-vivification support
for objects, so $a->b->c = 'd' may no longer modify $a->b proper
(i.e. not counting interior mutability of the object).

Closes GH-5250.
2020-03-18 12:08:06 +01:00
Christoph M. Becker
66d8d0c7d7 Drop support for iconv without proper errno setting
It is hard to impossible to work around iconv() implementations which
do not properly set errno according to POSIX.  We therefore do no
longer allow to build against such iconv() implementations.

Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com>
2020-03-17 14:02:29 +01:00
Philipp Tanlak
1668ad7cb1 Add str_contains() function
RFC: https://wiki.php.net/rfc/str_contains

Closes GH-5179.
2020-03-16 11:05:26 +01:00
Nikita Popov
0fdffc1807 Update Unicode tables to 13.0.0 2020-03-12 11:29:51 +01:00
Nikita Popov
fff5771ccc Require non-absolute trait method refs to be unambiguous
Currently, when writing something like

class X {
    use T1, T2 {
       func as otherFunc;
    }
    function func() {}
}

where both T1::func() and T2::func() exist, we will simply assume
that func refers to T1::func(). This is surprising, and it doesn't
really make sense that this particular method gets picked.

This commit validates that non-absolute method references are
unambiguous, i.e. refer to exactly one method. If there is
ambiguity, it is required to write T1::func as otherFunc or
similar.

Closes GH-5232.
2020-03-10 16:01:13 +01:00
Remi Collet
ed998f8a0d Fix #50678 files extracted by ZipArchive class lost their original modified time 2020-03-09 07:09:50 +01:00
Remi Collet
125724cf58 [ci skip] fix for #72374 is no more a BC break 2020-03-06 10:29:16 +01:00
Remi Collet
e786e9c83c upgrade information about changs in Zip 2020-03-05 14:03:20 +01:00
Nikita Popov
336eb48c36 Automatically implement Stringable interface 2020-03-02 15:25:33 +01:00
Benjamin Eberlei
531ea6d340 Add upgrading note regarding merge of RFC for new DOMParentNode/DOMChildNode APIs. 2020-02-28 17:35:54 +01:00
Nicolas Oelgart
aa79a22d32 Add preg_last_error_msg() function
Provides the last PCRE error as a human-readable message, similar
to functionality existing in other extensions, such as
json_last_error_msg().

Closes GH-5185.
2020-02-25 10:26:03 +01:00
Nikita Popov
a939805641 Use serialize_precision for var_dump()
var_dump() is debugging functionality, so it should print
floating-point numbers accurately. We do this by switching
to serialize_precision, which (by default) will print with
as much precision as necessary to preserve the exact value
of the float.

This also affects debug_zval_dump().

Closes GH-5172.
2020-02-25 09:51:32 +01:00
Máté Kocsis
f031735489
Update UPGRADING
[skip ci]
2020-02-20 11:13:24 +01:00
Nikita Popov
3b08f53c97 Deprecate required param after optional
As an exception, we allow "Type $foo = null" to occur before a
required parameter, because this pattern was used as a replacement
for nullable types in PHP versions older than 7.1.

Closes GH-5067.
2020-02-18 14:35:58 +01:00
Christoph M. Becker
9ca449e0a8 Make quoting of cmd execution functions consistent
While the `$command` passed to `proc_open()` had to be wrapped in
double-quotes manually, that was implicitly done for all other
program execution functions.  This could easily introduce bugs and
even security issues when switching from one to another program
execution function.

Furthermore we ensure that the additional quotes are always
unwrapped regardless of what is passed as `$command` by passing
the `/s` flag to cmd.exe.  As it was, `shell_exec('path with
spaces/program.exe')` did execute program.exe, but adding an
argument (`shell_exec('path with spaces/program.exe -h)`) failed
to execute program.exe, because cmd.exe stripped the additional
quotes.

While these changes obviously can cause BC breaks, we feel that in
the long run the benefits of having consistent behavior for all
program execution functions outweighs the drawbacks of potentially
breaking some code now.
2020-02-17 23:17:17 +01:00
Nikita Popov
72bd55902d Improve generated names for anonymous classes
In order of preference, the generated name will be:

    new class extends ParentClass {};
    // -> ParentClass@anonymous
    new class implements FirstInterface, SecondInterface {};
    // -> FirstInterface@anonymous
    new class {};
    // -> class@anonymous

This is intended to display a more useful class name in error messages
and stack traces, and thus make debugging easier.

Closes GH-5153.
2020-02-17 12:21:33 +01:00
Nikita Popov
43443857b7 Add static return type
RFC: https://wiki.php.net/rfc/static_return_type

The "static" type is represented as MAY_BE_STATIC, rather than
a class type like "self" and "parent", as it has special
resolution semantics, and cannot be cached in the runtime cache.

Closes GH-5062.
2020-02-17 11:51:09 +01:00
Tyson Andre
d9b80efb57 [skip ci] Fix typos in UPGRADING
Closes GH-5183
2020-02-16 10:28:39 -05:00
Nikita Popov
ae2e4b5953 Add UPGRADING notes
Not listing the details here, I think the RFC is a better reference
for the precise technical details.

[ci skip]
2020-02-11 12:44:43 +01:00
Nikita Popov
d933591674 Add support for $obj::class
This allows $obj::class, which gives the same result as get_class($obj).
Anything other than an object results in TypeError.

RFC: https://wiki.php.net/rfc/class_name_literal_on_object

Closes GH-5065.
2020-02-11 12:16:30 +01:00
Dmitry Stogov
64b40f69dc Make ASSIGN, ASSIGN_OP, INC and DEC opcodes to return IS_TMP_VAR instead of IS_VAR.
This helps to avoid unnecessary IS_REFERENCE checks.
This changes some notices "Only variables should be passed by reference" to exception "Cannot pass parameter %d by reference".

Also, for consistency, compile-time fatal error "Only variables can be passed by reference" was converted to exception "Cannot pass parameter %d by reference"
2020-02-07 13:36:52 +03:00
Markus Staab
9f4d1b9936 Fix typo [ci skip] 2020-01-26 16:08:46 +01:00
George Peter Banyard
300d4df654 Add mention about empty needles for strrch() functions in UPGRADING [ci skip] 2020-01-25 12:34:42 +01:00
wbender
98bfad738a Fix bug #64865: Use CONTEXT_DOCUMENT_ROOT for scanning dir tree
If CONTEXT_DOCUMENT_ROOT is set use that rather than DOCUMENT_ROOT to
scan up the dir tree looking for .user.ini files.

Closes GH-5051.
2020-01-24 15:33:55 +01:00
Nikita Popov
e72bf63691 Allow variadic arguments to replace non-variadic ones
Any number of arguments can be replaced by a variadic one, so
long as the variadic argument is compatible (in the sense of
contravariance) with the subsumed arguments.

In particular this means that function(...$args) becomes a
near-universal signature: It is compatible with any function
signature that does not accept parameters by-reference.

This also fixes bug #70839, which describes a special case.

Closes GH-5059.
2020-01-23 15:23:31 +01:00
Máté Kocsis
4281c2a989
Add UPGRADING notes [skip ci] 2020-01-22 23:24:50 +01:00
Christoph M. Becker
7426e3b6a1 Bump required libcurl version to 7.29.0
libcurl 7.29.0 has been released almost eight years ago, so this
version is supposed to be available practically everywhere.  This bump
also allows us to get rid of quite some conditional code and tests
catering to very old libcurl versions.
2020-01-19 14:10:46 +01:00
Christoph M. Becker
f6fbe13717 Rename run-test.php to run-tests.php in the test packs
In the php-src repository, the test runner is named run-tests.php, but
when it is copied to the tests packs, it is renamed to run-test.php.
This renaming does not make sense, and is actually somewhat confusing.
Although changing the name back to run-tests.php constitutes a BC
break, we think the benefit of having a single name outweights the
disadvantages in the long run.
2020-01-14 18:31:25 +01:00
Christoph M. Becker
03bd4333f6 Add imagegetinterpolation()
While `imagesetinterpolation()` is available as of PHP 5.5.0,
there is no according getter function, so users would have to track the
current interpolation method manually.

To remedy this, we introduce `imagegetinterpolation()` as thin wrapper
for `gdImageGetInterpolationMethod()` (which has been introduced with
libgd 2.1.1), and use `im->interpolation_id` as fallback for older
libgd.  Since our bundled libgd does not yet have this function, we add
it.

We also simplify the recently introduced bug79068.phpt, where it is
sufficient to check that the interpolation method has not been changed.
2020-01-14 18:25:27 +01:00
Islam Israfilov
f553e676ec Fixed #78385: Distinguish absent/empty query/fragment
http://example.com/foo   => query = null, fragment = null
http://example.com/foo?  => query = "",   fragment = null
http://example.com/foo#  => query = null, fragment = ""
http://example.com/foo?# => query = "",   fragment = ""

Closes GH-5078.
2020-01-13 10:18:23 +01:00
George Peter Banyard
66659d6cf6 [ci skip] Update UPGRADING 2020-01-09 00:38:47 +01:00
mike
1658b5babc Adding DateTime(Immutable)::createFromInterface()
These are like

    DateTime::createFromImmutable()
    DateTimeImmutable::createFromMutable()

but accept any DateTimeInterface instead.

Closes GH-5016.
2020-01-03 16:55:12 +01:00
Nikita Popov
d8c9902567 Implement WeakMap
RFC: https://wiki.php.net/rfc/weak_maps
2020-01-03 10:43:24 +01:00
Wouter Wijsman
f13d0a72d5 Add FILTER_VALIDATE_BOOL as alias for FILTER_VALIDATE_BOOLEAN
Both filters are equivalent, but FILTER_VALIDATE_BOOL uses our
canonical name for the type (the only one permitted in type
declarations for example), so the new name is preferred long
term.

The old name may be deprecated in the future, but no specific
timeline is planned.
2019-12-30 14:18:03 +01:00
BohwaZ
3958592487 Add setAuthorizer method to SQLite3
This adds the possibility to define a userland callback that will be
used to authorize or not an action on the database.
2019-12-20 11:33:23 +01:00
Máté Kocsis
bc231f017b
Add upgrading note about implode() [ci skip] 2019-12-19 22:58:26 +01:00
George Peter Banyard
fdf45debdf Remove deprecated behaviour of passing encoding as third parameter in mb_strrpos()
Merged GH-5011
2019-12-13 22:03:27 +01:00
Máté Kocsis
73730eebca
Add upgrading notes about removed functionality that were deprecated in PHP 7.4 2019-12-05 13:15:55 +01:00
Christoph M. Becker
2de79f0855 Make the $num_points parameter of php_imagepolygon optional
That parameter is mostly useless in practise, and likely has been
directly ported from the underlying `gdImagePolygon()` and friends,
which require that parameter since the number of elements of the point
array would otherwise be unknown.  Typical usages of `imagepolygon()`,
`imageopenpolygon()` and `imagefilledpolygon()` pass `count($points)/2`
or hard-code this value as literal.  Since explicitly specifying this
parameter is annoying and error-prone, we offer the possibility to omit
it, in which case the `$points` array must have an even number of
elements, and the number of points is calculated as `count($points)/2`.
2019-11-15 09:41:10 +01:00
Nikita Popov
999e32b65a Implement union types
According to RFC: https://wiki.php.net/rfc/union_types_v2

The type representation now makes use of both the pointer payload
and the type mask at the same time. Additionall, zend_type_list is
introduced as a new kind of pointer payload, which is used to store
multiple class types. Each of the class types is a tagged pointer,
which may be either a class name or class entry. The latter is only
used for typed properties, while arguments/returns will instead use
cache slots. A type list can contain a mix of both names and CEs at
the same time, as not all classes may be resolvable.

One thing this is missing is support for union types in arginfo
and stubs, which I want to handle separately.

I've also dropped the special object code from the JIT implementation
for now -- I plan to add this back in a different form at a later time.
For now I did not want to include non-trivial JIT changes together
with large functional changes.

Another possible piece of follow-up work is to implement "iterable"
as an internal alias for "array|Traversable". I believe this will
eliminate quite a few special-cases that had to be implemented.

Closes GH-4838.
2019-11-08 15:15:48 +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
Nikita Popov
87fefd165a Remove ability to unbind $this of closures if used
This was deprecated in PHP 7.4, removing it for PHP 8.0.
2019-10-28 13:24:07 +01:00
Tyson Andre
9d48bf5152 Fix miscellaneous typos in docs and error messages
Closes GH-4863.
2019-10-28 11:44:08 +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
80103bdb78 Document the changes to substr functions 2019-10-23 11:22:12 +02:00
Nikita Popov
530a8a3854 Fix and undeprecate ReflectionType::__toString()
Add deprecated _ZendTestClass::__toString() method to preserve
an existing test.

ReflectionType::__toString() will now return a complete
representation of the type, as it should have originally. Users
that relied on nullability being absent should have been pushed
to ReflectionNamedType::getName() by the deprecation of
ReflectionType::__toString() in PHP 7.1 / PHP 7.4.
2019-10-22 11:26:02 +02:00
Nikita Popov
5c24f8042d Promote "Cannot use parent" to fatal error 2019-10-15 11:46:48 +02:00
Nikita Popov
e35bdb4912 Add fdiv() function
The fdiv() function is part of the fmod() / intdiv() family. It
implements a floating-point division with IEEE-754 semantics.
That is, division by zero is considered well-defined and does not
trigger any kind of diagnostic. Instead one of INF, -INF or NAN
will be returned, depending on the case.

This is in preparation for throwing DivisionByZeroError from the
standard division operator.
2019-10-11 16:36:11 +02:00
Nikita Popov
db233501ff Use clean shutdown on uncaught exception 2019-10-11 12:41:15 +02:00
Nikita Popov
d44cf9b539 Replace "unexpected character" warning with ParseError
Closes GH-4767.
2019-10-04 11:28:58 +02:00
tyage
4d6f88e215 Fix #72374: remove_path strips first char of filename 2019-10-02 15:33:28 +02:00
Nikita Popov
2f92957fd3 Convert some notices to warnings
Part of https://wiki.php.net/rfc/engine_warnings.
2019-10-02 10:34:08 +02:00
Mark
8aad466c42 Convert GD Resources to objects 2019-09-30 15:14:02 +02:00
Nikita Popov
38b19d47e0 Convert "Only arrays and Traversables can be unpacked" into Error 2019-09-27 15:50:34 +02:00
Nikita Popov
e8b0163e0b Promote write "use scalar as array" warning to Error 2019-09-27 15:49:18 +02:00
Nikita Popov
0ebf2bdba0 Convert "Illegal offset type" warnings to exceptions 2019-09-27 13:00:07 +02:00
Nikita Popov
f2b09969db Convert "cannot add element" warning to exception 2019-09-27 13:00:07 +02:00
Nikita Popov
a66c60cce3 Throw Error when writing property of non-object
This removes object auto-vivification support.

This also means that we can remove the corresponding special
handling for typed properites: We no longer need to check that a
property is convertible to stdClass if such a conversion might
take place indirectly due to a nested property write.

Additionally OBJ_W style operations now no longer modify the
object operand, and as such we no longer need to treat op1 as a
def in SSA form.

The next step would be to actually compile the whole LHS of OBJ_W
operations in R rather than W mode, but that causes issues with
SimpleXML, whose object handlers depend on the current compilation
structure.

Part of https://wiki.php.net/rfc/engine_warnings.
2019-09-27 10:11:47 +02:00
Christoph M. Becker
5356bad8c6 Remove unused parameter
The `$use_include_path` parameter doesn't make sense for
`tidy_repair_string()`, and actually unused, so we remove it.
2019-09-22 16:28:42 +02:00
Christoph M. Becker
48892e6d24 Remove unused parameter
Cf. <https://bugs.php.net/78579>.
2019-09-21 16:30:17 +02:00
Nikita Popov
cdd4e591a4 Don't make argument nullable based on AST null initializer
Closes GH-4720.
2019-09-19 11:27:00 +02:00
Christoph M. Becker
d61bc63c4d Change XMLWriter resources to objects
While we generally prefer objects over resources for quite a while, the
procedural XMLWriter API still uses resources, although there is
already an object-oriented API which uses objects.  This dichotomy
makes no sense, slightly complicates the implementation, and doesn't
allow a stepwise migration to the object-oriented API, which might be
desired.  Thus we completely drop the XMLWriter resources in favor of
XMLWriter objects.

We consider the minor BC break acceptable for a major version, since
only explicit type checks (`is_resource()`, `gettype()` etc.) need to
be adapted.
2019-09-18 08:52:14 +02:00
Benjamin Eberlei
873b54840f Upgrading notes for removed ext/dom classes. 2019-09-17 23:52:08 +02:00
Peter Cowburn
4253811c42 upgrading notes for ValueError/zend_value_error() 2019-09-10 13:19:24 +01:00
Nikita Popov
790ed7d540 Enable display_startup_errors by default 2019-09-06 14:33:03 +02:00
Nikita Popov
ea5854ca8c Make error_reporting=E_ALL the default 2019-09-02 10:03:26 +02:00
George Peter Banyard
6d578482a9 Improve strpos and strstr function family implementation 2019-08-26 17:11:37 +02:00
viest
48040cf345 Remove deprecated getaddrinfo flags
The AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES have
been deprecated by glibcs, and PHP 7.4 follows this deprecation.

This removes the offending flags for PHP 8.0.
2019-08-26 11:45:31 +02:00
Sjon Hortensius
05752d3acf Ref #77388: Don't pass BAD_ESCAPE_IS_LITERAL
This option is considered dangerous and unwanted. To allow for more
graceful migration don't error on now ignored X modifier.

Closes GH-4430.
2019-07-18 10:52:27 +02:00
Nikita Popov
0904dd3dc2 Remove INPUT_SESSION and INPUT_REQUEST
These were never supported and always generated a warning. Remove
them entirely for PHP 8.
2019-07-08 10:50:34 +02:00
Tyson Andre
435384127c Fix a typo in UPGRADING 2019-06-16 11:24:44 +02:00
Bob Weinand
af12aa8124 Merge branch 'concatenation_precedence' 2019-05-16 18:39:48 +02:00
Nikita Popov
fd2db11929 Always generate fatal error for LSP failures
RFC: https://wiki.php.net/rfc/lsp_errors
2019-05-07 13:45:28 +02:00
Kalle Sommer Nielsen
4218466111 Okay, too quick to merge, these are only relevant to 7.4 2019-05-01 23:48:05 +03:00
Kalle Sommer Nielsen
c71e35ea91 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove some more interbase leftovers
  Fix typo
  NEWS for ext/interbase unbundling
2019-05-01 23:45:24 +03:00
Kalle Sommer Nielsen
c8a20dfdca NEWS for ext/interbase unbundling 2019-05-01 23:35:30 +03:00