(bug 43801) add a getter for ICU version to ICUCollation
authorMatmaRex <matma.rex@gmail.com>
Fri, 18 Jan 2013 21:36:32 +0000 (22:36 +0100)
committerMatmaRex <matma.rex@gmail.com>
Wed, 30 Jan 2013 18:46:25 +0000 (19:46 +0100)
It will be necessary to be able to use correct version of Unicode
data files.

The constant INTL_ICU_VERSION this getter returns isn't really
documented. It is available since PHP 5.3.7 (see PHP bug 54561),
the getter will fail gracefully on older PHPs. It should be possible to
determine the ICU version on these by grepping the output of phpinfo(),
but I don't think such a minor improvement is worth such a huge hack.

Change-Id: Iee4b8380406ae71c980dfdd7b9fdd0b58ecb9cd0

includes/Collation.php

index 3cc7902..63cfbe1 100644 (file)
@@ -374,5 +374,21 @@ class IcuCollation extends Collation {
                }
                return false;
        }
+
+       /**
+        * Return the version of ICU library used by PHP's intl extension,
+        * or false when the extension is not installed of the version
+        * can't be determined.
+        *
+        * The constant INTL_ICU_VERSION this function refers to isn't really
+        * documented. It is available since PHP 5.3.7 (see PHP bug 54561).
+        * This function will return false on older PHPs.
+        *
+        * @since 1.21
+        * @return string|false
+        */
+       static function getICUVersion() {
+               return defined( 'INTL_ICU_VERSION' ) ? INTL_ICU_VERSION : false;
+       }
 }