Commit Graph

16108 Commits

Author SHA1 Message Date
Nikita Popov
9395e01e3d Check variadic parameter for type and duplicate name
Set HAS_TYPE_HINTS flag if the variadic parameter is types as well,
and make sure it has a distinct name. This was previously missed,
because the variadic parameter is not part of num_args.
2020-08-24 10:15:57 +02:00
Dmitry Stogov
5c18ee58b9 Fixed use-after-free introduced by aed1f78515 2020-08-24 09:50:54 +03:00
Christoph M. Becker
13419befff Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix wrong datatype
2020-08-21 15:30:07 +02:00
Christoph M. Becker
8f9f308bb9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix wrong datatype
2020-08-21 15:28:37 +02:00
Manuel Mausz
46d62e5464 Fix wrong datatype
ini_entry->modifiable is of type uint8_t and so should be the temp. variable. Especially important after 4b77a158.

Closes GH-6028
2020-08-21 15:28:12 +02:00
Dmitry Stogov
aed1f78515 micro-optimization 2020-08-20 15:02:12 +03:00
Christoph M. Becker
ff14b7adad 7.3.23 is next 2020-08-18 09:55:37 +02:00
Nikita Popov
befe10fd21 Fix bug #78770
Refactor the zend_is_callable implementation to check callability
at a particular frame (this is an implementation detail for now,
but could be exposed in the API if useful). Pick the first parent
user frame as the one to check.
2020-08-14 10:24:06 +02:00
Nikita Popov
b03e300a29 Fix test after PDOStatement::fetchObject() change 2020-08-13 16:45:32 +02:00
Nikita Popov
670036e2a9 Use Z_PARAM_CLASS in PDOStatement::fetchObject()
Instead of implementing custom logic.
2020-08-13 16:20:29 +02:00
Tyson Andre
1e9a5c67ef Rename standard array function parameters to $array
This is targeting 8.0.

`$arg` seems like a poor choice of a name,
especially if the function were to have arguments added.

In many cases, the php.net documentation already has $array for these functions.
E.g. https://www.php.net/manual/en/function.array-intersect.php

I'd assume that since named arguments was added to 8.0 near the feature freeze,
PHP's maintainers had planned to make the names consistent
and gradually use the same name for  docs and implementation.
2020-08-11 19:11:59 -04:00
Ilija Tovilo
10f660f0a5
Fix ?-> in encaps vars without braces
Closes GH-5966.
2020-08-11 21:16:44 +02:00
Nikita Popov
e25aab6426 Fixed bug #79927
We need to unset the AT_FIRST_YIELD flag when yielding from an
array as well.

In the interest of being conservative, I'm applying this only to
PHP 8.
2020-08-11 15:48:40 +02:00
Nikita Popov
227f1f1481 Fix nullsafe operator on $this 2020-08-11 15:22:14 +02:00
Nikita Popov
42eda5160d SAVE_OPLINE in NULL_HANDLER
Let's avoid crashing before the nice error message gets printed...
2020-08-11 15:14:50 +02:00
Nikita Popov
f491dabe40 Fix nullsafe operator on reference
Dereference the value before checking the type. As the happy path
necessarily has to check for references, I'm not bothering to
delay the comparison.
2020-08-11 15:11:36 +02:00
Nikita Popov
c439f1fa6a Fixed bug #62294
The primary issue was already resolved in 7c3e487289,
but the particular example used in this bug report ran into an
additional issue on PHP 8, because I forgot to drop a number of
zend_bailout calls when switch require failure to throw.
2020-08-10 12:54:02 +02:00
Nikita Popov
ee16316148 Fixed bug #79948
Make sure we don't execute further scripts if one of them encountered
an exit exception.

Also make sure that we free file handles that end up unused due to
an early abort in php_execute_scripts(), which turned up as an
issue in the added test case.

Finally, make use of EG(exit_status) in the places where we
zend_eval_string_ex, instead of unconditionally assigning exit
code 254. If an error occurs, the error handler will already set
exit status 255.
2020-08-10 11:15:16 +02:00
Nikita Popov
896dad4c79 Fixed bug #77561
Unconditionally strip shebang lines when using the CLI SAPI,
independently of whether they occur in the primary or non-primary
script. It's unlikely that someone intentionally wants to print
that shebang line when including a script, and this regularly
causes issues when scripts are used in multiple contexts, e.g.
for direct invocation and as a phar bootstrap.
2020-08-10 10:38:33 +02:00
Nikita Popov
74c4381806 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79947
2020-08-10 10:13:34 +02:00
Nikita Popov
2d087210eb Fixed bug #79947
Move the FREE_OP for op_data out of the zend_binary_assign_op_dim_slow()
slow path, so it can be used by the other error path as well. This
makes ASSIGN_DIM_OP structurally more similar to ASSIGN_DIM.
2020-08-10 10:11:56 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00
Nikita Popov
01cbb5967c Accept zend_object* in zend_unset_property 2020-08-07 16:40:27 +02:00
Nikita Popov
978b7de244 Accept zend_object* in zend_get_exception_base 2020-08-07 16:40:27 +02:00
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00
Máté Kocsis
af80d8a14e
Add more argument types to stubs
Closes GH-5943
2020-08-07 12:35:30 +02:00
Nikita Popov
fcff418411 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79934: CRLF-only line in heredoc causes parsing error
2020-08-06 12:04:23 +02:00
Nikita Popov
2cbc94097e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79934: CRLF-only line in heredoc causes parsing error
2020-08-06 12:03:57 +02:00
Pieter van den Ham
06ade15528 Fix #79934: CRLF-only line in heredoc causes parsing error
Fixes the function `next_newline()` in zend_language_scanner.l. The
function now correctly returns a newline_len of 2 for "\r\n".

Closes GH-5944.
2020-08-06 12:02:54 +02:00
Gabriel Caruso
7479ab9f80 Update API version numbers
In preparation for PHP 8.0.
2020-08-04 22:25:28 +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
Gabriel Caruso
1ab4d0e6b7
Update API version numbers
In preparation for PHP 8.0.
2020-08-04 18:07:16 +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
dc1107ba5b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Removed space from bug55086.phpt
2020-08-03 15:14:36 +02:00
Graham Campbell
f3a43e85e7 Removed space from bug55086.phpt
Closes GH-5923.
2020-08-03 15:14:15 +02: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
Nikita Popov
bb8b95be63 Fix bug #79925
If the expected return type of a magic method is "object", we also
need to allow class types and "static" to comply with covariance.
2020-08-03 10:35:26 +02:00
Nikita Popov
5d4659c25c Enforce __set_state() parameter type
This fixes one of the issues reported in bug #79925. The parameter
type check for this particular method was missed.
2020-08-03 10:23:06 +02:00
Nikita Popov
a4c015b4b2 Fix handling of nullsafe method in empty()
Fixes oss-fuzz #24627.
2020-08-03 10:16:38 +02:00
tangl163
7d4ae7fa23 Drop the unneeded pointer casting
The standard says that "A pointer to void may be converted to or from a
pointer to any object type". So the casting is unneeded.

REF:
    * c11: http://port70.net/~nsz/c/c11/n1570.html#6.3.2.3p1
    * c99: http://port70.net/~nsz/c/c99/n1256.html

