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

141390 Commits

Author SHA1 Message Date
Jorg Adam Sowa
e11a702c05 ext/hash: tests for md5 and sha1 compatibility (#18525)
Add test cases to check compatibility between the `hash("algo")` and `md5()`/`sha1()` functions.
2025-05-09 13:08:58 +01:00
Tim Düsterhus
73c4e9f0b2 Merge branch 'PHP-8.4'
* PHP-8.4:
  gen_stub: Fix `ce_flags` generation for compatibility mode (#18507)
2025-05-09 13:33:58 +02:00
Tim Düsterhus
84f82d0a1c gen_stub: Fix ce_flags generation for compatibility mode (#18507)
* gen_stub: Fix `ce_flags` generation for compatibility mode

Fixes php/php-src#18506

* gen_stub: Improve output for ce_flags compatibility
2025-05-09 13:33:09 +02:00
Daniel Scherzer
2b0cb760d4 gen_stub: move parseStubFile() into FileInfo
Reduce the number of global functions by moving it to static method
`FileInfo::parseStubFile()`. Additionally, make `FileInfo::handleStatements()`
private now that the only caller is part of the class.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
05dbf0707a gen_stub: further reduce the number of public properties
The following properties are made private:
* `ArgInfo::$phpDocType`
* `ClassInfo::$flags`, `::$attributes`, `::$extends`, `::$implements`
* `FileInfo::$isUndocumentable`

The following are made protected:
* `VariableLike::$flags`
2025-05-08 13:06:51 -07:00
Daniel Scherzer
c89d7a7426 gen_stub: add and use FileInfo::getLegacyVersion()
Separate out the creation of a legacy version of a FileInfo object, which has
information for old versions of PHP discarded, from its subsequent use in
`processStubFile()`.

In the process, make `FileInfo::$legacyArginfoGeneration` private, and inline
the single use of `FileInfo::getAllClassInfos()`, removing that method.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
bb555926c4 gen_stub: deduplicate and simplify DocCommentTag processing
For a lot of the structures, the parsing of doc comment tags is based on if a
specific tag is present, or the value that it has if it is. Add a new helper
method, `DocCommentTag::makeTagMap()`, that turns an array of tag instances
into a map from tag name to value (the last value, if there are multiple uses
of the same tag name). Then, for the simple cases where just a tag's presence
is all that is checked, or just the (last) value is used, check the map instead
of using a loop through all of the tags present.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
d42bac2866 gen_stub: move parseDocComments() into DocCommentTag
Reduce the number of global functions by moving it to static method
`DocCommentTag::parseDocComments()`.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
ce3990c1d3 gen_stub: move handlePreprocessorConditions() into FileInfo()
Reduce the number of global functions by moving it to static method
`FileInfo::handlePreprocessorConditions()`. Since it is only used by
`FileInfo::handleStatements()`, also make it private.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
1c9b6b84df gen_stub: move handleStatements() into FileInfo
Reduce the number of global functions by moving it to instance method
`FileInfo::handleStatements()`.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
ec3ecdc2c8 gen_stub: documentation updates
* Use `@param` instead of `@var` for parameters
* Fix type of `$attributeGroups` in `AttributeInfo::createFromGroups()`
* Remove extra documentation of `$allConstInfo` for
`ClassInfo::getClassSynopsisDocument()`, it is already documented under the
correct name `$allConstInfos`
* Remove unneeded `@throws`
2025-05-08 13:06:51 -07:00
Daniel Scherzer
722eba20ae gen_stub: drop unused parameters
The following parameters were either unused before this commit or became unused
as part of updating callers to stop passing unused parameters to other
functions updated in this commit:
* `FuncInfo::getMethodSynopsisDocument()` - `$funcMap`, `$aliasMap`
* `FuncInfo::getMethodSynopsisElement()` - `$funcMap`, `$aliasMap`
* `ConstInfo::getGlobalConstDeclaration()` - `$allConstInfos`
* `generateMethodSynopses()` - `$aliasMap`
* `replaceMethodSynopses()` - `$aliasMap`
2025-05-08 13:06:51 -07:00
Daniel Scherzer
4861391501 gen_stub: inline some single-use variables 2025-05-08 13:06:51 -07:00
Daniel Scherzer
39a6d6086e gen_stub: move funcInfoToCode() into FuncInfo
Reduce the number of global functions by moving it to instance method
`FuncInfo::toArgInfoCode()`.

In the process, make `FuncInfo::$numRequiredArgs` private.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
b5361d75e0 gen_stub: add ReturnInfo::beginArgInfo()
The vast majority of the decisions about the use of `ZEND_BEGIN_ARG_INFO_EX` or
one of its variations are based on the return information of the function - is
the type builtin, is the return information tentative, does it include an
object mask, etc. Accordingly, move the logic into the `ReturnInfo` class.

The logic is actually moved into two methods, `ReturnInfo::beginArgInfo()`,
which needs to handle the case of tentative returns being used when PHP < 8.1
is supported, and `::beginArgInfoCompatible()`, which can assume that PHP 8.1+
is supported and thus make use of early returns and guard clauses. Further
improvements to the logic will be made in a subsequent commit.

In the process, make `ReturnInfo::$byRef` private.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
24b7c7a365 gen_stub: add ArgInfo::toZendInfo()
Move the logic out of `funcInfoToCode()` and update it. In the process, make
`ArgInfo::getDefaultValueAsArginfoString()` private.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
0d79039027 gen_stub: simplify ArgInfo::getDefaultValueAsMethodSynopsisString()
There is no need to add special handling for the default value of `null`, since
it is not loosely-equals to any of the strings 'UNKNOWN', 'false', 'true', or
'null' it will just be returned directly anyway.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
45d313bbd7 gen_stub: simplify generateVersionDependentFlagCode()
* Return a string rather than an array, all callers just immediately used
`implode()` to join the elements in the array with nothing between them
* In the callers, inline some single-use variables with the template for the
version-dependent code
* Remove the callback to `array_filter` specifying that only items that are not
`empty()` be removed - this is the default behavior
2025-05-08 13:06:51 -07:00
Daniel Scherzer
bfa2b92ca6 gen_stub: add ExposedDocComment::getInitCode()
Deduplicates the setting up of the `zend_string_init_interned()` call, removes
the need for `ExposedDocComment::getLength()` and so that method is removed.
2025-05-08 13:06:51 -07:00
Daniel Scherzer
4527bafad0 gen_stub: break up closing tag in DOMCdataSection
Otherwise GitHub's syntax highlighting treats it as the end of the code and
stops highlighting
2025-05-08 13:06:51 -07:00
Jorg Adam Sowa
c6a9beebff ext/standard/md5: Minor refactorings (#18518)
- Use size_t type instead of int type
- Use false instead of 0
- Remove wrapping comments
2025-05-08 12:00:50 +01:00
Remi Collet
e3715cddf0 Merge branch 'PHP-8.4'
* PHP-8.4:
  bump zip extension version to 1.22.6
2025-05-07 14:24:22 +02:00
Remi Collet
71ffa9596a bump zip extension version to 1.22.6 2025-05-07 14:24:07 +02:00
Niels Dossche
168343d2e8 [RFC] Implement array_first() and array_last() (#18210) 2025-05-07 08:15:50 +02:00
Niels Dossche
50dc301f96 Merge branch 'PHP-8.4'
* PHP-8.4:
  Sync EXTENSIONS and extend maintenance time
2025-05-06 22:07:11 +02:00
Niels Dossche
11ad09e4bf Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Sync EXTENSIONS and extend maintenance time
2025-05-06 22:07:05 +02:00
Niels Dossche
e7a44a68e9 Sync EXTENSIONS and extend maintenance time 2025-05-06 22:06:31 +02:00
Jakub Zelenka
cb4bafa4c0 Init OpenSSL libctx and use it for pkey (#18282) 2025-05-06 20:14:55 +02:00
Ilija Tovilo
905bba637a Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix missing include in win32/globals.c
2025-05-06 15:52:38 +02:00
Ilija Tovilo
14ff4b75a2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix missing include in win32/globals.c
2025-05-06 15:52:30 +02:00
Ilija Tovilo
69f0882d3b Fix missing include in win32/globals.c
This previously errored with:

win32\globals.c(66): error C2220: the following warning is treated as an error
win32\globals.c(66): warning C4013: 'php_win32_signal_ctrl_handler_request_shutdown' undefined; assuming extern returning int

This only errors on master because of 2473f57ba (thanks to Niels for
that info!).

Closes GH-18508
2025-05-06 15:51:37 +02:00
Niels Dossche
e0b73dc977 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18494: PDO OCI segfault in statement GC
2025-05-05 19:30:47 +02:00
Niels Dossche
5825a6be83 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18494: PDO OCI segfault in statement GC
2025-05-05 19:30:42 +02:00
Niels Dossche
dcf9d8f812 Fix GH-18494: PDO OCI segfault in statement GC
This is the same issue that was fixed in 2ae897fff7, but now for OCI.

Closes GH-18495.
2025-05-05 19:30:23 +02:00
Niels Dossche
3c84b01e02 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix leak+crash with sapi_windows_set_ctrl_handler()
2025-05-05 19:14:19 +02:00
Niels Dossche
d4a3e437ae Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix leak+crash with sapi_windows_set_ctrl_handler()
2025-05-05 19:14:13 +02:00
Niels Dossche
fb3536fd60 Fix leak+crash with sapi_windows_set_ctrl_handler()
The ctrl_handler is never destroyed. We have to destroy it at request
end so we avoid leaking it and also avoid keeping a reference to
previous request memory in a next request. The latter can result in a
crash and can be demonstrated with this script and `--repeat 2`:

```php
class Test {
	public function set() {
		sapi_windows_set_ctrl_handler(self::cb(...));
	}
	public function cb() {
	}
}

$test = new Test;
$test->set();
sleep(3);
```
When you hit CTRL+C in the second request you can crash.

This patch resolves both the leak and crash by destroying the
ctrl_handler after a request.

Closes GH-18231.
2025-05-05 19:13:39 +02:00
Niels Dossche
a9b84f9425 Use specialized functions/macros to reduce code size in ext/random (#18499)
On x86-64 with GCC 14.2.1:
zim_Random_Randomizer_getBytes goes from 514 to 418 bytes
zim_Random_Randomizer_getBytesFromString goes from 750 to 676 bytes
2025-05-05 19:12:39 +02:00
David CARLIER
be53902a13 ext/pgsql: globals data struct rework/size reduction (#18503) 2025-05-05 14:40:09 +01:00
Florian Moser
90da4821a2 ext/gmp: Add GMP ECC test (#18363)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
2025-05-05 14:10:29 +01:00
David CARLIER
7855c52e81 ext/standard: gethostbyaddr/gethostbyname using *NEW_STR flavor. (#18502) 2025-05-05 13:58:15 +01:00
Niels Dossche
c91c6545fe Drop name from mysqli_prop_handler (#18498)
It's just not necessary to store this, if we ever need this we can get
this from the hash table.
2025-05-05 12:36:26 +01:00
DanielEScherzer
940ee1a641 gen_stub: ZEND_ACC_NODISCARD is for PHP 8.5+ (#18465) 2025-05-04 15:08:37 -07:00
David CARLIER
9ac5b04487 ext/intl: use RETURN_NEW_STR for intl_get*id_windows_id(). (#18501)
for non interned return values.
2025-05-04 21:44:39 +01:00
Niels Dossche
af87ade8b8 Cleanup php_posix_group_to_array() (#18497)
This function can be static, and the error checks are pointless:
1. It's guaranteed that the return value is an array by now,
   as it is always preceded by array_init(return_value).
2. The null check for g is pointless as every callee already
   handles that in a better way.
2025-05-04 20:07:14 +02:00
Niels Dossche
1fa076e187 Cleanup php_posix_passwd_to_array() (#18496)
This function can be static, and the error checks are pointless:
1. It's guaranteed that the return value is an array by now, as it is
   always preceded by array_init(return_value).
2. The null check for pw is pointless as every callee already handles
   that in a better way.
2025-05-04 20:07:06 +02:00
David Carlier
e80d9535d7 Merge branch 'PHP-8.4' 2025-05-04 14:15:32 +01:00
David Carlier
2e2077172d Merge branch 'PHP-8.3' into PHP-8.4 2025-05-04 14:15:05 +01:00
David Carlier
8a585856d1 Fix GH-18480: array_splice overflow on array length with offset.
close GH-18483
2025-05-04 14:14:22 +01:00
Niels Dossche
4152ca5c8a Fix fuzzer support after CALL VM changes (#18491) 2025-05-04 13:25:42 +02:00