Commit Graph

978 Commits

Author SHA1 Message Date
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