From 774e9d0da6634e94e6332160749fc5add257f1bd Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 5 Mar 2012 15:13:07 +0100 Subject: [PATCH] Remove dependency on filter_var --- CHANGELOG.md | 1 + src/Composer/Command/InitCommand.php | 2 +- src/Composer/Repository/ComposerRepository.php | 2 +- src/Composer/Repository/PearRepository.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96dbcc00d..62315e64e 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 80c487935..6f8433c23 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -34,7 +34,7 @@ class InitCommand extends Command public function parseAuthorString($author) { if (preg_match('/^(?P[- \.,a-z0-9]+) <(?P.+?)>$/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'] diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index fadfd6a7c..03a13b8e2 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/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']); } diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index ed7bd8d53..a1a2f4272 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/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']); }