vendor/symfony/config/Resource/ComposerResource.php line 19

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Config\Resource;
  11. /**
  12.  * ComposerResource tracks the PHP version and Composer dependencies.
  13.  *
  14.  * @author Nicolas Grekas <p@tchwork.com>
  15.  */
  16. class ComposerResource implements SelfCheckingResourceInterface\Serializable
  17. {
  18.     private $vendors;
  19.     private static $runtimeVendors;
  20.     public function __construct()
  21.     {
  22.         self::refresh();
  23.         $this->vendors self::$runtimeVendors;
  24.     }
  25.     public function getVendors()
  26.     {
  27.         return array_keys($this->vendors);
  28.     }
  29.     /**
  30.      * {@inheritdoc}
  31.      */
  32.     public function __toString()
  33.     {
  34.         return __CLASS__;
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     public function isFresh($timestamp)
  40.     {
  41.         self::refresh();
  42.         return array_values(self::$runtimeVendors) === array_values($this->vendors);
  43.     }
  44.     /**
  45.      * @internal
  46.      */
  47.     public function serialize()
  48.     {
  49.         return serialize($this->vendors);
  50.     }
  51.     /**
  52.      * @internal
  53.      */
  54.     public function unserialize($serialized)
  55.     {
  56.         $this->vendors unserialize($serialized);
  57.     }
  58.     private static function refresh()
  59.     {
  60.         self::$runtimeVendors = [];
  61.         foreach (get_declared_classes() as $class) {
  62.             if ('C' === $class[0] && === strpos($class'ComposerAutoloaderInit')) {
  63.                 $r = new \ReflectionClass($class);
  64.                 $v \dirname(\dirname($r->getFileName()));
  65.                 if (file_exists($v.'/composer/installed.json')) {
  66.                     self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');
  67.                 }
  68.             }
  69.         }
  70.     }
  71. }