From 44bd943c1818fb5976d4cf66cd4779d120be6b00 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Sun, 24 May 2026 23:41:54 +0200 Subject: [PATCH 1/7] change style of sscanf --- reference/strings/functions/sscanf.xml | 112 ++++++++++++------------- 1 file changed, 52 insertions(+), 60 deletions(-) diff --git a/reference/strings/functions/sscanf.xml b/reference/strings/functions/sscanf.xml index 40977dca7b97..58a22543fc12 100644 --- a/reference/strings/functions/sscanf.xml +++ b/reference/strings/functions/sscanf.xml @@ -14,66 +14,63 @@ stringformat mixedvars - + The function sscanf is the input analog of printf. sscanf reads from the string string and interprets it according to the specified format. - - + + Any whitespace in the format string matches any whitespace in the input string. This means that even a tab (\t) in the format string can match a single space character in the input string. - + &reftitle.parameters; - - - - string - - - The input string being parsed. - - - - &strings.scanf.parameter.format; - - vars - - - Optionally pass in variables by reference that will contain the parsed values. - - - - - + + + string + + + The input string being parsed. + + + + &strings.scanf.parameter.format; + + vars + + + Optionally pass in variables by reference that will contain the parsed values. + + + + &reftitle.returnvalues; - + If only two parameters were passed to this function, the values parsed will be returned as an array. Otherwise, if optional parameters are passed, the function will return the number of assigned values. The optional parameters must be passed by reference. - - + + If there are more substrings expected in the format than there are available within string, &null; will be returned. - + &reftitle.examples; - - - <function>sscanf</function> Example - - + <function>sscanf</function> Example + + ]]> - - - - + + + If optional parameters are passed, the function will return the number of assigned values. - - - - <function>sscanf</function> - using optional parameters - - + + <function>sscanf</function> - using optional parameters + + \n"; ?> ]]> - - - + + &reftitle.seealso; - - - printf - sprintf - fprintf - vprintf - vsprintf - vfprintf - fscanf - number_format - date - - + + printf + sprintf + fprintf + vprintf + vsprintf + vfprintf + fscanf + number_format + date + From 3ce71f8b039f9bae87ad442eefec0573da81bcf5 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Sun, 24 May 2026 23:47:41 +0200 Subject: [PATCH 2/7] change style of fscanf and mark array as type --- reference/filesystem/functions/fscanf.xml | 106 ++++++++++------------ reference/spl/splfileobject/fscanf.xml | 76 +++++++--------- reference/strings/functions/sscanf.xml | 4 +- 3 files changed, 86 insertions(+), 100 deletions(-) diff --git a/reference/filesystem/functions/fscanf.xml b/reference/filesystem/functions/fscanf.xml index d32b2a7275ad..bedc198fe206 100644 --- a/reference/filesystem/functions/fscanf.xml +++ b/reference/filesystem/functions/fscanf.xml @@ -14,67 +14,64 @@ stringformat mixedvars - + The function fscanf is similar to sscanf, but it takes its input from a file associated with stream and interprets the input according to the specified format. - - + + Any whitespace in the format string matches any whitespace in the input stream. This means that even a tab (\t) in the format string can match a single space character in the input stream. - - + + Each call to fscanf reads one line from the file. - + &reftitle.parameters; - - - - stream - - &fs.file.pointer; - - - &strings.scanf.parameter.format; - - vars - - - The optional assigned values. - - - - - + + + stream + + &fs.file.pointer; + + + &strings.scanf.parameter.format; + + vars + + + The optional assigned values. + + + + &reftitle.returnvalues; - + If only two parameters were passed to this function, the values parsed will be - returned as an array. Otherwise, if optional parameters are passed, the - function will return the number of assigned values. The optional + returned as an array. Otherwise, if optional parameters are passed, + the function will return the number of assigned values. The optional parameters must be passed by reference. - - + + If there are more substrings expected in the format than there are available within string, &null; will be returned. On other errors, &false; will be returned. - + &reftitle.examples; - - - <function>fscanf</function> Example - - + <function>fscanf</function> Example + + ]]> - - - - - - Contents of users.txt - - + + + Contents of users.txt + + - - - + + &reftitle.seealso; - - - fread - fgets - fgetss - sscanf - printf - sprintf - - + + fread + fgets + fgetss + sscanf + printf + sprintf + diff --git a/reference/spl/splfileobject/fscanf.xml b/reference/spl/splfileobject/fscanf.xml index d492b5ce969d..886e9ab7159e 100644 --- a/reference/spl/splfileobject/fscanf.xml +++ b/reference/spl/splfileobject/fscanf.xml @@ -13,81 +13,75 @@ stringformat mixedvars - + Reads a line from the file and interprets it according to the specified format. - - + + Any whitespace in the format string matches any whitespace in the line from the file. This means that even a tab (\t) in the format string can match a single space character in the input stream. - + &reftitle.parameters; - - - &strings.scanf.parameter.format; - - vars - - - The optional assigned values. - - - - - + + &strings.scanf.parameter.format; + + vars + + + The optional assigned values. + + + + &reftitle.returnvalues; - + If only one parameter is passed to this method, the values parsed will be - returned as an array. Otherwise, if optional parameters are passed, the - function will return the number of assigned values. The optional + returned as an array. Otherwise, if optional parameters are passed, + the function will return the number of assigned values. The optional parameters must be passed by reference. - + &reftitle.examples; - - - <methodname>SplFileObject::fscanf</methodname> example - + + <methodname>SplFileObject::fscanf</methodname> example + fscanf("%s %s %s")) { - list ($name, $profession, $countrycode) = $userinfo; - // Do something with $name $profession $countrycode + list ($name, $profession, $countrycode) = $userinfo; + // Do something with $name $profession $countrycode } ?> ]]> - - Contents of users.txt - + + Contents of users.txt + - - - + + &reftitle.seealso; - - - fscanf - sscanf - printf - sprintf - - + + fscanf + sscanf + printf + sprintf + diff --git a/reference/strings/functions/sscanf.xml b/reference/strings/functions/sscanf.xml index 58a22543fc12..91beb0e4647d 100644 --- a/reference/strings/functions/sscanf.xml +++ b/reference/strings/functions/sscanf.xml @@ -54,8 +54,8 @@ &reftitle.returnvalues; If only two parameters were passed to this function, the values parsed will - be returned as an array. Otherwise, if optional parameters are passed, the - function will return the number of assigned values. The optional parameters + be returned as an array. Otherwise, if optional parameters are passed, + the function will return the number of assigned values. The optional parameters must be passed by reference. From 7af7c98e4f7c983581dc05c58b958bb6c0c1267b Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Mon, 25 May 2026 00:27:42 +0200 Subject: [PATCH 3/7] clarify fscanf/sscanf negative return value --- reference/filesystem/functions/fscanf.xml | 5 +++++ reference/spl/splfileobject/fscanf.xml | 12 +++++++++++- reference/strings/functions/sscanf.xml | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/reference/filesystem/functions/fscanf.xml b/reference/filesystem/functions/fscanf.xml index bedc198fe206..d2b20921a7df 100644 --- a/reference/filesystem/functions/fscanf.xml +++ b/reference/filesystem/functions/fscanf.xml @@ -64,6 +64,11 @@ than there are available within string, &null; will be returned. On other errors, &false; will be returned. + + When optional parameters are used and the end of the input + string is reached before any value has been + parsed, -1 is returned. + diff --git a/reference/spl/splfileobject/fscanf.xml b/reference/spl/splfileobject/fscanf.xml index 886e9ab7159e..7f2f1a3df755 100644 --- a/reference/spl/splfileobject/fscanf.xml +++ b/reference/spl/splfileobject/fscanf.xml @@ -40,11 +40,21 @@ &reftitle.returnvalues; - If only one parameter is passed to this method, the values parsed will be + If only two parameters were passed to this function, the values parsed will be returned as an array. Otherwise, if optional parameters are passed, the function will return the number of assigned values. The optional parameters must be passed by reference. + + If there are more substrings expected in the format + than there are available within string, + &null; will be returned. On other errors, &false; will be returned. + + + When optional parameters are used and the end of the input + string is reached before any value has been + parsed, -1 is returned. + diff --git a/reference/strings/functions/sscanf.xml b/reference/strings/functions/sscanf.xml index 91beb0e4647d..90aaa7262110 100644 --- a/reference/strings/functions/sscanf.xml +++ b/reference/strings/functions/sscanf.xml @@ -63,6 +63,11 @@ than there are available within string, &null; will be returned. + + When optional parameters are used and the end of the input + string is reached before any value has been + parsed, -1 is returned. + From 0515da6fa61642d58f65fa5fa313ec4b86275c2d Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Mon, 25 May 2026 00:29:31 +0200 Subject: [PATCH 4/7] convert para to simpara --- reference/filesystem/functions/fscanf.xml | 4 ++-- reference/spl/splfileobject/fscanf.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/filesystem/functions/fscanf.xml b/reference/filesystem/functions/fscanf.xml index d2b20921a7df..82a532c2dc6c 100644 --- a/reference/filesystem/functions/fscanf.xml +++ b/reference/filesystem/functions/fscanf.xml @@ -43,9 +43,9 @@ vars - + The optional assigned values. - + diff --git a/reference/spl/splfileobject/fscanf.xml b/reference/spl/splfileobject/fscanf.xml index 7f2f1a3df755..fba64cc3a067 100644 --- a/reference/spl/splfileobject/fscanf.xml +++ b/reference/spl/splfileobject/fscanf.xml @@ -72,7 +72,7 @@ while ($userinfo = $file->fscanf("%s %s %s")) { ?> ]]> - Contents of users.txt + Contents of users.txt Date: Mon, 25 May 2026 10:47:21 +0200 Subject: [PATCH 5/7] Remove indent from CDATA Co-authored-by: Kamil Tekiela --- reference/filesystem/functions/fscanf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/filesystem/functions/fscanf.xml b/reference/filesystem/functions/fscanf.xml index 82a532c2dc6c..8fc4716f1e92 100644 --- a/reference/filesystem/functions/fscanf.xml +++ b/reference/filesystem/functions/fscanf.xml @@ -76,7 +76,7 @@ <function>fscanf</function> Example - Date: Mon, 25 May 2026 15:06:11 +0200 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Louis-Arnaud --- reference/filesystem/functions/fscanf.xml | 2 +- reference/strings/functions/sscanf.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/filesystem/functions/fscanf.xml b/reference/filesystem/functions/fscanf.xml index 8fc4716f1e92..cc6c2cdce64c 100644 --- a/reference/filesystem/functions/fscanf.xml +++ b/reference/filesystem/functions/fscanf.xml @@ -91,7 +91,7 @@ fclose($handle); Contents of users.txt - <function>sscanf</function> Example - <function>sscanf</function> - using optional parameters - Date: Mon, 25 May 2026 18:58:36 +0200 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Louis-Arnaud --- reference/filesystem/functions/fscanf.xml | 4 ++-- reference/spl/splfileobject/fscanf.xml | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/reference/filesystem/functions/fscanf.xml b/reference/filesystem/functions/fscanf.xml index cc6c2cdce64c..9282b702c085 100644 --- a/reference/filesystem/functions/fscanf.xml +++ b/reference/filesystem/functions/fscanf.xml @@ -65,8 +65,8 @@ &null; will be returned. On other errors, &false; will be returned. - When optional parameters are used and the end of the input - string is reached before any value has been + When optional parameters are used and the end of the input read from + stream is reached before any value has been parsed, -1 is returned. diff --git a/reference/spl/splfileobject/fscanf.xml b/reference/spl/splfileobject/fscanf.xml index fba64cc3a067..18e2e94a71b1 100644 --- a/reference/spl/splfileobject/fscanf.xml +++ b/reference/spl/splfileobject/fscanf.xml @@ -40,20 +40,20 @@ &reftitle.returnvalues; - If only two parameters were passed to this function, the values parsed will be + If only one parameter is passed to this method, the values parsed will be returned as an array. Otherwise, if optional parameters are passed, - the function will return the number of assigned values. The optional + the method will return the number of assigned values. The optional parameters must be passed by reference. If there are more substrings expected in the format - than there are available within string, - &null; will be returned. On other errors, &false; will be returned. + than there are available in the line read from the file, + &null; will be returned. - When optional parameters are used and the end of the input - string is reached before any value has been - parsed, -1 is returned. + When optional parameters are used and the end of the line read from the + file is reached before any value has been parsed, -1 + is returned.