+ return $this->cache->fetch('[C]'.$cacheKey) >= $lastModification;
+ }
+
+ /**
+ * Returns the time the class was last modified, testing traits and parents
+ *
+ * @param ReflectionClass $class
+ * @return int
+ */
+ private function getLastModification(ReflectionClass $class)
+ {
+ $filename = $class->getFileName();
+ $parent = $class->getParentClass();
+
+ return max(array_merge(
+ [$filename ? filemtime($filename) : 0],
+ array_map([$this, 'getTraitLastModificationTime'], $class->getTraits()),
+ array_map([$this, 'getLastModification'], $class->getInterfaces()),
+ $parent ? [$this->getLastModification($parent)] : []
+ ));
+ }
+
+ /**
+ * @param ReflectionClass $reflectionTrait
+ * @return int
+ */
+ private function getTraitLastModificationTime(ReflectionClass $reflectionTrait)
+ {
+ $fileName = $reflectionTrait->getFileName();
+
+ return max(array_merge(
+ [$fileName ? filemtime($fileName) : 0],
+ array_map([$this, 'getTraitLastModificationTime'], $reflectionTrait->getTraits())
+ ));