Commit Graph

460 Commits

Author SHA1 Message Date
DanielEScherzer
a3583d7eef
zend_inheritance.c: make a bunch of pointers const (GH-15934)
* zend_inheritance.c: make a bunch of pointers `const`

* Fix const double pointers
2024-09-17 12:44:17 +02:00
Ilija Tovilo
7f0d2574f0
Simplify a-vis error message 2024-09-03 12:18:07 +02:00
Ilija Tovilo
2b8a1b4258
Forbid a-vis on unilateral virtual prop
The get-only case is obvious, there is no set operation so specifying its
visibility is senseless. The set-only case is also questionable, since there is
no operation other than set, so changing the visibility of the entire property
is preferable.

Closes GH-15698
2024-09-02 17:40:30 +02:00
Ilija Tovilo
8df557ac42
[RFC] Asymmetric visibility v2 (GH-15063)
Co-authored-by: Larry Garfield <larry@garfieldtech.com>
2024-08-27 02:04:48 +02:00
Ilija Tovilo
8fcf34d598
Remove ZEND_ACC_ABSTRACT from prop variance check
Abstract properties are now virtual, unless they actually contain concrete hook
implementations using the backing field.
2024-08-23 16:13:23 +02:00
Ilija Tovilo
2f27e0b2ab
Fix missing variance check for abstract set with asymmetric type (#15157)
Fixes GH-15140
2024-08-05 16:43:54 +02:00
Ilija Tovilo
5d9c155dd3
Fix inheritance of hooks onto plain properties 2024-08-05 14:30:37 +02:00
Ilija Tovilo
43f688e1ed
Fix zend_function.prop_info pointer for trait hooks (#15245)
Fixes GH-15240
2024-08-05 13:14:37 +02:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00
Dmitry Stogov
924e7fcb8a
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484)
2024-06-05 23:59:49 +03:00
Dmitry Stogov
ee7d35cc4d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484)
2024-06-05 23:59:37 +03:00
Dmitry Stogov
86b93bc479
Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484) 2024-06-05 23:53:31 +03:00
Cristian Rodríguez
8e62e2b829
Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Dmitry Stogov
c5982c961d
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix incorrect inheritance of private trait methods (#14163)
2024-05-07 13:20:00 +03:00
Dmitry Stogov
da5b43f3a1
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix incorrect inheritance of private trait methods (#14163)
2024-05-07 13:19:49 +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
3fcf6ffbc4
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix prototype for trait methods (#14148)
2024-05-06 21:46:13 +03:00
Dmitry Stogov
c42f48d58d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix prototype for trait methods (#14148)
2024-05-06 21:46:00 +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
Ilija Tovilo
1c30c5e707
Print location on class redeclaration
Fixes GH-13950
Closes GH-13999
2024-04-30 14:34:43 +02:00
Ilija Tovilo
782af7a963
Fix -Walloc-size warning
It's indeed unsafe to treat zend_internal_function as zend_function, because
sizeof(zend_internal_function) < sizeof(zend_function), which can lead to buffer
overflows. This might also be UB.

Either way, this would need to be addressed in the whole codebase.
2024-04-29 16:36:24 +02:00
Bob Weinand
9bed0b5f2f Merge branch 'PHP-8.3' 2024-03-18 19:06:12 +01:00
Bob Weinand
6d6cd29909 Merge branch 'PHP-8.2' of https://github.com/php/php-src into PHP-8.3 2024-03-18 19:04:12 +01: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
Michael Voříšek
87edeed3b9
Remove UNEXPECTED from typed prop checks
Closes GH-13143
2024-02-12 11:35:43 +01:00
Niels Dossche
31092c235d Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-13177: PHP 8.3.2: final private constructor not allowed when used in trait
  Fix GH-12107: When running a stored procedure (that returns a result set) twice, PHP crashes
2024-01-19 23:41:01 +01:00
Niels Dossche
c2c1710ed7 Fix GH-13177: PHP 8.3.2: final private constructor not allowed when used in trait
zend_compile has an exception to this rule for constructors using
`zend_is_constructor`, which compares the function name to
`__construct`. Sadly, `zend_is_constructor` is not a public API, but we
can just do the string compare ourselves.

Closes GH-13179.
2024-01-19 23:36:36 +01:00
Niels Dossche
bfb678a266 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12854: 8.3 - as final trait-used method does not correctly report visibility in Reflection
2023-12-05 21:49:42 +01:00
Niels Dossche
e679ab36b3 Fix GH-12854: 8.3 - as final trait-used method does not correctly report visibility in Reflection
Closes GH-12857.
2023-12-05 21:49:29 +01:00
Niels Dossche
cdfa016854
Avoid refcounted copy in _object_properties_init() for internal classes (#12474)
This currently uses ZVAL_COPY_OR_DUP, which copies the value and handles
refcounting. However, internal classes cannot have refcounted default
properties because of constraints imposed by
zend_declare_typed_property(). So copying the value is sufficient.

While this doesn't really improve the performance for our benchmarks, it
improves performance for cases where a lot of temporary internal objects
are instantiated. For example, when instantiating DOM classes: DOM
objects are transient, so lots of temporary objects are created.
2023-10-19 12:34:55 +02:00
Tim Düsterhus
d344fe06a2
Fix #[Override] on traits overriding a parent method without a matching interface (#12205)
Fixes GH-12189

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2023-09-15 14:57:10 +02:00
George Peter Banyard
82972f448f Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix various bugs related to DNF types
2023-08-15 17:01:51 +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
Ilija Tovilo
d9db446065
Fix iface const visibility variance check 2023-07-13 10:52:58 +02:00
Ilija Tovilo
7343ae5d3c
Fix missing iface class const inheritance type check 2023-07-13 10:40:19 +02:00
Tim Düsterhus
49ef6e209d
RFC: Add #[Override] attribute (#9836)
* Add #[Override] attribute

* Move #[\Override] tests into Zend/tests/attributes/override/

* Check `check_only` before removing `ZEND_ACC_OVERRIDE`

* NEWS/UPGRADING for #[\Override]
2023-06-29 20:23:53 +02:00
Ilija Tovilo
ee4ebab5a9
[skip ci] Improve inheritance checked comment
zend_can_early_bind() might have already detected that the methods are
incompatible. In that case the class is still early bound, but must compile
error when inheritance is performed. Thus it is only safe to skip compatibility
checks when zend_can_early_bind() has succeeded.
2023-06-29 09:35:42 +02:00
Ilija Tovilo
5723fa2275
[skip ci] Document do_inheritance_check_on_method_ex() check_only and check params
These are quite confusingly named.
2023-06-29 09:18:59 +02:00
Ilija Tovilo
0600f513b3
Implement delayed early binding for classes without parents
Normally, we add classes without parents (and no interfaces or traits) directly
to the class map, early binding the class. However, if the same class has
already been registered, we would instead just add a ZEND_DECLARE_CLASS
instruction and let the handler throw a duplicate class declaration exception.

However, with opcache, if on the next request the files are included in the
opposite order, we won't perform early binding. To fix this, create a
ZEND_DECLARE_CLASS_DELAYED instruction instead and handle classes without
parents accordingly, skipping any linking for classes that are already linked in
delayed early binding.

Fixes GH-8846
2023-05-15 10:25:33 +02:00
Máté Kocsis
414f71a902
Typed class constants (#10444)
RFC: https://wiki.php.net/rfc/typed_class_constants

Co-Authored-By: Ben <7127204+moliata@users.noreply.github.com>
Co-Authored-By: Bob Weinand <3154871+bwoebi@users.noreply.github.com>
Co-Authored-By: Ilija Tovilo <ilija.tovilo@me.com>
2023-04-16 22:20:26 +02:00
Ilija Tovilo
9a250cc9d6
Add separate static property through trait if parent already declares it
Fixes GH-10935
Closes GH-10937
2023-04-06 14:27:24 +02:00
Máté Kocsis
3bcf2c3755
Allow readonly properties to be reinitialized once during cloning (#10389)
RFC: https://wiki.php.net/rfc/readonly_amendments
2023-02-28 22:54:38 +01:00
Max Kellermann
413844d626
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
2023-02-18 19:31:28 +00:00
rj1
d2cdfdbe44
fixed some misspellings (#10503) 2023-02-04 07:03:10 +00:00
Christoph M. Becker
bf1cfc0753
Revert GH-10300
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit 68ada76f9a.
his reverts commit 45384c6e20.
This reverts commit ef7fbfd710.
This reverts commit 9b9ea0d7c6.
This reverts commit f15747c26b.
This reverts commit e883ba93c4.
This reverts commit 7e87551c37.
This reverts commit 921274d2b8.
This reverts commit fc1f528e5e.
This reverts commit 0961715cda.
This reverts commit a93f264526.
This reverts commit 72dd94e1c6.
This reverts commit 29b2dc8964.
This reverts commit 05c7653bba.
This reverts commit 5190e5c260.
This reverts commit 6b55bf228c.
This reverts commit 184b4a12d3.
This reverts commit 4c31b7888a.
This reverts commit d44e9680f0.
This reverts commit 4069a5c43f.
2023-01-16 12:22:54 +01:00
Max Kellermann
45384c6e20 Zend/zend_inheritance: include cleanup 2023-01-15 15:07:58 +00:00
Dmitry Stogov
7b6e31e9b5 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix memory leak
2022-12-19 12:12:05 +03: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
98646e3e21 Merge branch 'PHP-8.2' 2022-11-02 15:33:17 +01:00