Browse Source

Remove dependency on filter_var

Jordi Boggiano 13 years ago
parent
commit
774e9d0da6

+ 1 - 0
CHANGELOG.md

@@ -1,6 +1,7 @@
 * 1.0.0-alpha2
 
   * Added "file" downloader type to download plain files
+  * Dependency on filter_var is now optional
 
 * 1.0.0-alpha1 (2012-03-01)
 

+ 1 - 1
src/Composer/Command/InitCommand.php

@@ -34,7 +34,7 @@ class InitCommand extends Command
     public function parseAuthorString($author)
     {
         if (preg_match('/^(?P<name>[- \.,a-z0-9]+) <(?P<email>.+?)>$/i', $author, $match)) {
-            if ($match['email'] === filter_var($match['email'], FILTER_VALIDATE_EMAIL)) {
+            if (!function_exists('filter_var') || $match['email'] === filter_var($match['email'], FILTER_VALIDATE_EMAIL)) {
                 return array(
                     'name'  => trim($match['name']),
                     'email' => $match['email']

+ 1 - 1
src/Composer/Repository/ComposerRepository.php

@@ -31,7 +31,7 @@ class ComposerRepository extends ArrayRepository
             $config['url'] = 'http://'.$config['url'];
         }
         $config['url'] = rtrim($config['url'], '/');
-        if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
+        if (function_exists('filter_var') && !filter_var($config['url'], FILTER_VALIDATE_URL)) {
             throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$config['url']);
         }
 

+ 1 - 1
src/Composer/Repository/PearRepository.php

@@ -31,7 +31,7 @@ class PearRepository extends ArrayRepository
             $config['url'] = 'http://'.$config['url'];
         }
 
-        if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
+        if (function_exists('filter_var') && !filter_var($config['url'], FILTER_VALIDATE_URL)) {
             throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']);
         }