4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Resource;
15 * ComposerResource tracks the PHP version and Composer dependencies.
17 * @author Nicolas Grekas <p@tchwork.com>
19 class ComposerResource implements SelfCheckingResourceInterface, \Serializable
23 private static $runtimeVendors;
25 public function __construct()
28 $this->vendors = self::$runtimeVendors;
31 public function getVendors()
33 return array_keys($this->vendors);
39 public function __toString()
47 public function isFresh($timestamp)
51 return self::$runtimeVendors === $this->vendors;
54 public function serialize()
56 return serialize($this->vendors);
59 public function unserialize($serialized)
61 $this->vendors = unserialize($serialized);
64 private static function refresh()
66 self::$runtimeVendors = array();
68 foreach (get_declared_classes() as $class) {
69 if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
70 $r = new \ReflectionClass($class);
71 $v = dirname(dirname($r->getFileName()));
72 if (file_exists($v.'/composer/installed.json')) {
73 self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');