Issue Type: New Feature Created: 2010-03-17T10:24:03.000+0000 Last Updated: 2012-11-20T21:37:30.000+0000 Status: Open Fix version(s): Reporter: Josh Ribakoff (firstname.lastname@example.org) Assignee: None Tags: - Zend_Version
Related issues: - ZF-10363
As some of the legacy projects I work on slowly adopt ZF, we also adopt some of ZF's conventions (naming, unit testing).
One thing I find common to all projects is tracking the current version. Sometimes I make a file version.text, but I like the way ZF handles it, with the Zend_Version class.
Would it make sense to let me extend that for use in my other projects (so I don't duplicate the compareVersion method?).
I'd suggest to remove the "final class" and convert it to late static binding, just in case.
Posted by Michael Rehbein (tech13) on 2010-03-17T10:33:09.000+0000
Since ZF 1.10 still supports PHP 5.2, late static binding isn't an option. Still an option for ZF2.
Could adjust the compare to
public static function compareVersion($version, $version2 = Zend_Version::VERSION)
to allow for BC, and still use the compare version for items outside of ZF.
Posted by Matthew Weier O'Phinney (matthew) on 2010-03-17T10:41:14.000+0000
The essence of Zend_Version boils down to two things:
compareVersion() is really simply a wrapper for PHP's version_compare, though it contains some minor logic to accommodate what we termed "Preview Release" versions prior to 1.8, but which were, in fact, alpha versions. (The logic does a simple regular expression to translate "pr" to "a" in the version string.) If we did not have those versions haunting us, we would have no need for the method, to be honest.
As long as your version numbers follow those that version_compare() understands, I really see no need to extend Zend_Version; simply create a namespace-level constant or a class constant, and feed it to version_compare().
Posted by Matthew Weier O'Phinney (matthew) on 2010-03-17T10:42:47.000+0000
We may revisit the "final" declaration for 2.0, but likely not prior to that.
Posted by Josh Ribakoff (email@example.com) on 2010-03-17T11:01:56.000+0000
If you guys don't intend to add additional business logic to that namespace in the future, then I guess we'd have no use for it.
Posted by Benoît Durand (intiilapa) on 2010-09-02T09:59:36.000+0000
I can add a method isLastest() to complete the method getLatest().
Have you found an issue?
See the Overview section for more details.