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:
|
- SPL:
|
||||||
. ArrayObject no longer accepts enums, as modifying the $name or $value
|
. ArrayObject no longer accepts enums, as modifying the $name or $value
|
||||||
properties can break engine assumptions.
|
properties can break engine assumptions.
|
||||||
|
. SplFileObject::fwrite's parameter $length is now nullable. The default
|
||||||
|
value changed from 0 to null.
|
||||||
|
|
||||||
========================================
|
========================================
|
||||||
2. New Features
|
2. New Features
|
||||||
|
|
|
@ -2606,15 +2606,18 @@ PHP_METHOD(SplFileObject, fwrite)
|
||||||
char *str;
|
char *str;
|
||||||
size_t str_len;
|
size_t str_len;
|
||||||
zend_long length = 0;
|
zend_long length = 0;
|
||||||
|
bool length_is_null = true;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &length) == FAILURE) {
|
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||||
RETURN_THROWS();
|
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);
|
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() > 1) {
|
if (!length_is_null) {
|
||||||
if (length >= 0) {
|
if (length >= 0) {
|
||||||
str_len = MIN((size_t)length, str_len);
|
str_len = MIN((size_t)length, str_len);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -283,7 +283,7 @@ class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIt
|
||||||
public function fscanf(string $format, mixed &...$vars): array|int|null {}
|
public function fscanf(string $format, mixed &...$vars): array|int|null {}
|
||||||
|
|
||||||
/** @tentative-return-type */
|
/** @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 */
|
/** @tentative-return-type */
|
||||||
public function fstat(): array {}
|
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.
|
/* 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_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1)
|
||||||
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
|
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_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(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()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
#define arginfo_class_SplFileObject_fstat arginfo_class_SplFileInfo___debugInfo
|
#define arginfo_class_SplFileObject_fstat arginfo_class_SplFileInfo___debugInfo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue