mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
SplFileObject::fwrite $length param nullable (#17242)
This commit is contained in:
parent
f6469054dc
commit
bf5e6c5f2d
4 changed files with 13 additions and 8 deletions
|
@ -57,6 +57,8 @@ PHP 8.5 UPGRADE NOTES
|
|||
- SPL:
|
||||
. ArrayObject no longer accepts enums, as modifying the $name or $value
|
||||
properties can break engine assumptions.
|
||||
. SplFileObject::fwrite's parameter $length is now nullable. The default
|
||||
value changed from 0 to null.
|
||||
|
||||
========================================
|
||||
2. New Features
|
||||
|
|
|
@ -2606,15 +2606,18 @@ PHP_METHOD(SplFileObject, fwrite)
|
|||
char *str;
|
||||
size_t str_len;
|
||||
zend_long length = 0;
|
||||
bool length_is_null = true;
|
||||
ssize_t written;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &length) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||
Z_PARAM_STRING(str, str_len)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_LONG_OR_NULL(length, length_is_null)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
|
||||
|
||||
if (ZEND_NUM_ARGS() > 1) {
|
||||
if (!length_is_null) {
|
||||
if (length >= 0) {
|
||||
str_len = MIN((size_t)length, str_len);
|
||||
} else {
|
||||
|
|
|
@ -283,7 +283,7 @@ class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIt
|
|||
public function fscanf(string $format, mixed &...$vars): array|int|null {}
|
||||
|
||||
/** @tentative-return-type */
|
||||
public function fwrite(string $data, int $length = 0): int|false {}
|
||||
public function fwrite(string $data, ?int $length = null): int|false {}
|
||||
|
||||
/** @tentative-return-type */
|
||||
public function fstat(): array {}
|
||||
|
|
4
ext/spl/spl_directory_arginfo.h
generated
4
ext/spl/spl_directory_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: c8c3c642d6f8c19a83f6a94ede5b6138a969bc12 */
|
||||
* Stub hash: 06a7809f97dde10e800382fec03a9bb308918bb3 */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1)
|
||||
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
|
||||
|
@ -227,7 +227,7 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SplFileObject_fwrite, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_SplFileObject_fstat arginfo_class_SplFileInfo___debugInfo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue