Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_directory.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function fpassthru(): int {}
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 {}
Expand Down
4 changes: 2 additions & 2 deletions ext/spl/spl_directory_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading