Commit graph

301 commits

Author SHA1 Message Date
Tim Düsterhus
45d948f2da
Zend: Add zend_check_method_accessible() to DRY method visibility checks (#18995)
* Zend: Add `zend_check_method_accessible()` to DRY method visibility checks

* Zend: Add assertions verifying flags didn't change before `zend_check_method_accessible()`

* Try `zend_always_inline` for `zend_check_method_accessible`
2025-07-07 21:30:13 +02:00
Tim Düsterhus
ca49a7bec2
RFC: Turn clone() into a function (#18919)
RFC: https://wiki.php.net/rfc/clone_with_v2

Co-authored-by: Volker Dusch <volker@tideways-gmbh.com>
2025-06-24 20:14:40 +02:00
DanielEScherzer
4dfba7a250
[RFC] Final Property Promotion
https://wiki.php.net/rfc/final_promotion
2025-06-22 12:29:26 -07:00
Larry Garfield
1c09c0c832
RFC: Pipe operator (#17118)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-06-10 09:59:43 +02:00
Nikita Popov
910411f2f5 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix line assignment in zend_ast_create_va()
2025-06-01 20:36:01 +02:00
Nikita Popov
d66e87b02e Fix line assignment in zend_ast_create_va()
The intent here was to assign the first found line. Instead this
always fell back to CG(zend_lineno).

Not sure if this line matters for anything in php-src, but the
issue was observed in https://github.com/nikic/php-ast/issues/247.
2025-06-01 20:35:35 +02:00
Daniel Scherzer
6b95875dc5
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() (#18699)
2025-05-29 13:49:34 -07:00
Daniel Scherzer
e44c13cffe
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() (#18699)
2025-05-29 13:48:38 -07:00
Oleg Efimov
087f38f347
Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() (#18699) 2025-05-29 13:46:11 -07:00
DanielEScherzer
f0fa9c748a
zend_ast.c: use smart_str_appendc for appending single characters (#18703)
Slightly more performant
2025-05-29 11:11:00 -07:00
Dmitrii Derepko
fdebad0b25
zend_ast: Add parentheses around IIFE in zend_ast_export() (#18688) 2025-05-29 15:47:47 +02:00
Niels Dossche
0b48e2a267
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix OSS-Fuzz #418106144
  Fix OSS-Fuzz #417078295
  fix: dangling opline in ZEND_INIT_ARRAY (#18578)
2025-05-19 19:08:29 +02:00
Niels Dossche
08cba2dcc1
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #418106144
  Fix OSS-Fuzz #417078295
2025-05-19 19:07:17 +02:00
Niels Dossche
98cb17f4fd
Fix OSS-Fuzz #418106144
The VM assumes that an exception must be handled when the AST evaluation
returns FAILURE. However, the comparison functions always return SUCCESS
even if an exception happened. This can be fixed in
zend_ast_evaluate_inner() or we can make is_smaller_function() etc check
for the exception. I chose the former to avoid impact or API breaks.
Perhaps in the future the comparison functions should either return void
or return whether an exception happened, as to be not misleading.

Closes GH-18589.
2025-05-19 19:05:32 +02: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
Niels Dossche
2f6c069296
Implement GH-18261: Allow cast to be used in constant expressions (#18264) 2025-04-11 17:53:43 +02:00
Tim Düsterhus
45d1acf916
Zend: Fix reference counting for Closures in const-expr (#17853)
* Clean up closure static variable handling

* Zend: Fix reference counting for Closures in const-expr

Fixes php/php-src#17851

---------

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2025-03-27 10:11:44 +01: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
Tim Düsterhus
2042fd34e0
Support first-class callables in const-expressions (#17213)
RFC: https://wiki.php.net/rfc/fcc_in_const_expr

Co-authored-by: Volker Dusch <volker@tideways-gmbh.com>
2025-02-20 18:52:47 +01:00
Gina Peter Banyard
65d433161a
Use new known "self" and "parent" zend_strings (#17766) 2025-02-12 15:30:55 +00:00
Tim Düsterhus
d8d1cb4195
zend_ast: Print placeholder value when printing ZEND_AST_OP_ARRAY (#17405)
As per the discussion in GH-17120, we are printing a placeholder value only.
The commit history of that PR also includes alternative implementations, should
a different decision be desirable.

Fixes GH-17096
Closes GH-17120
2025-01-10 08:37:17 +01:00
Tim Düsterhus
e421a44ac6
zend_ast: Remove unused ZEND_AST_EXIT (#17417)
This AST node is no longer used since `exit()` was made a real function in
GH-13483.
2025-01-09 12:23:33 +01:00
Tim Düsterhus
cee64ed3bd
Add dedicated zend_ast_op_array struct (#17391)
Given that the `ZEND_AST_OP_ARRAY` type already needed special handling in
various places, it makes sense to give it its own struct to avoid some of the
casts. As a side benefit, it is a little smaller than the `zend_ast_zval`
struct.
2025-01-08 11:26:35 +01:00
Tim Düsterhus
fd1eacc2ed
Add assertions verifying that zend_ast_decl AST nodes are not treated as regular zend_ast nodes (#17390)
* zend_compile: Do not traverse children of ZEND_AST_CLOSURE in zend_compile_const_expr()

* Add assertions verifying that zend_ast_decl AST nodes are not treated as regular zend_ast nodes
2025-01-08 10:36:02 +01:00
Niels Dossche
97f44b7c39
Merge branch 'PHP-8.4'
* PHP-8.4:
  Export visibility for promoted property (8.3)
  [ci skip] News for GH-17101
  Add test for GH-17101
  Print hooks in parameter exports
  Fix property hook name mismatch
  Extract hook export code
  Export visibility for promoted property
2024-12-17 19:14:55 +01:00
Niels Dossche
160a4a65ad
Export visibility for promoted property (8.3) 2024-12-17 19:14:07 +01:00
Niels Dossche
3f0f7ab7df
Print hooks in parameter exports 2024-12-17 19:06:10 +01:00
Niels Dossche
0cba85b54d
Fix property hook name mismatch 2024-12-17 19:06:10 +01:00
Niels Dossche
6920aa2ae6
Extract hook export code 2024-12-17 19:06:10 +01:00
Niels Dossche
6f41bfd1c7
Export visibility for promoted property 2024-12-17 19:06:09 +01:00
Tim Düsterhus
f6a0bb4d04
Support Closures in constant expressions (#16458)
RFC: https://wiki.php.net/rfc/closures_in_const_expr

Co-authored-by: Volker Dusch <volker@tideways-gmbh.com>
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Arthur Kurbidaev <artkurbidaev@gmail.com>
2024-12-02 18:25:43 +01: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
Christoph M. Becker
65c6d72319
Drop FASTCALL on variadic functions (GH-15389)
This is unlikely to be properly supported by compilers anyway, see
<https://github.com/php/php-src/pull/2975>.
2024-08-13 19:46:48 +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
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
George Peter Banyard
d5ad75108e
More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
Nikita Popov
c230aa9be3 Correctly handle multiple constants in typed declaration
While here also fix AST printing support.
2023-05-21 14:17:01 +01:00
Ilija Tovilo
5107483cd6
Correctly copy lineno for zval asts (#11203)
The comment was incorrect. Zval ASTs store their lineno in u2, but u2 does not
get copied in ZVAL_COPY. This triggers use-of-uninitialized errors with MSAN.
Unfortunately, I don't have a simple reproducer.
2023-05-07 13:17:19 +02:00
Ilija Tovilo
ba33bbe260
Merge branch 'PHP-8.2'
* PHP-8.2:
  Unary minus const expression consistency
2023-03-31 14:28:39 +02:00
Ilija Tovilo
ed80a7e8c9
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Unary minus const expression consistency
2023-03-31 14:28:25 +02:00
Ilija Tovilo
41bbb116dd
Unary minus const expression consistency
- of 0.0 should result in -0.0

Closes GH-10978
2023-03-31 14:27:54 +02:00
Ilija Tovilo
35a36b13e5
Fix comp-time and constant evaluation of dynamic class constant fetch
Fixes GH-10486
Fixes oss-fuzz #55436
Fixes oss-fuzz #55472
Closes GH-10487
2023-02-02 19:18:17 +01:00
Ilija Tovilo
9e097822e8
Fix lineno for all constant expressions
Fixes GH-8821
Closes GH-8855
2023-02-02 19:03:47 +01: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
5190e5c260 Zend/zend_ast: include cleanup 2023-01-15 15:07:58 +00:00
Niels
23fe58c3a8
Remove _zend_ast_decl->lex_pos (#10046)
This struct member was only written to, but never read.
2022-12-22 15:01:21 +01:00
Christoph M. Becker
9f0e4a55e7
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-9769: Misleading error message for unpacking of objects
2022-12-02 13:12:14 +01:00
Christoph M. Becker
6b1f4c5a44
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-9769: Misleading error message for unpacking of objects
2022-12-02 13:11:51 +01:00
蝦米
93592ea743
Fix GH-9769: Misleading error message for unpacking of objects
Only arrays can be unpacked in constant expressions.

Closes GH-9776.
2022-12-02 13:10:59 +01:00
Ilija Tovilo
683d81e4bd
Fix incorrect short-circuiting in constant expressions (#10030)
Fixes GH-10014
2022-12-01 19:30:44 +01:00