1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

1063 Commits

Author SHA1 Message Date
Gina Peter Banyard
6880a6c49d Zend: mark scope parameter of zend_type_to_string_resolved() const
And propagate const qualifier to use sites of this function.
2026-03-09 21:41:06 +00:00
Tim Düsterhus
303104e2bf zend: Define C23 enum zend_class_type (#21241)
Checked for “binary and” comparisons using Coccinelle:

    @@
    struct _zend_class_entry *e;
    expression x;
    @@

    * (e->type & x)

    @@
    zend_class_entry *e;
    expression x;
    @@

    * (e->type & x)
2026-02-17 16:49:45 +01:00
Tim Düsterhus
9c900b6e34 zend_compile: Bundle function type constants into an zend_function_type enum (#21208)
* zend_compile: Bundle function type constants into an `zend_function_type` enum

This clarifies the relationship between these constants and improves type
safety a little.

* Add C23_ENUM() helper macro

* zend_portability: Rename `size` to `underlying_type` in `C23_ENUM()`

* zend_portability: Include the leading `enum` in the `C23_ENUM` macro

* Fix comment for C23_ENUM()
2026-02-16 14:19:29 +01:00
Ilija Tovilo
6173a9a109 VAR|TMP overhaul (GH-20628)
The aim of this PR is twofold:

- Reduce the number of highly similar TMP|VAR handlers
- Avoid ZVAL_DEREF in most of these cases

This is achieved by guaranteeing that all zend_compile_expr() calls, as well as
all other compile calls with BP_VAR_{R,IS}, will result in a TMP variable. This
implies that the result will not contain an IS_INDIRECT or IS_REFERENCE value,
which was mostly already the case, with two exceptions:

- Calls to return-by-reference functions. Because return-by-reference functions
  are quite rare, this is solved by delegating the DEREF to the RETURN_BY_REF
  handler, which will examine the stack to check whether the caller expects a
  VAR or TMP to understand whether the DEREF is needed. Internal functions will
  also need to adjust by calling the zend_return_unwrap_ref() function.

- By-reference assignments, including both $a = &$b, as well as $a = [&$b]. When
  the result of these expressions is used in a BP_VAR_R context, the reference
  is unwrapped via a ZEND_QM_ASSIGN opcode beforehand. This is exceptionally
  rare.

Closes GH-20628
2026-01-31 19:44:56 +01:00
Khaled Alam
d03d69a88a Remove duplicate #include statements (#21085)
* Remove duplicate #include statements across the codebase.

* feat: Restore conditional/unconditional include pairs in lscriu.c
2026-01-30 16:37:13 +01:00
Arnaud Le Blanc
5472cac806 Support PFA syntax
RFC: https://wiki.php.net/rfc/partial_function_application_v2

For FCCs, the parser generates a normal function call AST node, the but argument
list is a ZEND_AST_CALLABLE_CONVERT / zend_ast_fcc node.

We extend this for PFAs so that zend_ast_fcc can represent arguments.

 * Support PFA syntax in grammar
 * Update zend_ast_fcc so that arguments can be represented
 * Support serialization of zend_ast_fcc arguments in SHM / file cache
 * Introduce zend_ast_arg_list_add(): Same as zend_ast_list_add(), but wraps the
   list in a ZEND_AST_CALLABLE_CONVERT when adding any placeholder argument.

Technically the arg list wrapping is not required, but it results in simpler
code later as it will be very convenient in the compiler (determines whether a
function calls is a PFA/FCC), and for PFA-in-const-expr support. It also allows
to unify FCCs and PFAs in the grammar.

Closes GH-20717.
2026-01-06 12:01:48 +01:00
Arnaud Le Blanc
626f3c3c7c Unify arg info representation for internal and user functions
The arg_info member of zend_function is now always a zend_arg_info*. Before,
it was a zend_internal_arg_info* on internal functions, unless the
ZEND_ACC_USER_ARG_INFO flag was set.

Closes GH-19022
2025-12-15 16:50:49 +01:00
Gina Peter Banyard
c669fbf370 Zend/zend_compile: add const qualifiers 2025-10-30 12:02:43 +00:00
Gina Peter Banyard
d0ad286ec8 Zend: use type uint32_t for zend_lineno global 2025-10-21 22:42:00 +01:00
Gina Peter Banyard
ada9d37527 Zend/Optimizer/zend_optimizer: add const qualifiers 2025-10-03 12:17:48 +01:00
Ilija Tovilo
292e0c2937 Add ce_flags2 & fn_flags2 (GH-19991) 2025-09-30 22:54:59 +02:00
Gina Peter Banyard
c515c04b0a Zend: Convert _zend_op_array literal fields to uint32_t 2025-09-29 15:53:58 +01:00
Gina Peter Banyard
0a47dd9bb4 Zend: Convert _zend_op_array.last_try_catch field to uint32_t 2025-09-29 15:53:58 +01:00
Gina Peter Banyard
a94dc48567 Zend: Convert _zend_op_array.last_live_range field to uint32_t 2025-09-29 15:53:58 +01:00
Gina Peter Banyard
18ce83b2e3 Zend: Convert _zend_op_array.cache_size field to uint32_t 2025-09-29 15:53:58 +01:00
Gina Peter Banyard
6b470cf5d8 Zend: Convert _zend_oparray_context.var_size field to uint32_t 2025-09-29 15:53:58 +01:00
Gina Peter Banyard
39d6bc1716 Mark zend_visibility_string as returning a const char* (#19951)
This is because the char* returned is immutable and should not be modified.
2025-09-25 10:28:13 +01:00
Daniel Scherzer
34a6e86282 [RFC] Allow #[\Deprecated] on traits (#19045)
https://wiki.php.net/rfc/deprecated_traits
2025-09-05 12:30:50 -07:00
Gina Peter Banyard
8a5972fd83 ext/standard: Deprecate $http_response_header (#19464)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_http_response_header_predefined_variable
2025-08-25 22:43:26 +01:00
Ilija Tovilo
71a3226a46 Prohibit pipe & arrow function combination that leads to confusing parse trees
See https://externals.io/message/128473
Closes GH-19533
2025-08-25 17:24:55 +02:00
Jiří Pudil
38beb44176 [RFC] Extend #[\Override] to target properties (#19061)
RFC: https://wiki.php.net/rfc/override_properties

Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2025-08-12 15:18:50 +02:00
Theodore Brown
5f8d648af6 Deprecate terminating case statements with a semicolon (#19215)
Part of https://wiki.php.net/rfc/deprecations_php_8_5

Closes GH-15258
2025-08-11 14:18:06 +02:00
Gina Peter Banyard
36ec3370fb Zend/zend_ast: Add const qualifier 2025-08-05 12:43:18 +01:00
Arnaud Le Blanc
7f7b3cdb90 Introduce zend_vm_opcode_handler_t / zend_vm_opcode_handler_func_t
This reduces the chances of confusion between opcode handlers used by the
VM, and opcode handler functions used for tracing or debugging. Depending
on the VM, zend_vm_opcode_handler_t may not be a function. For instance in
the HYBRID VM this is a label pointer.

Closes GH-19006
2025-07-26 13:20:59 +02:00
DanielEScherzer
7777eaa8e1 zend_compile.h: align ZEND_CLASS_CONST_IS_CASE like others [skip ci] 2025-07-24 15:07:27 -07:00
DanielEScherzer
3558293ce8 Remove broken zend_get_zendleng() declaration (#19032)
Does not actually exist anywhere
2025-07-04 14:40:54 -07:00
DanielEScherzer
3f03f7ed3d [RFC] Add support for attributes on compile-time constants
https://wiki.php.net/rfc/attributes-on-constants
2025-04-29 11:53:09 -07:00
Ilija Tovilo
c97bdce962 Evaluate const expression cast at ct if possible
Related to GH-18264
Closes GH-18347
2025-04-22 17:49:33 +02:00
Ilija Tovilo
aa0c54dade Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix prop info fetching from prop slot with added hooks
2025-04-08 18:46:01 +02:00
Ilija Tovilo
6d458caefe Fix prop info fetching from prop slot with added hooks
Fixes GH-18268
Closes GH-18271
2025-04-08 18:45:26 +02:00
Tim Düsterhus
5544be7018 RFC: Marking return values as important (#[\NoDiscard]) (#17599)
RFC: https://wiki.php.net/rfc/marking_return_value_as_important

Co-authored-by: Volker Dusch <volker@tideways-gmbh.com>
2025-04-02 09:35:29 +02:00
Tim Düsterhus
8779e2a603 Add (void) cast
RFC: https://wiki.php.net/rfc/marking_return_value_as_important
2025-03-24 19:35:30 +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
e95b298262 Store prop info name in CG(context) instead of prop info
The prop info is not always available, e.g. when compiling the default
value.

See GH-17378
Closes GH-17464
2025-01-14 17:01:10 +01:00
Daniel Scherzer
79d708cfca GH-15976: clarify error messages for enum/trait/interface/alias names
Instead of always saying that a name is reserved or deprecated and
cannot/should not be used as a class name, take the usage into account and say
the name cannot be used as an enum name, trait name, etc. In the process, for
class names add a missing "a".
2024-09-22 19:14:57 +01:00
DanielEScherzer
3c8fd93dcf [skip ci] zend_compile.h: ZEND_ACC_DEPRECATED can be used for class constants (#15848)
Support for deprecating class constants was added to implement the PHP 8.3
deprecations in #11615, but the documentation update was missed.

[skip ci]
2024-09-12 17:52:43 +01:00
DanielEScherzer
e1f7197f89 [skip ci] zend_compile.h: ZEND_ACC_FINAL can be used for constants (GH-15764)
There was a whole RFC about this, but the implementation in #6878 seems to have
missed updating the documentation
2024-09-05 19:22:07 +02:00
Arnaud Le Blanc
58aa6fc830 Lazy objects
RFC: https://wiki.php.net/rfc/lazy-objects

Closes GH-15019
2024-08-30 17:30:03 +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
327588abf9 Replace OBJ_PROP_PTR_TO_NUM() with zend_get_property_info_for_slot()
I wasn't aware such a function already existed.
2024-08-20 18:44:42 +02:00
Ilija Tovilo
60f87f29bb Fix various hooked object iterator issues (GH-15394)
Fixes GH-15187
2024-08-19 15:46:20 +02:00
Tim Düsterhus
551038bb16 zend_compile: Fully remove ZEND_DIM_ALTERNATIVE_SYNTAX (#14974)
This flag is longer set since the merge of property hooks in
780a8280d2. This patch removes it completely,
because the corresponding error messages are unreachable.
2024-07-16 16:27:46 +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
Ilija Tovilo
600d591cae Omit FETCH_THIS in closures
Non-static closures are guaranteed to have $this. The existing comment
highlights this, but fails to handle it correctly.

Closes GH-14181
2024-05-16 12:28:11 +02:00
Máté Kocsis
f2e199e878 Implement "support doc comments for internal classes and functions" (#13266)
Fixes #13130
2024-02-25 08:41:31 +01:00
Ilija Tovilo
c149b4f56f Fix missing syntax error message in cli-server router script
Fixes GH-13113
Closes GH-13275
2024-02-07 16:13:08 +01:00
Ilija Tovilo
631bc81607 Implement stackless internal function calls
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12461
2024-02-06 17:42:28 +01:00
Ilija Tovilo
ffc250d245 Add runtime type inference verification
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12930
2024-01-19 09:29:14 +01:00
George Peter Banyard
5c3a6eaec9 Zend: Remove dependency on zend.h for certain headers (#12166) 2023-09-11 12:27:21 +01:00