Doc #78393 [NEW]: Incorrectly specified behavior.

From: Date: Fri, 09 Aug 2019 14:53:40 +0000
Subject: Doc #78393 [NEW]: Incorrectly specified behavior.
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16874@lists.php.net to get a copy of this message
From: dmorgan at adobe dot com Operating system: n/a PHP version: Irrelevant Package: PHP Language Specification Bug Type: Documentation Problem Bug description:Incorrectly specified behavior. Description: ------------ The documentation describes the operation of the method as follows: "Returns a string with the first character of each word in str capitalized, if that character is alphabetic." The documentation describes a word as follows: "The definition of a word is any string of characters that is immediately after any character listed in the delimiters parameter (By default these are: space, form-feed, newline, carriage return, horizontal tab, and vertical tab)." It should probably read more like: "The definition of a word is any string of characters that is EITHER AT THE START OF STR, OR immediately after any character listed in the delimiters parameter (By default these are: space, form-feed, newline, carriage return, horizontal tab, and vertical tab)." Alternatively, the first line could be changed to read something like: "Returns a string with the first character of STR, AND THE FIRST CHARACTER OF each SUBSEQUENT word in str capitalized, if that character is alphabetic." I would recommend, while you're in there, clarifying the first line by adding something like "All characters in the remainder of word are left unchanged." - many are caught out by interpreting this as a TitleCase method, so try to use this function to Title Case an UPPER CASE string, without first lowercasing it. You can see at least one such victim in the comments on the page. Finally, I'd also recommend rigorously clarifying what's meant by "alphabetic", and how that definition might change with localization; and/or giving a clear pointer to a page where such a clarification is made (not just in the "see also" section!) Test script: --------------- php -r 'echo ucwords("foo_bar_BAZ", "_") . "\n"; Expected result: ---------------- If a word were indeed "any string of characters that is immediately after any character listed in the delimiters parameter", you'd expect the output of the above to be "foo_Bar_BAZ", or possibly "foo_Bar_Baz" without the optional clarification. Actual result: -------------- The output is instead "Foo_Bar_BAZ". Note how the first character of the string is capitalized, even though it is NOT immediately after the delimiter '_' as stated in the documentation. -- Edit bug report at https://bugs.php.net/bug.php?id=78393&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78393&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78393&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78393&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78393&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78393&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78393&r=support Expected behavior: https://bugs.php.net/fix.php?id=78393&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78393&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78393&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78393&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78393&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78393&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78393&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78393&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78393&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78393&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78393&r=mysqlcfg

« previous php.doc.bugs (#16874) next »