1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00
Commit Graph

4015 Commits

Author SHA1 Message Date
George Peter Banyard c66fd72dbb Fix deprecated float to int tests
Missed those as they are not present on the 8.0 branch
2021-06-18 19:14:22 +01:00
George Peter Banyard 4939d2cec1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test
  Fix bug #81159: Object to int warning when using an object as a string offset
  Fix bug #81163 indirect vars in __sleep
2021-06-18 18:11:46 +01:00
George Peter Banyard f0fd5922ee Fix bug #81159: Object to int warning when using an object as a string offset
Closes GH-7167
2021-06-18 18:07:22 +01:00
Aaron Piotrowski 865fb353f5 Rename Fiber::this() to Fiber::getCurrent() (#7155) 2021-06-18 11:02:02 -05:00
George Peter Banyard acb78035b6 Add proper EXTENSIONS section for tests in Zend/ 2021-06-18 01:05:05 +01:00
Nikita Popov b64213872a Fix missing error for single index unset on wrong type
The error was correctly thrown for a nested index, but not for a
single index. Make sure both have the same behavior.
2021-06-15 14:41:11 +02:00
Aaron Piotrowski fdc22744a8 Add API to prevent Fiber switch in select contexts
Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2021-06-14 14:19:00 -05:00
Nikita Popov 1c08f8a48a Allow named args after unpack
Currently, argument unpacking and named arguments cannot be mixed
at all. This relaxes the restriction to allow
foo(...$args, named: $arg). The variant foo(named: $arg, ...$args)
is still forbidden, because we can't ensure that positional
parameters come before named parameters in that case (without more
intrusive changes). Effectively this just enforces a required style,
as the order of unpack and named args doesn't matter for the cases
where both could be well-defined.

ML discussion: https://externals.io/message/114589

Closes GH-7009.
2021-06-14 10:32:36 +02:00
Nikita Popov 71fb83567f Fix bug #80945: Don't throw undefined array key warning in ArrayObject unset()
This makes the behavior of ArrayObject the same as far plain
arrays, which don't throw a warning when unsetting a key that
already doesn't exit.
2021-06-14 10:14:38 +02:00
Nikita Popov 39131219e8 Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov 7485978339 Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Nikita Popov b58d74547f Rerun GC if destructors encountered
Since PHP 7.4 objects that have a destructor require two GC runs
to be collected. Currently the collection is delayed to the next
automatic GC run. However, in some cases this may result in a large
increase in memory usage, as in one of the cases of bug #79519.

See also bug #78933 and bug #81117 where the current behavior is
unexpected for users.

This patch will automatically rerun GC if destructors were encountered.
I think this should not have much cost, because it is very likely that
objects on which the destructor has been called really are garbage,
so the extra GC run should not be doing wasted work.

Closes GH-5581.
2021-06-09 14:53:14 +02:00
Aaron Piotrowski 2184422adc Merge fiber switching functions (#7106)
Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2021-06-08 08:23:56 -05:00
Nikita Popov 291d8db7c5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81104
2021-06-08 14:34:08 +02:00
Nikita Popov d29f15ce5f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81104
2021-06-08 14:33:29 +02:00
Nikita Popov d8165c2502 Fixed bug #81104
When the memory limit is restored during shutdown, we may still
be using a lot of memory. Ignore the failure at that point and
set it again after the MM is shut down, at which point memory
usage should be at its lowest point.
2021-06-08 14:31:55 +02:00
Joe Watkins 27ce269c1b Revert "Fix bug #24214 implement access to skip_last in user API for backtrace"
This reverts commit a5cef84de8.
2021-06-08 11:30:37 +02:00
Ayesh Karunaratne b8e380ab09 Update deprecation message for incompatible float to int conversion
Updates the deprecation message for implicit incompatible float to int conversion from:

```
Implicit conversion from non-compatible float %.*H to int in %s on line %d
```

to

```
Implicit conversion from float %.*H to int loses precision in %s on line %d
```

Related: #6661
2021-06-07 14:36:11 +02:00
Joe Watkins a5cef84de8 Fix bug #24214 implement access to skip_last in user API for backtrace 2021-06-06 08:37:32 +02:00
twosee e2e770c442 Fix undefined return value of fiber after bailout (#7103) 2021-06-05 07:20:47 -05:00
Christoph M. Becker d5dd9d59ae Speed up test case
This test case did 100,000 includes of a non existing file to show the
memory leak; this is not necessary, because after the first failing
include, memory is not supposed to increase for further includes.

Closes GH-7088.
2021-06-02 23:19:38 +02:00
Ayesh Karunaratne a706d7302a Improve interface non-public method error message
Currently interface methods with visibility `private` or `protected` fail
with an error message:

  Access type for interface method A::b() must be omitted

However, explicitly setting visibility `public` is allowed and often desired.
This commit updates the error message to:

  Access type for interface method A::b() must be public
2021-06-02 20:08:36 +01:00
Nikita Popov 96fe8141c3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip test without ZMM
2021-06-01 12:08:04 +02:00
Nikita Popov 59a52d6942 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Skip test without ZMM
2021-06-01 12:07:51 +02:00
Nikita Popov d4f493b0b0 Skip test without ZMM 2021-06-01 12:07:33 +02:00
George Peter Banyard b6958bb847 Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Peter van Dommelen 3a4ea6cb91 Don't automatically adjust memory_limit to 2M
As PHP has a minimum memory usage of 2M (size of allocator chunk),
setting a limit below that value is not meaningful and will be
automatically rounded up to the chunk size. Rather than doing this
silently, show the newly introduced error message.

The memory limit had to be increased to 2M for a number of tests.

tests/lang/bug45392 has been marked as XFAIL. This old bugfix is
not working as intended. The memory limit in main's `PG(memory_limit)`
differs from the one in zend_alloc. In zend_alloc the `AG(mm_heap)->limit`
is defined as `max(passed_value, ZEND_MM_CHUNK_SIZE)`. The check made in
an unclean shutdown will never be true unless the memory limit is lower
than ZEND_MM_CHUNK_SIZE, which happened to be the case in the test.
https://bugs.php.net/bug.php?id=45392
https://github.com/php/php-src/commit/fcc0fdd125fdb9e1713f91d027fe07d680a0cf36
2021-05-31 15:42:10 +02:00
Nikita Popov b4559e7ae4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81070
2021-05-31 15:24:29 +02:00
Nikita Popov 324ad2f42c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81070

This is a non-trivial merge. To avoid an ABI break, a new
zend_set_memory_limit_ex() function is added.
2021-05-31 15:24:00 +02:00
Peter van Dommelen 1b3b5c94e5 Fixed bug #81070
When the memory limit is reduced using an `ini_set("memory_limit", ..)`
below the currently allocated memory, the out-of-memory check overflowed.
Instead of implementing additional checks during allocation,
`zend_set_memory_limit()` now validates the new memory limit. When
below the current memory usage the ini_set call will fail and throw
a warning.

This is part of GH-7040.
2021-05-31 15:18:58 +02:00
Nikita Popov 477f4fe67b Skip pcntl_rfork() in arginfo test
Same as pcntl_fork(), we don't want to have this side-effect in
this mass-test.
2021-05-31 14:55:55 +02:00
Nikita Popov 27be6670b1 Correctly parse array_slice() argument in call_user_func_array() opt
We should be treating this argument using the normal zpp rules,
rather than performing a simple integer cast.
2021-05-31 10:38:25 +02:00
Nikita Popov ea256a218b Add %0 format to run-tests.php
This format matches against null bytes, and prevents the test
expectation from being interpreted as binary data.

bless_tests.php will automatically replace \0 with %0 as well.
2021-05-29 11:33:13 +02:00
Máté Kocsis 48981f4f1e Declare tentative return types for ext/standard (#7065) 2021-05-28 15:46:04 +02:00
Nikita Popov 100a1e8e21 Convert exception during inheritance to fatal error
Now that inheritance can throw deprecations again, these may be
converted to exception by a custom error handler. In this case
we need to convert the exception to a fatal error, as inheritance
cannot safely throw in the general case.
2021-05-28 10:19:23 +02:00
Máté Kocsis 5beba0b038 Declare tentative return types for ext/json (#7051) 2021-05-27 10:47:15 +02:00
Joe Watkins 531413f809 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info
2021-05-25 11:27:20 +02:00
Joe Watkins 213063f6ca Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info 2021-05-25 11:26:38 +02:00
Joe Watkins 6408ebb731 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77627 method_exists on Closure::__invoke
2021-05-25 11:23:08 +02:00
Joe Watkins cfd4d3df0b Fix #77627 method_exists on Closure::__invoke 2021-05-25 11:22:05 +02:00
Nikita Popov b849aa6494 Merge branch 'PHP-8.0'
* PHP-8.0:
  Pass flags to #[Attribute] on internal attributes
2021-05-21 11:42:11 +02:00
Nikita Popov db6e60e744 Pass flags to #[Attribute] on internal attributes
While the specified restriction was checked, the #[Attribute]
attribute did not specify the flags parameter, so that Reflection
returned incorrect information.

In particular, Attribute itself has a CLASS target, not an ALL
target.
2021-05-21 11:40:23 +02:00
Nikita Popov 0123c99595 Fix bug55509.phpt skipif on FreeBSD 2021-05-18 19:35:03 +02:00
Nikita Popov c939bd2f10 Handle explicitly nullable types in optional-before-required deprecation
The exception for null default values here exists to keep compatibility
with PHP < 7.1 where "Foo $bar = null" was the canonical way to create
a nullable parameter. If the parameter is actually "?Foo $bar = null",
then clearly compatibility with PHP < 7.1 is not a concern, and we
can throw a deprecation notice.
2021-05-18 14:00:25 +02:00
Nikita Popov afc4d67c8b Consistently treat optional-before-required as required
There was a loophole here when it came to usage with named arguments,
which was not intended. Close the loophole thoroughly by actually
dropping the default value from the signature entirely. The default
is still used to make the type nullable, but not for anything else.
2021-05-18 12:40:58 +02:00
Nikita Popov de6e401e05 Use common formatting for backtraces (#6977)
This makes debug_print_backtrace() use the same formatting as exception
backtraces. The only difference is that the final #{main} is omitted,
because it wouldn't make sense for limited backtraces, and wasn't there
previously either.
2021-05-18 11:43:37 +02:00
George Peter Banyard c4d69c2e60 Fix test expectation now that -a doesn't work without readline
Follow-up upon 959e5787bd
2021-05-15 02:39:35 +01:00
Máté Kocsis 532c60cb92 Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
Nikita Popov 008bfcc7ba Use NO_DYNAMIC_PROPERTIES for Closure
Instead of manually implementing this, use the standard mechanism.
This has minor behavior changes (e.g. doing an isset() will now
return false instead of throwing) which are more in line with
typical behavior.
2021-05-14 14:48:56 +02:00
Nikita Popov 4fe07d474c Add test for restoring error_reporting on fatal error during silencing
This guard against the issue that GH-6904 would introduce when
run under --repeat 2 mode.
2021-05-11 12:16:59 +02:00