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

345 Commits

Author SHA1 Message Date
Máté Kocsis
30b2d77cd3 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix replacement of class signatures when a packagesynopsis element is present
2026-03-20 23:30:35 +01:00
Máté Kocsis
6932260386 Fix replacement of class signatures when a packagesynopsis element is present
So far, the gen_stub.php --replace-classsynopses subcommand didn't take the packagesynopsis element into account, causing some bugs: the wrong element was tried to be replaced (classynopsis instead of packagesynopsis) with the wrong content (the classname without the namespace: e.g. \Exception instead of \FFI\Exception).
2026-03-20 23:30:01 +01:00
Daniel Scherzer
36e1469fe1 gen_stub: use first class callables where possible 2026-03-20 14:44:28 -07:00
Daniel Scherzer
362f5fdb09 gen_stub: use match rather than switch when possible 2026-03-20 14:44:28 -07:00
Daniel Scherzer
ef5771dce2 gen_stub: use real readonly modifier 2026-03-20 14:44:27 -07:00
Daniel Scherzer
b83dd1055b gen_stub: use real mixed type 2026-03-20 14:44:10 -07:00
Daniel Scherzer
25f62cfa1f gen_stub: simplify with early returns 2026-03-16 09:53:51 -07:00
Daniel Scherzer
f1dd3f2f30 gen_stub: move generateArgInfoCode() into FileInfo
Reduce the number of global functions by moving it to instance method
`FileInfo::generateArgInfoCode()`.

In the process, make the following parts of `FileInfo` private:

- `$funcInfos`
- `$generateFunctionEntries`
- `$declarationPrefix`
- `$generateClassEntries`
- `$generateCEnums`
- `::getMinimumPhpVersionIdCompatibility()`
2026-03-16 09:53:51 -07:00
Daniel Scherzer
777fa5d158 gen_stub: fix typo $minPHPCompatability to $minPHPCompatibility 2026-03-16 09:53:51 -07:00
Daniel Scherzer
8ee5a524fa gen_stub: polyfill and use array_any() 2026-03-16 09:53:51 -07:00
Daniel Scherzer
a1d8e525f0 gen_stub: drop unused parameter in ConstInfo::getClassConstDeclaration() 2026-03-16 09:53:34 -07:00
Máté Kocsis
c506142044 Merge branch 'PHP-8.5'
* PHP-8.5:
  Add support for generating the namespace for the manual (#21313)
2026-03-05 13:43:14 +01:00
Máté Kocsis
7e78b0f1d2 Add support for generating the namespace for the manual (#21313)
[skip ci]
2026-03-05 13:42:36 +01:00
Arnaud Le Blanc
d16e6f52a4 Generate C enums from internal enums, introduce Z_PARAM_ENUM() (#20917)
Update gen_stubs.php to generate C enums from internal enums, when the stub is annotated with @generate-c-enums. Enum values can be compared to the result of zend_enum_fetch_case_id(zend_object*).

The generated enums are added to separate files named {$extensionName}_decl.h, so that it's possible to include these from anywhere. _arginfo.h files would generate warnings if we tried to include them in a compilation unit that doesn't call the register_{$class} functions, for instance.

Introduce Z_PARAM_ENUM().

* Make ZEND_AST_CONST_ENUM_INIT a 4-children node

* Store enum case id in ZEND_AST_CONST_ENUM_INIT

* Store enum case id in instance

* Expose enum case_id internally

* Generate C enum for internal enums

* Introduce Z_PARAM_ENUM()

* Port extensions
2026-02-03 12:38:04 +01:00
Tim Düsterhus
149d34d2cc Merge branch 'PHP-8.5'
* PHP-8.5:
  gen_stub: Fix compatibility with php 7.4 (in PHP-8.5+) (#21075)
2026-01-29 12:01:10 +01:00
Giovanni Giacobbi
7ec14e3ca4 gen_stub: Fix compatibility with php 7.4 (in PHP-8.5+) (#21075) 2026-01-29 12:01:01 +01:00
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Máté Kocsis
eea9a62b1b Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix constant references inside parameter default values when generating the manual
2026-01-08 22:52:32 +01:00
Máté Kocsis
eb1e22b1df Fix constant references inside parameter default values when generating the manual 2026-01-08 22:51:28 +01:00
Máté Kocsis
6dad2060b8 Merge branch 'PHP-8.5'
* PHP-8.5:
  fix: Allow variadic syntax in PHPDoc parameter annotation in `gen_stub.php` (#20342)
2025-12-27 13:01:18 +01:00
Máté Kocsis
324db3a77a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  fix: Allow variadic syntax in PHPDoc parameter annotation in `gen_stub.php` (#20342)
2025-12-27 13:00:29 +01:00
Máté Kocsis
14d8e84236 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  fix: Allow variadic syntax in PHPDoc parameter annotation in `gen_stub.php` (#20342)
2025-12-27 12:54:04 +01:00
Michael Telgmann
09cb5ad442 fix: Allow variadic syntax in PHPDoc parameter annotation in gen_stub.php (#20342)
Closes #20277

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2025-12-27 12:53:15 +01:00
Máté Kocsis
85b681a206 Merge branch 'PHP-8.5'
* PHP-8.5:
  gen_stub: Fix php-parser package download (#20775)
2025-12-25 21:11:15 +01:00
Máté Kocsis
dc5de5d419 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  gen_stub: Fix php-parser package download (#20775)
2025-12-25 21:10:49 +01:00
Giovanni Giacobbi
7d4ba80705 gen_stub: Fix php-parser package download (#20775)
If the system wgetrc has the `content-disposition = on` option, the file is
actually saved as `PHP-Parser-5.0.0.tar.gz`, causing a subsequent failure.

Even with `content-disposition = off`, if for any reason the download file
already exists and is corrupted, it won't be overwritten, and a new file
such as `v5.0.0.tar.gz.1` is saved instead.

We solve both problems by enforcing the name of the downloaded file.

Also, if for any other reason the unpacking should fail, remove the created
directory to allow further attempts.
2025-12-25 21:10:29 +01:00
Niels Dossche
57ce245e1e Reduce code bloat in arginfo by using specialised string releases (#20016)
* Reduce code bloat in arginfo by using specialised string releases

Comparing this patch to master (c7da728574),
with a plain configure command without any options:

```
   text	   data	    bss	    dec	    hex	filename
20683738	1592400	 137712	22413850	156021a	sapi/cli/php
20688522	1592400	 137712	22418634	15614ca	sapi/cli/php_old
```

We see a minor reduction of 0.023% in code size.

* Also use true for the other initialization line

* Also use specialized code for consts
2025-10-02 22:00:20 +02:00
Daniel Scherzer
3f3a266a2b gen_stub: Infer constants' types from values (#19568)
Don't require `@var` with a type when the type can be inferred from a literal
value in the stub file.
2025-09-03 18:26:43 -07:00
Tim Düsterhus
092127cf25 gen_stub: Update to PHP-Parser 5.6.1 (#19495)
This fixes a PHP 8.5 Deprecation:

> Deprecated: Method SplObjectStorage::attach() is deprecated since 8.5, use
> method SplObjectStorage::offsetSet() instead in
> php-src/build/PHP-Parser-5.6.0/lib/PhpParser/Parser/Php7.php on line 2692
2025-08-16 14:04:56 +02:00
Daniel Scherzer
54863f4930 gen_stub: Update PHP-Parser to 5.6.0 (#19271)
Includes support for declaring functions named `clone`, so update the stub file
where `clone` is declared to remove the `_clone` workaround.
2025-07-29 07:47:58 -07:00
Daniel Scherzer
ff810d5e36 Arginfo: reuse zend_string objects for initializing attribute values (#19241)
Avoid initializing the same string content multiple times and make use of the
fact that the strings created to initialize attribute values are not freed by
simply making use of an existing zend_string with the same content if one is
available.
2025-07-27 17:27:22 -07:00
Daniel Scherzer
747ecce51f gen_stub: simplify ClassInfo::getRegistration() 2025-07-25 11:17:34 -07:00
Daniel Scherzer
74f7ecbe04 gen_stub: add ConstInfo::getPredefinedConstantElement()
Simplifies the implementation of `::getPredefinedConstantTerm()` and
`::getPredefinedConstantEntry()`, which only differ in the name of the tag
used.
2025-07-25 11:17:34 -07:00
Daniel Scherzer
5ae87ffef4 gen_stub: avoid unneeded regex match 2025-07-25 11:17:34 -07:00
Daniel Scherzer
ecc403a8fa gen_stub: inline computeStubHash() 2025-07-25 11:17:34 -07:00
Daniel Scherzer
2ed5472f06 gen_stub: make some FuncInfo methods private
* `FuncInfo::isFinalMethod()`
* `FuncInfo::getModifierNames()`
* `FuncInfo::equalsApartFromNameAndRefcount()`
2025-07-25 11:17:34 -07:00
Daniel Scherzer
0b01640b58 gen_stub: replace FunctionOrMethodName::isMethod() with instanceof 2025-07-25 11:17:34 -07:00
Daniel Scherzer
49f1685cde gen_stub: simplify FuncInfo::getFramelessDeclaration() 2025-07-25 11:17:34 -07:00
Daniel Scherzer
988da4c951 gen_stub: simplify FuncInfo::getFunctionEntry() 2025-07-25 11:17:34 -07:00
Daniel Scherzer
9dfee95dae gen_stub: add SimpleType::toTypeInfo()
Simplifies the implementation of `::toTypeCode()` and `::toTypeMask()` by
combining the `switch` blocks.
2025-07-25 11:17:34 -07:00
Daniel Scherzer
e5d4d656ab gen_stub: replace AbstractConstName::isClassConst() with instanceof 2025-07-25 11:17:34 -07:00
Daniel Scherzer
8bd8223bad gen_stub: remove unused AbstractConstName::equals() 2025-07-25 11:17:34 -07:00
Daniel Scherzer
15547a2eb1 gen_stub: simplify generateFunctionEntries() 2025-07-25 11:17:34 -07:00
Daniel Scherzer
30c8480a39 gen_stub: move getFileDocComments() into FileInfo
Reduce the number of global functions by moving it to static method
`FileInfo::getFileDocComments()`. Since it is only used by
`FileInfo::parseStubFile()`, also make it private.
2025-07-25 11:17:34 -07:00
Daniel Scherzer
24d94197fd gen_stub: move generateClassEntryCode() into FileInfo
Reduce the number of global functions by moving it to instance method
`FileInfo::generateClassEntryCode()`.
2025-07-25 11:17:34 -07:00
Daniel Scherzer
0d221c5b70 gen_stub: create VersionFlags class
This new class holds the logic for applying different flags based on the PHP
version, and replaces `VariableLike::addFlagForVersionsAbove()` (use
`VersionFlags::addForVersionsAbove()`) and `generateVersionDependentFlagCode()`
(use `VersionFlags::generateVersionDependentFlagCode()`).
2025-07-25 11:17:34 -07:00
Daniel Scherzer
1218e39b07 gen_stub: add maximum option to generateVersionDependentFlagCode()
In preparation for moving this logic to a dedicated class, add support for a
maximum version of PHP in the generation of version-dependent flags. This
replaces the manual logic in `FuncInfo::getFunctionEntry()` to split up the
flags that are used when PHP 8.4 is not supported.
2025-07-25 11:17:34 -07:00
DanielEScherzer
1eadf553f1 Arginfo: avoid using temporary zvals for initializing attribute values (#19141)
Instead of
* adding a zval on the stack
* initializing it
* copying the value to the attribute

Just initialize the value directly in the zend_attribute_arg
2025-07-21 13:33:51 -07:00
Daniel Scherzer
142e378618 Arginfo: add and use known strings for attribute values 2025-07-14 17:31:22 -07:00
Daniel Scherzer
0c920ecb07 gen_stub: use StringBuilder for attribute strings 2025-07-14 17:31:22 -07:00