Commit graph

498 commits

Author SHA1 Message Date
Ilija Tovilo
d20f4fca69
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix properties_info_table for abstract properties
2025-07-21 15:54:53 +02:00
Ilija Tovilo
c8cc23336d
Fix properties_info_table for abstract properties
Fixes GH-19053
Closes GH-19140

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
2025-07-21 15:54:24 +02:00
Niels Dossche
383aad8007
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18534: FPM exit code 70 with enabled opcache and hooked properties in traits
2025-05-19 19:22:16 +02:00
Niels Dossche
6b795f64a5
Fix GH-18534: FPM exit code 70 with enabled opcache and hooked properties in traits
The trait handling for property hooks in preloading did not exist, we
add a check to skip trait clones and we add the necessary code to update
the op arrays.

Closes GH-18586.
2025-05-19 19:21:53 +02:00
Niels Dossche
06738fc051
Remove ZEND_ACC_USE_GUARDS from hooks (#18587)
This is no longer necessary since the hooks amendments removed guards
for recursion.
2025-05-18 15:01:24 +02:00
Ilija Tovilo
03d2226f45
Fix self inheritance type checks for traits
Fixes GH-18295
Closes GH-18296
2025-04-22 17:52:43 +02:00
Gina Peter Banyard
71da944c82 Zend: Add MUTABLE zend_type foreach macros and const qualifiers
The motivation for this is that types should be considered immutable.
The only times this is not valid is during compilation, optimizations (opcache), or destruction.

Therefore the "normal" type foreach macros are marked to take const arguments and we add mutable version that say so in the name.
Thus add various const qualifiers to communicate intent.
2025-04-07 12:52:40 +01:00
Gina Peter Banyard
462b170a30 Zend/zend_inheritance: Use bool instead of uint32_t 2025-04-05 15:47:51 +01:00
Gina Peter Banyard
dcf664963f Zend/zend_inheritance: Add some const modifiers 2025-04-05 15:47:51 +01:00
Gina Peter Banyard
10c9e4decf Zend/zend_inheritance: Reduce scope of variables
Fix some types at the same time
2025-04-05 15:47:51 +01:00
Gina Peter Banyard
1304719aae Zend/zend_inheritance: Prevent variable shadowing 2025-04-05 15:47:51 +01:00
Ilija Tovilo
011795bcbe
Bind traits before parent class
This more accurately matches the "copy & paste" semantics described in
the documentation. Abstract trait methods diverge from this behavior,
given that a parent method can satisfy trait methods used in the child.
In that case, the method is not copied, but the check is performed after
the parent has been bound.

Fixes GH-15753
Fixes GH-16198
Close GH-15878
2025-04-01 18:20:02 +02:00
Ilija Tovilo
8731c95b35
Make missing trait error recoverable
We were already handling NULL as a case, but seem to have forgotten to
pass the ZEND_FETCH_CLASS_EXCEPTION flag.

Also make "is not a trait" error recoverable, there's no reason why it
can't be.

Fixes GH-17959
Closes GH-17960
2025-03-12 16:19:58 +01:00
rekmixa
4f5136cf2e
Allow substituting static for self in final classes
Fixes GH-17725
Closes GH-17724
2025-03-05 11:31:46 +01:00
Ilija Tovilo
949e10e4c1
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix circumvented added hooks in JIT
2025-02-26 21:26:39 +01:00
Ilija Tovilo
376e90fbf2
Fix circumvented added hooks in JIT
The following code poses a problem in the JIT:

```php
class A {
    public $prop = 1;
}

class B extends A {
    public $prop = 1 {
        get => parent::$prop::get() * 2;
    }
}

function test(A $a) {
    var_dump($a->prop);
}

test(new B);
```

The JIT would assume A::$prop in test() could be accessed directly
through OBJ_PROP_NUM(). However, since child classes can add new hooks
to existing properties, this assumption no longer holds.

To avoid introducing more JIT checks, a hooked property that overrides a
unhooked property now results in a separate zval slot that is used
instead of the parent slot. This causes the JIT to pick the slow path
due to an IS_UNDEF value in the parent slot.

zend_class_entry.properties_info_table poses a problem in that
zend_get_property_info_for_slot() and friends will be called using the
child slot, which does not store its property info, since the parent
slot already does. In this case, zend_get_property_info_for_slot() now
provides a fallback that will iterate all property infos to find the
correct one.

This also uncovered a bug (see Zend/tests/property_hooks/dump.phpt)
where the default value of a parent property would accidentally be
inherited by the child property.

Fixes GH-17376
Closes GH-17870
2025-02-26 21:26:00 +01:00
Ilija Tovilo
15c2477273
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix accidentally inherited default value in overridden virtual properties
2025-02-26 21:17:49 +01:00
Ilija Tovilo
e0c69dde02
Fix accidentally inherited default value in overridden virtual properties
Discovered when working on GH-17376.
2025-02-26 21:16:58 +01:00
Ilija Tovilo
84d00ec58f
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix property hook backing value access in multi-level inheritance
2025-02-26 20:49:15 +01:00
Ilija Tovilo
7a55116f12
Fix property hook backing value access in multi-level inheritance
Discovered by Niels when testing GH-17376.
2025-02-26 20:49:07 +01:00
Gina Peter Banyard
65d433161a
Use new known "self" and "parent" zend_strings (#17766) 2025-02-12 15:30:55 +00:00
Gina Peter Banyard
ac52b5b738
Zend: Add const specifier to resolve_class_name() 2025-02-11 19:48:05 +00:00
Ilija Tovilo
ed1e47e325
Fix callable variance check (GH-17613)
Caused by GH-15492. While the parent might contain callable, it may also
contain other types. zend_is_class_subtype_of_type() may be checking a
member that is not callable itself. Fall back to the normal class
subtype check.

Discovered by a failing Laravel test in nightly.
2025-01-28 16:45:36 +01:00
Gina Peter Banyard
32fb2607a3
Zend: Make Closure a proper subtype of callable (#15492) 2025-01-24 17:32:23 +00:00
Ilija Tovilo
0e1fbf97f4
Merge branch 'PHP-8.4'
* PHP-8.4:
  Relax final+private warning for trait methods with inherited final
2025-01-13 16:46:54 +01:00
Ilija Tovilo
3c138641e1
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Relax final+private warning for trait methods with inherited final
2025-01-13 16:46:43 +01:00
Ilija Tovilo
a6a290d541
Relax final+private warning for trait methods with inherited final
Fixes GH-17214
Closes GH-17381
2025-01-13 16:46:01 +01:00
Ilija Tovilo
fbb97aa6fc
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix unstable get_iterator pointer for hooked classes in shm on Windows
2024-12-09 17:14:46 +01:00
Ilija Tovilo
792f63df45
Fix unstable get_iterator pointer for hooked classes in shm on Windows
Closes GH-17034
2024-12-09 17:14:19 +01:00
chx
e5c2bc41ed
Improve error message when overriding untyped property with typed property (GH-16866) 2024-11-20 11:59:29 +01:00
Ilija Tovilo
e122152373
Simplify (bitset & flag) == flag conditions
Closes GH-16558
2024-10-30 17:27:52 +01:00
Ilija Tovilo
9fa2f116c3
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix lineno for inheritance errors of early bound classes
2024-10-22 15:17:36 +02:00
Ilija Tovilo
077d69db44
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix lineno for inheritance errors of early bound classes
2024-10-22 15:17:29 +02:00
Ilija Tovilo
e02085359d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix lineno for inheritance errors of early bound classes
2024-10-22 15:17:11 +02:00
Ilija Tovilo
2d068c4f47
Fix lineno for inheritance errors of early bound classes
Fixes GH-16508
Closes GH-16532
2024-10-22 15:16:43 +02:00
Daniel Scherzer
cb1d4ba97a
GH-16315: Improve error messages when extending enums
Closes GH-16491
2024-10-18 22:22:54 +02:00
DanielEScherzer
b436ef479e
GH-15994: fix suggestion that anonymous classes be made abstract (GH-15995)
In the process, remove the (incorrect) assumption that any abstract method that
needs to be implemented by a class that cannot itself be made abstract must be
a private method - the existing test for an enum already showed that this was
not the case.
2024-09-26 00:05:12 +02:00
DanielEScherzer
3b349db1a7
GH-15992: fix error message for single abstract method not implemented (GH-15993) 2024-09-25 22:48:02 +02:00
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