Closes GH-5916
2020-08-03 02:05:14 +01: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
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
Nikita Popov
a6e63b42c3 Make check in RECV_VARIADIC more precise
Fetch arg_info only once (it's always the same one...) and check
ZEND_TYPE_IS_SET on it, rather than checking if *any* parameter
has a type.
2020-07-31 12:02:28 +02:00
Christoph M. Becker
8c4f7d668e Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79919: Stack use-after-scope in define()
2020-07-31 10:59:17 +02:00
Christoph M. Becker
fce8061ede Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79919: Stack use-after-scope in define()
2020-07-31 10:57:02 +02:00
Christoph M. Becker
1e0bc6e30f Fix #79919: Stack use-after-scope in define()
Instead of the temporary `rv`, we use the `val_free` which is there for
this purpose.
2020-07-31 10:54:41 +02:00
Máté Kocsis
0d330e1a02
Add a few missing parameter types in stubs
Related to GH-5627
2020-07-30 14:26:45 +02:00
Deus Kane
f475edc2f1 Fixed bug #79897: Promoted constructor params with attribs cause crash
This was caused by the attribute AST being used twice, and was fixed by
creating a temporary copy of it (and destroying said copy) when neccesary.
2020-07-30 11:08:31 +02:00
Nikita Popov
ee7eecf321 Fix leak with nullsafe operator with constant LHS
Followup to 5303bcdd32. We need to
perform the addref after emitting the opline, because that might
intern the string.

Fixes oss-fuzz #24479.
2020-07-29 15:51:47 +02:00
Nikita Popov
c206c742d6 Fix bug #79900
Run debug build shutdown GC regardless even if GC has been disabled.
Of course, this only does something meaningful if the GC has been
disabled at runtime and root collection is still enabled. We cannot
prevent leaks if GC is disabled completely.
2020-07-29 15:27:48 +02:00
Nikita Popov
993be4b9bf Fix STR_OR_OBJ_OF_TYPE stringable handling 2020-07-29 11:29:49 +02: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
Andrea Faulds
f759936591 Permit trailing whitespace in numeric strings
This is part 1 of the 'Saner Numeric Strings' RFC:
https://wiki.php.net/rfc/saner-numeric-strings
2020-07-29 02:22:38 +01:00
Nikita Popov
c434bbb344 Fix typo in test 2020-07-28 15:39:22 +02: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
Christoph M. Becker
44ad2db15f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79806: realpath() erroneously resolves link to link
2020-07-28 14:02:25 +02:00
Christoph M. Becker
e0ebe56ebf Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79806: realpath() erroneously resolves link to link
2020-07-28 14:00:52 +02:00
Christoph M. Becker
c756f82c02 Fix #79806: realpath() erroneously resolves link to link
After resolving reparse points, the path still may be a reparse point;
in that case we have to resolve that reparse point as well.
2020-07-28 13:55:22 +02:00
Nikita Popov
5303bcdd32 Fix use-after-free when nullsafe used with constant LHS
Fixes oss-fuzz #24436.
2020-07-28 09:48:13 +02:00
Christoph M. Becker
592f70bc46 Merge branch 'PHP-7.4'
* PHP-7.4:
  Revert "Fix #79806: realpath() erroneously resolves link to link"
2020-07-27 17:53:23 +02:00
Christoph M. Becker
f02507469d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Revert "Fix #79806: realpath() erroneously resolves link to link"
2020-07-27 17:51:56 +02:00
Christoph M. Becker
1aeff522b8 Revert "Fix #79806: realpath() erroneously resolves link to link"
This reverts commit d5b59b4303.
2020-07-27 17:50:41 +02:00
Christoph M. Becker
54e15dcd6f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79806: realpath() erroneously resolves link to link
2020-07-27 15:11:39 +02:00
Christoph M. Becker
85a26fef11 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79806: realpath() erroneously resolves link to link
2020-07-27 15:10:22 +02:00
Christoph M. Becker
d5b59b4303 Fix #79806: realpath() erroneously resolves link to link
After resolving reparse points, the path still may be a reparse point;
in that case we have to resolve that reparse point as well.
2020-07-27 15:08:39 +02:00
Nikita Popov
6d97e7f0e9 JIT internal functions with return type in debug mode
The return type check is just a debug assertion, it's okay if it
is not performed in JIT mode. We already don't perform all the
argument validation in that case. Just disable the one test that
checks for this.

This removes an annoying discrepancy between debug&release mode.
2020-07-27 15:02:59 +02:00
Nikita Popov
08e6c20955 Fix null pointer deref in compile_return()
Fixes oss-fuzz #24387.
2020-07-27 10:27:26 +02:00
Nikita Popov
3b5b288127 Add AST export support for nullsafe operator
Fixes oss-fuzz #24403 and variants.
2020-07-27 10:20:02 +02:00
Derick Rethans
f66627abff Another pass of improving ext/date argument names 2020-07-26 10:38:53 +01:00
Tyson Andre
07db64156e [RFC] Make string length for getTraceAsString() configurable
Add a `zend.exception_string_param_max_len` ini setting.
(same suffix as `log_errors_max_len`)

Allow values between 0 and 1000000 bytes.
For example, with zend.exception_string_param_max_len=0,
"" would represent the empty string, and "..." would represent something
longer than the empty string.
Previously, this was hardcoded as exactly 15 bytes.

Discussion: https://externals.io/message/110717

Closes GH-5769
2020-07-25 09:50:57 -04:00
Máté Kocsis
8664ff7ae1
Cleanup argument handling in ext/reflection
Closes GH-5850
2020-07-24 17:47:42 +02:00
Nikita Popov
1f8a93abaa Support class+mask union for internal argument 2020-07-24 16:40:14 +02:00
Derick Rethans
e96e4ac726 More consistent parameter names for date/time functions 2020-07-24 11:49:01 +01: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
Máté Kocsis
70a3a909cd
Add the Z_PARAM_PATH_OR_NULL() and Z_PARAM_ZVAL_OR_NULL() macros 2020-07-24 10:37:35 +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
Christoph M. Becker
1e938e8eba Fix build
MSVC is pretty picky there, so we add the `ZEND_VOIDP` cast.
2020-07-22 22:57:58 +02:00
Christoph M. Becker
f1436c4832 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix minor memory leak of CG(script_encoding_list)
2020-07-22 20:34:21 +02:00
Christoph M. Becker
c1a80e075a Fix minor memory leak of CG(script_encoding_list)
This only leaks at the end of the process, so per se not an issue, but
the leak is caught by MSVC's CRT leak checker, so we better properly
clean up to avoid false positives.
2020-07-22 20:32:48 +02:00
twosee
6e92487f66 Fix warnings of strict-prototypes
Closes GH-5887.
2020-07-23 00:59:00 +08:00
twosee
a65ec4c2db Change type of max_num_args to uint32_t
Closes GH-5885.
2020-07-23 00:55:58 +08:00
twosee
e29ee65ec0 Export zend_register_error_notify_callback() with ZEND_API 2020-07-23 00:45:06 +08: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
Tyson Andre
4cf8b6f1c9 Support optional comma in closure use list
RFC: https://wiki.php.net/rfc/trailing_comma_in_closure_use_list
Discussion: https://externals.io/message/110715

The release manager has agreed to allow merging of RFCs that have near-unanimous
votes. If an RFC ends up not achieving the required 2/3 majority at the time the
announced voting period closes, this implementation commit will be reverted
in time for the feature freeze.

Closes GH-5793
2020-07-21 13:01:27 -04:00
Nikita Popov
e079e753dc Give zend_pass_function an arginfo
Now that the ZEND_ACC_VARIADIC flag is set, we should also make
sure there is a variadic arg that can be looked up.
2020-07-21 16:01:45 +02:00
Máté Kocsis
5770b66722
Cleanup argument handling of Zend functions and methods
Closes GH-5847
2020-07-21 14:47:03 +02:00
Nikita Popov
c9881fde7a Run arginfo / zpp mismatch tests for methods as well
As a side-effect, this also catches issues where classes are not
prepared for use with newInstanceWithoutConstructor.
2020-07-21 14:17:29 +02:00
Nikita Popov
38fb1f8383 Check for missing arginfo arguments
Internal functions error when too many arguments are passed. Make
this part of the verification we do in debug builds. This will
help avoid cases where an argument is missing in the stubs,
as recently encountered in 6d96f0f.
2020-07-21 14:17:29 +02:00
Christoph M. Becker
2c0a6977dd 7.3 is now 7.3.22-dev 2020-07-21 09:18:07 +02:00
Nikita Popov
236ddc56a2 Preserve original ce_flags when registering class
Bug that regularly sneaks in: ZEND_ACC_FINAL is set before calling
zend_register_internal_class() and promptly gets ignored. Remove
this footgun by preserving flags from the original CE.
2020-07-20 17:00:04 +02:00
Nikita Popov
7fd4212cc0 Add common code for magic method assignment
This was repeated three times.
2020-07-20 14:57:10 +02:00
Nikita Popov
efce3694b7 Directly assign magic methods
Instead of going through intermediary variables.
2020-07-20 11:22:47 +02:00
Nikita Popov
91e5452b95 Remove unused lc_class_name variable
This is probably a leftover from "old style constructor" support.
2020-07-20 11:15:58 +02:00
Nikita Popov
19de727e04 Report magic method names as written
Report the name the way the user has written it, the same way we
always do.
2020-07-20 11:12:47 +02:00
Nikita Popov
149029b9d6 Unify magic method visibility check
This was missing entirely for the internal function case.
2020-07-20 11:12:47 +02:00
Nikita Popov
312fe2bdce Unify magic method return type checks 2020-07-20 10:51:48 +02:00
Nikita Popov
fbbcf82ab7 Unify static/non-static check for magic methods
And promote it to be fatal.
2020-07-20 10:39:43 +02:00
Nikita Popov
b466e8b754 Add missing arg num check for __set_state 2020-07-20 10:20:29 +02:00
Nikita Popov
dcaf62f3d3 Clean up zend_check_magic_method_implementation
Let everything go through a common function, which fixes some
consistency issues.
2020-07-20 10:17:40 +02:00
Nikita Popov
f9ced0d4f7 Add missing zpp_none call in Exception::__wakeup 2020-07-17 16:06:54 +02:00
George Peter Banyard
fa60f57be4 Drop unused param in zend_parse_arg_class_name_or_obj() 2020-07-17 17:00:27 +02:00
Nikita Popov
86a62eb1fc Fixed bug #79867
In line with usual rules, give untyped properties a null default
value. Otherwise constructor promotion would give you a property
declaration that cannot be achieved through any other means.
2020-07-17 15:10:45 +02:00
Benjamin Eberlei
6c8b94eb42 Introduce error notification callbacks that are run independant of zend_error_cb 2020-07-17 15:08:11 +02:00
Nikita Popov
6d96f0f9ce Fix WeakReference::create() stub 2020-07-16 20:46:45 +02:00
Pedro Magalhães
272b887b7b Ignore inheritance rules on private methods
Closes GH-5401
2020-07-15 17:09:57 +01:00
Nikita Popov
5785a15f4e Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79862
2020-07-15 15:00:45 +02:00
Nikita Popov
e8430b592f Fixed bug #79862
While normally a private property in the active scope would take
priority, we should not use this if it has the wrong "staticness".
2020-07-15 14:59:55 +02:00
Nikita Popov
f60cf0cfe7 Remove type argument from zend_get_zval_ptr
As pointed out by Levi, this is unused, and we already changed
the signature of this function for PHP 8.
2020-07-15 09:51:51 +02:00
Nikita Popov
70501b81a7 Fixed bug #79852 2020-07-14 12:31:06 +02:00
George Peter Banyard
4f3eccfd4d Use consistent types
uint32_t type for argument count
size_t for length of char*
zend_bool for a zval bool arg

Closes GH-5845
2020-07-13 13:30:54 +02:00
Rowan Tommins
55a15f32ce Improve output of tokens in Parse Errors
Currently, unexpected tokens in the parser are shown as the text
found, plus the internal token name, including the notorious
"unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)".

This commit replaces that with a more user-friendly format, with
two main types of token:

* Tokens which always represent the same text are shown like
  'unexpected token "::"' and 'expected "::"'
* Tokens which have variable text are given a user-friendly
  name, and show like 'unexpected identifier "foo"', and
  'expected identifer'.

A few tokens have special cases:

* unexpected token """ -> unexpected double-quote mark
* unexpected quoted string "'foo'" -> unexpected single-quoted
  string "foo"
* unexpected quoted string ""foo"" -> unexpected double-quoted
  string "foo"
* unexpected illegal character "_" -> unexpected character 0xNN
  (where _ is almost certainly a control character, and NN is the
   hexadecimal value of the byte)

The \ token has a special case in the implementation just to stop
bison making a mess of escaping it and it coming out as \\
2020-07-13 11:07:40 +02:00
Nikita Popov
213852de78 Fixed bug #79828 2020-07-13 09:55:13 +02:00
Ilija Tovilo
1c967df5a0
Fix free of uninitialized memory in MATCH_ERROR
As suggested by Tyson Andre:
https://github.com/php/php-src/pull/5371#issuecomment-657081464

Also fix line number of unhandled match error

Closes GH-5841.
2020-07-12 13:33:36 +02:00
Ilija Tovilo
d5a0370828
[skip ci] Consistent match test closing tags 2020-07-11 16:50:51 +02:00
Máté Kocsis
95cff3ebf2
Retain the original formatting character in test 2020-07-10 23:15:08 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
George Peter Banyard
2297a6d364 Use dedicated function for illegal offset type error 2020-07-10 16:49:52 +02:00
Nikita Popov
5fc70243d7 Add missing addref for MATCH_ERROR operand 2020-07-10 15:58:42 +02:00
Nikita Popov
6556846754 Fixed bug #79818
Only destroy the variable directly before reassigning it. The
value could be read in the meantime.
2020-07-10 14:36:50 +02:00
twosee
b284ba3943 Add zend_wrong_parameter_error to reduce the size of ZPP macro
Closes GH-5831.
2020-07-10 10:12:23 +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
George Peter Banyard
9839752a9c Voidify some ZEND_API functions
Closes GH-5805
2020-07-09 14:15:57 +02:00
Nikita Popov
613a56d1cb Remove FREE_UNFETCHED concept
In master normal FREE_OPs work like FREE_UNFETCHED_OP used to, so
there is no point in keeping this distinction anymore, it's just
confusing.
2020-07-09 11:58:33 +02:00
Nikita Popov
c05bfa362b Merge branch 'PHP-7.4'
* PHP-7.4:
  Switch back to FREE_UNFETCHED_OP_DATA
2020-07-09 11:54:44 +02:00
Nikita Popov
8318379dd3 Switch back to FREE_UNFETCHED_OP_DATA
Some of the code paths leading to this do not fetch op data.
Hopefully this fixes the release build failure.
2020-07-09 11:54:08 +02:00
Nikita Popov
04b17217b4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #79599 in a different way
  Revert "Fixed bug #97599 (coredump in set_error_handler)"
2020-07-09 11:18:03 +02:00
Nikita Popov
5795dfda93 Fix bug #79599 in a different way
Move the emission of the undefined variable notice before the
array separation.
2020-07-09 11:12:44 +02:00
Nikita Popov
a3cb612243 Revert "Fixed bug #97599 (coredump in set_error_handler)"
This reverts commit ccd41e0833.

This causes a large performance regression when notices are thrown
and large arrays are in scope, see bug #79794.
2020-07-09 11:12:44 +02:00
Derick Rethans
fc7650944a Merge branch 'PHP-7.4' 2020-07-09 09:51:15 +01:00
Derick Rethans
972383fda4 Revert "Partial fixed bug #79649 (Altering disable_functions from module init corrupts memory)"
This reverts commit a297c09da5.
2020-07-09 09:50:25 +01:00
George Peter Banyard
7ac9e9bf64 Use ZPP callable check in zend built in functions 2020-07-08 19:38:46 +02:00
Nikita Popov
2af1d36bc5 Skip special function optimization for redeclared disabled functions
As pointed out on GH-5817.
2020-07-08 10:11:00 +02:00
Nikita Popov
e45f7053cf Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79793
2020-07-07 16:33:06 +02:00
Nikita Popov
77acc8a069 Fixed bug #79793
Make sure the string key is not released while throwing the
undefined index warning.
2020-07-07 16:29:48 +02:00
Nikita Popov
beb002a867 Fixed bug #79791
First throw the undefined variable warning, and then set the
variable to null. Otherwise we're not guaranteed that it's
actually null afterwards.
2020-07-07 16:00:50 +02:00
Nikita Popov
cdc4ea2a5c JIT support for undefined index/offset handling 2020-07-07 15:13:03 +02:00
Nikita Popov
f497b69944 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79784
2020-07-07 14:24:39 +02:00
Nikita Popov
62bec0e083 Fixed bug #79784
The fix here is essentially the same as for bug #78598, just for
the undefined variable notice, rather than the undefined index one.
2020-07-07 14:22:58 +02:00
Nikita Popov
2c73bf7e3f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78598
2020-07-07 12:28:35 +02:00
Nikita Popov
220880ad2d Fixed bug #78598
When performing an RW modification of an array offset, the undefined
offset warning may call an error handler / OB callback, which may
destroy the array we're supposed to change. Detect this by temporarily
incrementing the reference count. If we find that the array has been
modified/destroyed in the meantime, we do nothing -- the execution
model here would be that the modification has happened on the destroyed
version of the array.
2020-07-07 12:13:58 +02:00
Nikita Popov
ecf368b8f2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79792
2020-07-07 12:00:34 +02:00
Nikita Popov
48a247178e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79792
2020-07-07 11:59:40 +02:00
Nikita Popov
64931fd3c4 Fixed bug #79792
We need to remove the iterators even if the array is empty (we
will not create one if the first place, but the array may become
empty after the fact).
2020-07-07 11:58:25 +02:00
Nikita Popov
b48bd671b8 Assert no exception if using NEXT_OPCODE()
When NEXT_OPCODE() is used instead of NEXT_OPCODE_CHECK_EXCEPTION(),
assert that there is indeed no exception.
2020-07-07 11:34:43 +02:00
Nikita Popov
5d0687e895 Assert exception set in HANDLE_EXCEPTION()
Some code paths were checking this manually, but we can turn this
into a general assertion to avoid surprises (functions returning
failure without throwing).
2020-07-07 11:31:05 +02:00