Doc #75805 [NEW]: Documentation should clarify behavior of version_compare when there are spaces
| From: | ksours at internetbrands dot com | Date: | Thu, 11 Jan 2018 23:51:43 +0000 |
| Subject: | Doc #75805 [NEW]: Documentation should clarify behavior of version_compare when there are spaces | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-15334@lists.php.net to get a copy of this message | ||
From: ksours at internetbrands dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Documentation should clarify behavior of version_compare when there are spaces
Description:
------------
I'm not 100% sure if this is a documentation problem or a code problem
but the documentation doesn't quite match the behavior so one of them is
wrong. Since the function behavior isn't clearly wrong I'm going with
doc.
On "version_compare" it says:
"Then it compares the parts starting from left to right. If a part
contains special version strings these are handled in the following
order: any string not found in this list < dev < alpha = a < beta = b <
RC = rc < # < pl = p."
If there is a space in the version string this gets incorporated into
the "special string" and thus the string will always fall under "any
string not found in this list" even if it appears to match. You can
work this out from the transformations described but it's *not*
intuitive and should be explicitly called out (or the function behavior
changed to handle spaces)
Test script:
---------------
//these will all return "equal" results which is not what is immediately
expected
var_dump(version_compare('1.0.0 alpha 1', '1.0.0 beta 1'));
var_dump(version_compare('1.0.0 dev 1', '1.0.0 beta 1'));
var_dump(version_compare('1.0.0 totalgarbage 1', '1.0.0 beta 1'));
--
Edit bug report at https://bugs.php.net/bug.php?id=75805&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75805&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75805&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75805&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75805&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75805&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75805&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75805&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75805&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75805&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75805&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75805&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75805&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75805&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75805&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75805&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75805&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75805&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75805&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75805&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75805&r=mysqlcfg