Browse Source

Use ReflectionExtension to read ext versions

Jordi Boggiano 14 years ago
parent
commit
ae922eaf4c
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/Composer/Repository/PlatformRepository.php

+ 9 - 2
src/Composer/Repository/PlatformRepository.php

@@ -36,8 +36,15 @@ class PlatformRepository extends ArrayRepository
             if (in_array($ext, array('standard', 'Core'))) {
             if (in_array($ext, array('standard', 'Core'))) {
                 continue;
                 continue;
             }
             }
-            // TODO maybe we could parse versions from phpinfo(INFO_MODULES)
-            $ext = new MemoryPackage('ext/'.strtolower($ext), '0', 'stable');
+
+            $reflExt = new \ReflectionExtension($ext);
+            try {
+                $version = BasePackage::parseVersion($reflExt->getVersion());
+            } catch (\UnexpectedValueException $e) {
+                $version = array('version' => '0', 'type' => 'stable');
+            }
+
+            $ext = new MemoryPackage('ext/'.strtolower($ext), $version['version'], $version['type']);
             $this->addPackage($ext);
             $this->addPackage($ext);
         }
         }
     }
     }