Commit Graph

417 Commits

Author SHA1 Message Date
Dmitry Stogov
86b93bc479
Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484) 2024-06-05 23:53:31 +03:00
Dmitry Stogov
7a9e0fb39b
Fix incorrect inheritance of private trait methods (#14163)
The bug was introduced in c6b75f9328
2024-05-07 13:16:23 +03:00
Dmitry Stogov
c6b75f9328
Fix prototype for trait methods (#14148)
* Fix prototype for trait methods

Fixes GH-14009

* Clenup do_inheritance_check_on_method()

Remove wierd checks and define the behavior by explicit set of flags

* Fix naming and indentation

---------

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2024-05-06 21:39:30 +03:00
Bob Weinand
10d912d6e3
Fix GH-13712: Segmentation fault for enabled observers when calling trait method of internal trait when opcache is loaded (#13735)
Inherited methods regardless of source must share the original runtime cache. Traits were missed.
This adds ZEND_ACC_TRAIT_CLONE to internal functions as well to allow easy distinction of these.
2024-03-18 19:02:42 +01:00
George Peter Banyard
02a80c5b82 Fix various bugs related to DNF types
- GH-11958: DNF types in trait properties do not get bound properly
 - GH-11883: Memory leak in zend_type_release() for non-arena allocated DNF types
 - Internal trait bound to userland class would not be arena allocated
 - Property DNF types were not properly deep copied during lazy loading

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: ju1ius <jules.bernable@gmail.com>
2023-08-15 15:34:33 +01:00
Dmitry Stogov
f763cfd3d5 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix memory leak
2022-12-19 12:11:55 +03:00
Dmitry Stogov
683285165e Fix memory leak
Fixes oss-fuzz #54320
2022-12-19 12:11:16 +03:00
Bob Weinand
b30448f48f Fix observing inherited internal functions
Fixes GH-9871
2022-11-02 15:33:04 +01:00
Bob Weinand
a01dd9feda Revert "Port all internally used classes to use default_object_handlers"
This reverts commit 94ee4f9834.

The commit was a bit too late to be included in PHP 8.2 RC1. Given it's a massive ABI break, we decide to postpone the change to PHP 8.3.
2022-09-14 11:13:23 +02:00
Bob Weinand
94ee4f9834 Port all internally used classes to use default_object_handlers
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
Bob Weinand
bf427b732a Add an API to observe functions and classes being linked
To observe when the functions and classes start being officially available to the user

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-23 15:22:22 +02:00
Máté Kocsis
0897266219
Fix GH-9285 Traits cannot be used in readonly classes 2022-08-21 10:33:08 +02:00
sji
3b62d66098
Implement constants in traits (#8888)
RFC: https://wiki.php.net/rfc/constants_in_traits
2022-08-04 20:08:40 +01:00
George Peter Banyard
f905590764
Add support for Disjoint Normal Form (DNF) types (#8725)
RFC: https://wiki.php.net/rfc/dnf_types

This allows to combine union and intersection types together in the following form (A&B)|(X&Y)|T but not of the form (X|A)&(Y|B) or (X|A)&(Y|B)|T.

* Improve union type parsing

Co-authored-by: Sara Golemon <pollita@php.net>
2022-07-08 11:30:23 +01:00
George Peter Banyard
b40ae80804
Convert iterable into an internal alias for Traversable|array (#7309)
This does a compile time transformation of ``iterable`` into ``Traversable|array`` which simplifies some of the LSP variance handling.

The arginfo generation script from stubs is updated to produce a union type when it encounters the type ``iterable``
Extension functions which do not regenerate the arginfo, or write them manually are still supported by mimicking the compile time transformation while registering the function.

Type Reflection is preserved for single ``iterable`` (and ``?iterable``) to produce a ReflectionNamedType with name ``iterable``, however usage of ``iterable`` in union types will be converted to ``array|Traversable``
2022-06-07 13:35:34 +01:00
Máté Kocsis
7850c10389
Add support for readonly classes (#7305)
RFC: https://wiki.php.net/rfc/readonly_classes
2022-05-16 20:40:23 +02:00
Dmitry Stogov
f080a90a88 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak
2022-05-11 11:47:38 +03:00
Dmitry Stogov
b1b79c74fb Fix memory leak
This fixes oss-fuzz #47088
2022-05-11 11:43:01 +03:00
Jakub Zelenka
436cffc971
Merge branch 'PHP-8.1' 2022-04-22 23:08:23 +01:00
Arnaud Le Blanc
f20e11cbe1 Clear recorded errors before executing shutdown functions
Recorded errors may be attached to the wrong cached script when a fatal error
occurs during recording. This happens because the fatal error will cause a
bailout, which may prevent the recorded errors from being freed. If an other
script is compiled after bailout, or if a class is linked after bailout, the
recorded errors will be attached to it.

This change fixes this by freeing recorded errors before executing shutdown
functions.

Fixes GH-8063
2022-04-22 18:14:08 +02:00
Ilija Tovilo
733023b2e3
Improve error message class type
Refer to interfaces/enums instead of classes in more places.

Closes GH-7792
Closes GH-8187
2022-03-20 20:54:36 +01:00
Christoph M. Becker
dd6b1b7ef7
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7757: Multi-inherited final constant causes fatal error
2021-12-12 22:23:07 +01:00
Christoph M. Becker
206c521a1f
Fix GH-7757: Multi-inherited final constant causes fatal error
"Diamond" inheritance of final constants is supposed to be supported.

Closes GH-7767.
2021-12-12 22:22:51 +01:00
Nikita Popov
902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Dmitry Stogov
d56ec0a624 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81607 (CE_CACHE allocation with concurrent access)
2021-11-17 18:25:00 +03:00
Dmitry Stogov
76548e5093 Fixed bug #81607 (CE_CACHE allocation with concurrent access) 2021-11-17 18:23:36 +03:00
Nikita Popov
76df12cff0 Merge branch 'PHP-8.1'
* PHP-8.1:
  Combine variance obligation processing and error reporting
2021-11-08 10:42:41 +01:00
Nikita Popov
b969ce3b98 Combine variance obligation processing and error reporting
I don't believe there's a reason anymore to first resolve all
delayed variance obligations, and then report errors if any are
left.  We can report errors directly when resolving obligations.
2021-11-08 10:42:03 +01:00
Nikita Popov
53332b7f66 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug #78647
2021-11-08 10:00:07 +01:00
Nikita Popov
a38f4f9881 Fix bug #78647
We can't take ownership of the delayed autoload table here. It is
important that pending classes get loaded before resolving variance
of any nested classed, as they might actually be lower in the
hierarchy.
2021-11-08 09:59:33 +01:00
Nikita Popov
ee2cec186c Merge branch 'PHP-8.1'
* PHP-8.1:
  Partially address bug #78647
2021-11-05 17:07:14 +01:00
Nikita Popov
a2fe8d48b1 Partially address bug #78647
Produce a sensible error message for the case where inheritance
should fail. There is still a remaining issue that we sometimes
fail inheritance while we should not.
2021-11-05 17:05:55 +01:00
Nikita Popov
2d38f701e0 Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't implement Stringable on traits
2021-11-05 09:48:33 +01:00
Nikita Popov
4bdb271894 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't implement Stringable on traits
2021-11-05 09:48:28 +01:00
Nikita Popov
d478ae73b1 Don't implement Stringable on traits
Traits do not support interfaces, so we should not implement
Stringable on them.

Also check the __toString() return type in the same way other
magic methods do, otherwise we would now miss the check in the
trait case.
2021-11-05 09:42:58 +01:00
Nikita Popov
52ccb4d16b Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix typo

[ci skip]
2021-11-04 15:06:21 +01:00
Nikita Popov
94cacba1ee Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix typo

[ci skip]
2021-11-04 15:05:58 +01:00
Nikita Popov
462271c7e0 Fix typo
[ci skip]
2021-11-04 15:05:43 +01:00
Nikita Popov
9793b694e7 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81582
2021-11-04 11:58:59 +01:00
Nikita Popov
1d6f4db2ba Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed bug #81582
2021-11-04 11:58:43 +01:00
Nikita Popov
d3932682e7 Fixed bug #81582
If __toString() comes from a trait, implement Stringable during
inheritance.
2021-11-04 11:58:33 +01:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Dmitry Stogov
ddaf64b56c Avoid non-immutable map_ptr indirection 2021-10-14 12:16:18 +03:00
Nikita Popov
c19977d054 Fix delayed early binding with optimization
It's possible for delayed early binding opcodes to get optimized
away if they are "unreachable". However, we still need to attempt
early binding for them. (In some cases we also corrupt the early
binding list outright during optimization, which is how I got here.)

Fix this by storing information about delayed early binding
independently of DECLARE_CLASS_DELAYED opcodes, so early binding is
performed even after the opcode has been dropped.
2021-09-29 18:00:20 +02:00
Nikita Popov
c8fa477064 Convert exception during delayed autoload to fatal error
Same as with other exceptions during inheritance, convert those
thrown during delayed class loading into fatal errors. We can't
properly deal with such exceptions, as inheritance cannot be
gracefully aborted at this point.

Fixes oss-fuzz #39405.
2021-09-29 10:03:23 +02:00
Nikita Popov
3991483727 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Bail on exception during delayed autoload
2021-09-23 12:46:56 +02:00
Nikita Popov
be8217368b Bail on exception during delayed autoload
We shouldn't try to load further classes if one autoload throws.

This fixes oss-fuzz #38881, though I believe there are still two
deeper issues here: 1) Why do we allow autoloading with an active
exception? 2) Exception save & restore should probably also save
and restore the exception opline.
2021-09-23 12:46:39 +02:00
Nikita Popov
3eeeeeb104 Fully qualify ReturnTypeWillChange in deprecation message
When adding the #[ReturnTypeWillChange] attribute in namespaced
code, you also need to use ReturnTypeWillChange, otherwise it
will be silently ignored and may result in confusion. Change the
deprecation message to suggest #[\ReturnTypeWillChange], which
will always work.

Closes GH-7454.
2021-09-03 13:57:23 +02:00
Nikita Popov
4bb66ddc76 Set EG(active)=0 during preloading shutdown
Just like during normal shutdown, we should set EG(active)=0
during the partial preloading shutdown, to make sure that no
user code can run.

We need to slightly tweak inheritance class loading to still
pick the right code path.
2021-08-16 15:53:12 +02:00
Nikita Popov
1c6df2dffd Fixed bug #81192
Normally the filename is the current filename, but when traits
are involved, it might be a different one.
2021-08-12 14:35:13 +02:00